From c4dae711ab346c52e84d6f03365662b45484cab2 Mon Sep 17 00:00:00 2001 From: Aishwarya Mallampati Date: Thu, 15 Dec 2022 21:15:45 +0000 Subject: [PATCH 1/2] Added resource overlay flag to enable/disable getSubscriptionUserHandle api. API is enabled by default. Bug: 250620312 Test: atest FrameworkTelephonyTestCases Merged-In: I1666b4e15d62b24462f0e1b88e963b5f074929bf Change-Id: I1666b4e15d62b24462f0e1b88e963b5f074929bf --- core/res/res/values/config_telephony.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/res/res/values/config_telephony.xml b/core/res/res/values/config_telephony.xml index 94cf1b2ada0e2..504492b8ffcf2 100644 --- a/core/res/res/values/config_telephony.xml +++ b/core/res/res/values/config_telephony.xml @@ -122,4 +122,10 @@ the performance, but sync mode reduces the chance of database/cache out-of-sync. --> true + + + true + From f7733cf174e799fb3b38c7ac546e4f6818be5eab Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Thu, 15 Dec 2022 16:43:30 -0800 Subject: [PATCH 2/2] Exposed getAllSubscriptionInfoList and getSubscriptionId 1. Added getAllSubscriptionInfoList for getting all the subscriptions from the subscription database. 2. Added getSubscriptionId for getting the active subscription id from the specified slot. 3. Deprecated getSubscriptionIds, which is imposible to return more than one subscription in today's implementation. Fix: 261041952 Test: Manual + CTS Merged-In: I9396f8e329ecec815d7a4aecba0d10c1a2a9c8c7 Change-Id: I9396f8e329ecec815d7a4aecba0d10c1a2a9c8c7 --- core/api/current.txt | 4 +- .../telephony/SubscriptionManager.java | 41 +++++++++++-------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index a8552f80e31ff..d23827c34bcae 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -43311,6 +43311,7 @@ package android.telephony { method public int getActiveSubscriptionInfoCountMax(); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public android.telephony.SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List getActiveSubscriptionInfoList(); + method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_STATE, "carrier privileges"}) public java.util.List getAllSubscriptionInfoList(); method @NonNull public java.util.List getCompleteActiveSubscriptionInfoList(); method public static int getDefaultDataSubscriptionId(); method public static int getDefaultSmsSubscriptionId(); @@ -43322,7 +43323,8 @@ package android.telephony { method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_NUMBERS, "android.permission.READ_PRIVILEGED_PHONE_STATE", "carrier privileges"}) public String getPhoneNumber(int, int); method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_NUMBERS, "android.permission.READ_PRIVILEGED_PHONE_STATE", "carrier privileges"}) public String getPhoneNumber(int); method public static int getSlotIndex(int); - method @Nullable public int[] getSubscriptionIds(int); + method public static int getSubscriptionId(int); + method @Deprecated @Nullable public int[] getSubscriptionIds(int); method @NonNull public java.util.List getSubscriptionPlans(int); method @NonNull @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List getSubscriptionsInGroup(@NonNull android.os.ParcelUuid); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean isActiveSubscriptionId(int); diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 0cfd96e46c4b6..37bfa72f9394c 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -1707,31 +1707,30 @@ public class SubscriptionManager { } /** - * Get all subscription info records from SIMs that are inserted now or were inserted before. + * Get all subscription info records from SIMs that are inserted now or previously inserted. * *

* If the caller does not have {@link Manifest.permission#READ_PHONE_NUMBERS} permission, * {@link SubscriptionInfo#getNumber()} will return empty string. * If the caller does not have {@link Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER}, - * {@link SubscriptionInfo#getIccId()} and {@link SubscriptionInfo#getCardString()} will return - * empty string, and {@link SubscriptionInfo#getGroupUuid()} will return {@code null}. + * {@link SubscriptionInfo#getIccId()} will return an empty string, and + * {@link SubscriptionInfo#getGroupUuid()} will return {@code null}. * *

- * The carrier app will always have full {@link SubscriptionInfo} for the subscriptions - * that it has carrier privilege. + * The carrier app will only get the list of subscriptions that it has carrier privilege on, + * but will have non-stripped {@link SubscriptionInfo} in the list. * * @return List of all {@link SubscriptionInfo} records from SIMs that are inserted or - * inserted before. Sorted by {@link SubscriptionInfo#getSimSlotIndex()}, then + * previously inserted. Sorted by {@link SubscriptionInfo#getSimSlotIndex()}, then * {@link SubscriptionInfo#getSubscriptionId()}. * - * @hide + * @throws SecurityException if callers do not hold the required permission. */ + @NonNull @RequiresPermission(anyOf = { Manifest.permission.READ_PHONE_STATE, - Manifest.permission.READ_PRIVILEGED_PHONE_STATE, "carrier privileges", }) - @NonNull public List getAllSubscriptionInfoList() { List result = null; try { @@ -2205,13 +2204,23 @@ public class SubscriptionManager { } /** - * Get an array of Subscription Ids for specified slot Index. - * @param slotIndex the slot index. - * @return subscription Ids or null if the given slot Index is not valid or there are no active - * subscriptions in the slot. + * Get an array of subscription ids for specified logical SIM slot Index. + * + * @param slotIndex The logical SIM slot index. + * + * @return subscription Ids or {@code null} if the given slot index is not valid or there are + * no active subscription in the slot. In the implementation today, there will be no more + * than one subscriptions per logical SIM slot. + * + * @deprecated Use {@link #getSubscriptionId(int)} instead. */ + @Deprecated @Nullable public int[] getSubscriptionIds(int slotIndex) { + int subId = getSubscriptionId(slotIndex); + if (!isValidSubscriptionId(subId)) { + return null; + } return new int[]{getSubscriptionId(slotIndex)}; } @@ -2238,12 +2247,10 @@ public class SubscriptionManager { } /** - * Get the subscription id for specified slot index. + * Get the subscription id for specified logical SIM slot index. * - * @param slotIndex Logical SIM slot index. + * @param slotIndex The logical SIM slot index. * @return The subscription id. {@link #INVALID_SUBSCRIPTION_ID} if SIM is absent. - * - * @hide */ public static int getSubscriptionId(int slotIndex) { if (!isValidSlotIndex(slotIndex)) {