diff options
| -rw-r--r-- | telephony/java/android/telephony/SubscriptionManager.java | 21 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/TelephonyPermissions.java | 14 |
2 files changed, 18 insertions, 17 deletions
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 4a9b174cedbb..484fd3b17c02 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -2121,27 +2121,24 @@ public class SubscriptionManager { * @hide */ @UnsupportedAppUsage - public static @NonNull int[] getActiveSubscriptionIdList() { - return getActiveSubscriptionIdList(true); - } + public @NonNull int[] getActiveSubscriptionIdList() { + int[] subId = null; - /** - * @return a non-null list of subId's that are active. - * - * @hide - */ - public static @NonNull int[] getActiveSubscriptionIdList(boolean visibleOnly) { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - int[] subId = iSub.getActiveSubIdList(visibleOnly); - if (subId != null) return subId; + subId = iSub.getActiveSubIdList(/*visibleOnly*/true); } } catch (RemoteException ex) { // ignore it } - return new int[0]; + if (subId == null) { + subId = new int[0]; + } + + return subId; + } /** diff --git a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java index 5b57c9d7554c..7a0ab9ca6a28 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java +++ b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java @@ -605,11 +605,15 @@ public final class TelephonyPermissions { */ private static boolean checkCarrierPrivilegeForAnySubId(Context context, Supplier<ITelephony> telephonySupplier, int uid) { - int[] activeSubIds = SubscriptionManager.getActiveSubscriptionIdList(/*visibleOnly*/ false); - for (int activeSubId : activeSubIds) { - if (getCarrierPrivilegeStatus(telephonySupplier, activeSubId, uid) - == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { - return true; + SubscriptionManager sm = (SubscriptionManager) context.getSystemService( + Context.TELEPHONY_SUBSCRIPTION_SERVICE); + int[] activeSubIds = sm.getActiveSubscriptionIdList(); + if (activeSubIds != null) { + for (int activeSubId : activeSubIds) { + if (getCarrierPrivilegeStatus(telephonySupplier, activeSubId, uid) + == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { + return true; + } } } return false; |