diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-10-13 07:57:57 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-10-13 07:57:57 +0000 |
commit | 18ada97fe141a4a67c22060b7e47779e25d0674a (patch) | |
tree | bdf6b513c497a826178bb6c0e94f73373d081995 | |
parent | c2d025f5dfbe5c8277051a295e392d53342bd0c1 (diff) | |
parent | 8b3f749787a1ec6f2add5424d28251a9110e5193 (diff) | |
download | telephony-q_tzdata_aml_297100000.tar.gz |
Snap for 9170954 from 8b3f749787a1ec6f2add5424d28251a9110e5193 to qt-aml-tzdata-releaseq_tzdata_aml_297100400q_tzdata_aml_297100300q_tzdata_aml_297100000q_tzdata_aml_296200000q_tzdata_aml_295600118q_tzdata_aml_295600110q_tzdata_aml_295500002q_tzdata_aml_295500001q_tzdata_aml_297100000android10-mainline-tzdata-releaseandroid10-android13-mainline-tzdata-release
Change-Id: I9b127f8d7eeb7e736867160458938352c8dd2a96
-rw-r--r-- | src/java/com/android/internal/telephony/SubscriptionController.java | 37 | ||||
-rw-r--r-- | tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java | 30 |
2 files changed, 61 insertions, 6 deletions
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java index e97e2a9ac3..f5cfa81426 100644 --- a/src/java/com/android/internal/telephony/SubscriptionController.java +++ b/src/java/com/android/internal/telephony/SubscriptionController.java @@ -692,6 +692,19 @@ public class SubscriptionController extends ISub.Stub { */ @Override public List<SubscriptionInfo> getAllSubInfoList(String callingPackage) { + return getAllSubInfoList(callingPackage, false); + } + + /** + * @param callingPackage The package making the IPC. + * @param callingFeatureId The feature in the package + * @param skipConditionallyRemoveIdentifier if set, skip removing identifier conditionally + * @return List of all SubscriptionInfo records in database, + * include those that were inserted before, maybe empty but not null. + * @hide + */ + public List<SubscriptionInfo> getAllSubInfoList(String callingPackage, + boolean skipConditionallyRemoveIdentifier) { if (VDBG) logd("[getAllSubInfoList]+"); // This API isn't public, so no need to provide a valid subscription ID - we're not worried @@ -710,9 +723,9 @@ public class SubscriptionController extends ISub.Stub { } finally { Binder.restoreCallingIdentity(identity); } - if (subList != null) { + if (subList != null && !skipConditionallyRemoveIdentifier) { if (VDBG) logd("[getAllSubInfoList]- " + subList.size() + " infos return"); - subList.stream().map( + subList = subList.stream().map( subscriptionInfo -> conditionallyRemoveIdentifiers(subscriptionInfo, callingPackage, "getAllSubInfoList")) .collect(Collectors.toList()); @@ -2697,9 +2710,19 @@ public class SubscriptionController extends ISub.Stub { */ @Override public String getSubscriptionProperty(int subId, String propKey, String callingPackage) { - if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( - mContext, subId, callingPackage, "getSubscriptionProperty")) { - return null; + switch (propKey) { + case SubscriptionManager.GROUP_UUID: + if (mContext.checkCallingOrSelfPermission( + Manifest.permission.READ_PRIVILEGED_PHONE_STATE) != PERMISSION_GRANTED) { + EventLog.writeEvent(0x534e4554, "213457638", Binder.getCallingUid()); + return null; + } + break; + default: + if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId, + callingPackage, "getSubscriptionProperty")) { + return null; + } } final long identity = Binder.clearCallingIdentity(); @@ -3334,7 +3357,9 @@ public class SubscriptionController extends ISub.Stub { List<SubscriptionInfo> subInfoList; try { - subInfoList = getAllSubInfoList(mContext.getOpPackageName()); + // need to bypass removing identifier check because that will remove the subList without + // group id. + subInfoList = getAllSubInfoList(mContext.getOpPackageName(), true); if (groupUuid == null || subInfoList == null || subInfoList.isEmpty()) { return new ArrayList<>(); } diff --git a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java index 26adb81958..129b2adad4 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java @@ -674,6 +674,36 @@ public class SubscriptionControllerTest extends TelephonyTest { @Test @SmallTest + public void testGetSubscriptionProperty() throws Exception { + testInsertSim(); + ContentValues values = new ContentValues(); + values.put(SubscriptionManager.GROUP_UUID, 1); + mFakeTelephonyProvider.update(SubscriptionManager.CONTENT_URI, values, + SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=" + 1, null); + + mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); + mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE); + + // should succeed with read phone state permission + String prop = mSubscriptionControllerUT.getSubscriptionProperty(1, + SubscriptionManager.CB_EXTREME_THREAT_ALERT, mContext.getOpPackageName()); + + assertNotEquals(null, prop); + + // group UUID requires privileged phone state permission + prop = mSubscriptionControllerUT.getSubscriptionProperty(1, SubscriptionManager.GROUP_UUID, + mContext.getOpPackageName()); + assertEquals(null, prop); + + // group UUID should succeed once privileged phone state permission is granted + mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE); + prop = mSubscriptionControllerUT.getSubscriptionProperty(1, SubscriptionManager.GROUP_UUID, + mContext.getOpPackageName()); + assertNotEquals(null, prop); + } + + @Test + @SmallTest public void testCreateSubscriptionGroupWithCarrierPrivilegePermission() throws Exception { testInsertSim(); // Adding a second profile and mark as embedded. |