diff --git a/api/system-current.txt b/api/system-current.txt index ed87c0f040337..764a386e45ef8 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9244,6 +9244,8 @@ package android.telephony { public class SubscriptionManager { method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean canDisablePhysicalSubscription(); method public boolean canManageSubscription(@Nullable android.telephony.SubscriptionInfo, @Nullable String); + method @NonNull public int[] getActiveAndHiddenSubscriptionIdList(); + method @NonNull public int[] getActiveSubscriptionIdList(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.SubscriptionInfo getActiveSubscriptionInfoForIcc(@NonNull String); method public java.util.List getAvailableSubscriptionInfoList(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEnabledSubscriptionId(int); diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index f0a3bfd6b3190..af7af5f6f0acf 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -1357,7 +1357,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { public void notifyCarrierNetworkChange(boolean active) { // only CarrierService with carrier privilege rule should have the permission int[] subIds = Arrays.stream(SubscriptionManager.from(mContext) - .getActiveSubscriptionIdList(false)) + .getActiveAndHiddenSubscriptionIdList()) .filter(i -> TelephonyPermissions.checkCarrierPrivilegeForSubId(mContext, i)).toArray(); if (ArrayUtils.isEmpty(subIds)) { diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 630815c72bbb7..ef035456d32a0 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -1296,6 +1296,11 @@ public class SubscriptionManager { * The records will be sorted by {@link SubscriptionInfo#getSimSlotIndex} * then by {@link SubscriptionInfo#getSubscriptionId}. * + * Hidden subscriptions refer to those are not meant visible to the users. + * For example, an opportunistic subscription that is grouped with other + * subscriptions should remain invisible to users as they are only functionally + * supplementary to primary ones. + * *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * or that the calling app has carrier privileges (see * {@link TelephonyManager#hasCarrierPrivileges}). In the latter case, only records accessible @@ -2146,20 +2151,35 @@ public class SubscriptionManager { } /** - * TODO(b/137102918) Make this static, tests use this as an instance method currently. + * Get visible subscription Id(s) of the currently active SIM(s). * * @return the list of subId's that are active, - * is never null but the length maybe 0. + * is never null but the length may be 0. * @hide */ - @UnsupportedAppUsage + @SystemApi public @NonNull int[] getActiveSubscriptionIdList() { return getActiveSubscriptionIdList(/* visibleOnly */ true); } /** - * TODO(b/137102918) Make this static, tests use this as an instance method currently. + * Get both hidden and visible subscription Id(s) of the currently active SIM(s). * + * Hidden subscriptions refer to those are not meant visible to the users. + * For example, an opportunistic subscription that is grouped with other + * subscriptions should remain invisible to users as they are only functionally + * supplementary to primary ones. + * + * @return the list of subId's that are active, + * is never null but the length may be 0. + * @hide + */ + @SystemApi + public @NonNull int[] getActiveAndHiddenSubscriptionIdList() { + return getActiveSubscriptionIdList(/* visibleOnly */false); + } + + /** * @return a non-null list of subId's that are active. * * @hide