From dd2c16678f79c5ff4dc384579c9c4df28715c9e8 Mon Sep 17 00:00:00 2001 From: Michael Groover Date: Fri, 10 May 2019 19:31:13 -0700 Subject: [PATCH] Grant device ID access to app with carrier privlege on any sub ID Fixes: 132173603 Test: atest TelephonyPermissionsTest Test: cts-tradefed run cts-dev -m CtsTelephony3TestCases Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t \ com.android.cts.devicepolicy.DeviceOwnerTest#testDeviceOwnerCanGetDeviceIdentifiers Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t \ com.android.cts.devicepolicy.ManagedProfileTest#testProfileOwnerCanGetDeviceIdentifiers Test: cts-tradefed run cts-dev -m CtsTelephonyTestCases -t android.telephony.cts.TelephonyManagerTest Change-Id: I6a92790389db8ce08118e7f7f45d9309296d2551 --- .../telephony/TelephonyPermissions.java | 150 +++++++++--------- 1 file changed, 72 insertions(+), 78 deletions(-) diff --git a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java index 64c1830c5e5c8..2552f045eedf1 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java +++ b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java @@ -209,18 +209,9 @@ public final class TelephonyPermissions { context.enforcePermission( android.Manifest.permission.READ_PHONE_STATE, pid, uid, message); } catch (SecurityException phoneStateException) { - SubscriptionManager sm = (SubscriptionManager) context.getSystemService( - Context.TELEPHONY_SUBSCRIPTION_SERVICE); - int[] activeSubIds = sm.getActiveSubscriptionIdList(); - for (int activeSubId : activeSubIds) { - // If we don't have the runtime permission, but do have carrier privileges, that - // suffices for reading phone state. - if (getCarrierPrivilegeStatus(telephonySupplier, activeSubId, uid) - == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { - return true; - } - } - return false; + // If we don't have the runtime permission, but do have carrier privileges, that + // suffices for reading phone state. + return checkCarrierPrivilegeForAnySubId(context, telephonySupplier, uid); } } @@ -236,9 +227,9 @@ public final class TelephonyPermissions { * *

This method behaves in one of the following ways: *