diff options
| author | 2018-12-21 00:04:57 +0000 | |
|---|---|---|
| committer | 2018-12-21 00:04:57 +0000 | |
| commit | 90f496b14c31f519df8ef4c33f76d0c20f3564b8 (patch) | |
| tree | 655ab95e8f2d1d7f80b8d35bea3d94e71f729946 | |
| parent | 7eae0132c14861a88233ad3b00e9b2ebb6b22051 (diff) | |
| parent | 18350e409e723a1c466f59649e1ac6620793b6f8 (diff) | |
Merge changes from topic "118349116"
* changes:
Fix broken building offline-sdk-docs.
Add APIs to remove sub from a group and get subs in the same gorup.
| -rwxr-xr-x | api/current.txt | 2 | ||||
| -rw-r--r-- | telephony/java/android/telephony/SubscriptionManager.java | 86 | ||||
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 2 | ||||
| -rwxr-xr-x | telephony/java/com/android/internal/telephony/ISub.aidl | 4 |
4 files changed, 90 insertions, 4 deletions
diff --git a/api/current.txt b/api/current.txt index b3ab4ede8833..4fa6dcf53d23 100755 --- a/api/current.txt +++ b/api/current.txt @@ -42902,12 +42902,14 @@ package android.telephony { method public static int getSlotIndex(int); method public int[] getSubscriptionIds(int); method public java.util.List<android.telephony.SubscriptionPlan> getSubscriptionPlans(int); + method public java.util.List<android.telephony.SubscriptionInfo> getSubscriptionsInGroup(int); method public boolean isActiveSubscriptionId(int); method public boolean isNetworkRoaming(int); method public static boolean isUsableSubscriptionId(int); method public static boolean isValidSubscriptionId(int); method public void removeOnOpportunisticSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener); method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener); + method public boolean removeSubscriptionsFromGroup(int[]); method public java.lang.String setSubscriptionGroup(int[]); method public void setSubscriptionOverrideCongested(int, boolean, long); method public void setSubscriptionOverrideUnmetered(int, boolean, long); diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index f782faea8482..47f265675765 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -19,6 +19,7 @@ package android.telephony; import static android.net.NetworkPolicyManager.OVERRIDE_CONGESTED; import static android.net.NetworkPolicyManager.OVERRIDE_UNMETERED; +import android.Manifest; import android.annotation.CallbackExecutor; import android.annotation.DurationMillisLong; import android.annotation.NonNull; @@ -2391,16 +2392,21 @@ public class SubscriptionManager { * together, some of them may be invisible to the users, etc. * * Caller will either have {@link android.Manifest.permission#MODIFY_PHONE_STATE} - * permission or can manage all subscriptions in the list, according to their - * acess rules. + * permission or had carrier privilege permission on the subscriptions: + * {@link TelephonyManager#hasCarrierPrivileges()} or + * {@link #canManageSubscription(SubscriptionInfo)} + * + * @throws SecurityException if the caller doesn't meet the requirements + * outlined above. * * @param subIdList list of subId that will be in the same group * @return groupUUID a UUID assigned to the subscription group. It returns * null if fails. * */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public String setSubscriptionGroup(int[] subIdList) { + public @Nullable String setSubscriptionGroup(@NonNull int[] subIdList) { String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; if (VDBG) { logd("[setSubscriptionGroup]+ subIdList:" + Arrays.toString(subIdList)); @@ -2420,6 +2426,80 @@ public class SubscriptionManager { } /** + * Remove a list of subscriptions from their subscription group. + * See {@link #setSubscriptionGroup(int[])} for more details. + * + * Caller will either have {@link android.Manifest.permission#MODIFY_PHONE_STATE} + * permission or had carrier privilege permission on the subscriptions: + * {@link TelephonyManager#hasCarrierPrivileges()} or + * {@link #canManageSubscription(SubscriptionInfo)} + * + * @throws SecurityException if the caller doesn't meet the requirements + * outlined above. + * + * @param subIdList list of subId that need removing from their groups. + * @return whether the operation succeeds. + * + */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges + @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) + public boolean removeSubscriptionsFromGroup(@NonNull int[] subIdList) { + String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; + if (VDBG) { + logd("[removeSubscriptionsFromGroup]+ subIdList:" + Arrays.toString(subIdList)); + } + + try { + ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); + if (iSub != null) { + return iSub.removeSubscriptionsFromGroup(subIdList, pkgForDebug); + } + } catch (RemoteException ex) { + // ignore it + } + + return false; + } + + /** + * Get subscriptionInfo list of subscriptions that are in the same group of given subId. + * See {@link #setSubscriptionGroup(int[])} for more details. + * + * Caller will either have {@link android.Manifest.permission#READ_PHONE_STATE} + * permission or had carrier privilege permission on the subscription. + * {@link TelephonyManager#hasCarrierPrivileges()} + * + * @throws SecurityException if the caller doesn't meet the requirements + * outlined above. + * + * @param subId of which list of subInfo from the same group will be returned. + * @return list of subscriptionInfo that belong to the same group, including the given + * subscription itself. It will return null if the subscription doesn't exist or it + * doesn't belong to any group. + * + */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges + @RequiresPermission(Manifest.permission.READ_PHONE_STATE) + public @Nullable List<SubscriptionInfo> getSubscriptionsInGroup(int subId) { + String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; + if (VDBG) { + logd("[getSubscriptionsInGroup]+ subId:" + subId); + } + + List<SubscriptionInfo> result = null; + try { + ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); + if (iSub != null) { + result = iSub.getSubscriptionsInGroup(subId, pkgForDebug); + } + } catch (RemoteException ex) { + // ignore it + } + + return result; + } + + /** * Set metered by simInfo index * * @param isMetered whether it’s a metered subscription. diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index bb48d535392a..e043a37f16a9 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -6645,7 +6645,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.getCarrierPrivilegeStatus(mSubId) == + return telephony.getCarrierPrivilegeStatus(subId) == CARRIER_PRIVILEGE_STATUS_HAS_ACCESS; } } catch (RemoteException ex) { diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl index f9db4b0afd12..65d1a920a324 100755 --- a/telephony/java/com/android/internal/telephony/ISub.aidl +++ b/telephony/java/com/android/internal/telephony/ISub.aidl @@ -210,6 +210,10 @@ interface ISub { */ List<SubscriptionInfo> getOpportunisticSubscriptions(String callingPackage); + boolean removeSubscriptionsFromGroup(in int[] subIdList, String callingPackage); + + List<SubscriptionInfo> getSubscriptionsInGroup(int subId, String callingPackage); + int getSlotIndex(int subId); int[] getSubId(int slotIndex); |