diff options
| author | 2022-12-09 02:20:59 -0800 | |
|---|---|---|
| committer | 2023-03-10 14:17:38 -0800 | |
| commit | 00dc8a15e9cb98a36e369be389aea1979682c7cd (patch) | |
| tree | 69b7562ee54f9c54011f7bcfd1a86d11e483dcf6 | |
| parent | 51c68aaa73425050fc33873f30ee892fa0a8a973 (diff) | |
Added 15 APIs support
Added setDisplayNumber, setOpportunistic, createSubscriptionGroup
setPreferredDataSubscriptionId, getPreferredDataSubscriptionId
getOpportunisticSubscriptions, addSubscriptionsIntoGroup
canDisablePhysicalSubscription, setUiccApplicationsEnabled
setDeviceToDeviceStatusSharing, setDeviceToDeviceStatusSharingContacts
getPhoneNumberFromFirstAvailableSource, setUsageSetting
setSubscriptionUserHandle, getSubscriptionUserHandle
Test: atest SubscriptionManagerServiceTest
Bug: 239607619
Merged-In: I617e94d96ca29d277e0f217ebef5548b7aad1f80
Change-Id: I617e94d96ca29d277e0f217ebef5548b7aad1f80
| -rw-r--r-- | telephony/common/com/android/internal/telephony/TelephonyPermissions.java | 24 | ||||
| -rw-r--r-- | telephony/java/android/telephony/SubscriptionManager.java | 58 |
2 files changed, 65 insertions, 17 deletions
diff --git a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java index 1ba997f4c334..fdf694303dbc 100644 --- a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java +++ b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java @@ -743,11 +743,23 @@ public final class TelephonyPermissions { /** * Given a list of permissions, check to see if the caller has at least one of them granted. If - * not, check to see if the caller has carrier privileges. If the caller does not have any of + * not, check to see if the caller has carrier privileges. If the caller does not have any of * these permissions, throw a SecurityException. */ public static void enforceAnyPermissionGrantedOrCarrierPrivileges(Context context, int subId, int uid, String message, String... permissions) { + enforceAnyPermissionGrantedOrCarrierPrivileges( + context, subId, uid, false, message, permissions); + } + + /** + * Given a list of permissions, check to see if the caller has at least one of them granted. If + * not, check to see if the caller has carrier privileges on the specified subscription (or any + * subscription if {@code allowCarrierPrivilegeOnAnySub} is {@code true}. If the caller does not + * have any of these permissions, throw a {@link SecurityException}. + */ + public static void enforceAnyPermissionGrantedOrCarrierPrivileges(Context context, int subId, + int uid, boolean allowCarrierPrivilegeOnAnySub, String message, String... permissions) { if (permissions.length == 0) return; boolean isGranted = false; for (String perm : permissions) { @@ -758,7 +770,12 @@ public final class TelephonyPermissions { } if (isGranted) return; - if (checkCarrierPrivilegeForSubId(context, subId)) return; + + if (allowCarrierPrivilegeOnAnySub) { + if (checkCarrierPrivilegeForAnySubId(context, Binder.getCallingUid())) return; + } else { + if (checkCarrierPrivilegeForSubId(context, subId)) return; + } StringBuilder b = new StringBuilder(message); b.append(": Neither user "); @@ -769,7 +786,8 @@ public final class TelephonyPermissions { b.append(" or "); b.append(permissions[i]); } - b.append(" or carrier privileges"); + b.append(" or carrier privileges. subId=" + subId + ", allowCarrierPrivilegeOnAnySub=" + + allowCarrierPrivilegeOnAnySub); throw new SecurityException(b.toString()); } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index aedca33d734b..74ae1bca9242 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -731,6 +731,15 @@ public class SubscriptionManager { /** Indicates that data roaming is disabled for a subscription */ public static final int DATA_ROAMING_DISABLE = SimInfo.DATA_ROAMING_DISABLE; + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"DATA_ROAMING_"}, + value = { + DATA_ROAMING_ENABLE, + DATA_ROAMING_DISABLE + }) + public @interface DataRoamingMode {} + /** * TelephonyProvider column name for subscription carrier id. * @see TelephonyManager#getSimCarrierId() @@ -3671,10 +3680,15 @@ public class SubscriptionManager { } /** - * DO NOT USE. - * This API is designed for features that are not finished at this point. Do not call this API. + * Check if a subscription is active. + * + * @param subscriptionId The subscription id to check. + * + * @return {@code true} if the subscription is active. + * + * @throws IllegalArgumentException if the provided slot index is invalid. + * * @hide - * TODO b/135547512: further clean up */ @SystemApi @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @@ -3695,8 +3709,12 @@ public class SubscriptionManager { * Set the device to device status sharing user preference for a subscription ID. The setting * app uses this method to indicate with whom they wish to share device to device status * information. - * @param sharing the status sharing preference - * @param subscriptionId the unique Subscription ID in database + * + * @param subscriptionId the unique Subscription ID in database. + * @param sharing the status sharing preference. + * + * @throws IllegalArgumentException if the subscription does not exist, or the sharing + * preference is invalid. */ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setDeviceToDeviceStatusSharingPreference(int subscriptionId, @@ -3727,8 +3745,12 @@ public class SubscriptionManager { * Set the list of contacts that allow device to device status sharing for a subscription ID. * The setting app uses this method to indicate with whom they wish to share device to device * status information. - * @param contacts The list of contacts that allow device to device status sharing - * @param subscriptionId The unique Subscription ID in database + * + * @param subscriptionId The unique Subscription ID in database. + * @param contacts The list of contacts that allow device to device status sharing. + * + * @throws IllegalArgumentException if the subscription does not exist, or contacts is + * {@code null}. */ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setDeviceToDeviceStatusSharingContacts(int subscriptionId, @@ -3758,16 +3780,24 @@ public class SubscriptionManager { } /** - * DO NOT USE. - * This API is designed for features that are not finished at this point. Do not call this API. + * Get the active subscription id by logical SIM slot index. + * + * @param slotIndex The logical SIM slot index. + * @return The active subscription id. + * + * @throws IllegalArgumentException if the provided slot index is invalid. + * * @hide - * TODO b/135547512: further clean up */ @SystemApi @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEnabledSubscriptionId(int slotIndex) { int subId = INVALID_SUBSCRIPTION_ID; + if (!isValidSlotIndex(slotIndex)) { + throw new IllegalArgumentException("Invalid slot index " + slotIndex); + } + try { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { @@ -3809,12 +3839,12 @@ public class SubscriptionManager { /** * Get active data subscription id. Active data subscription refers to the subscription * currently chosen to provide cellular internet connection to the user. This may be - * different from getDefaultDataSubscriptionId(). Eg. Opportunistics data + * different from getDefaultDataSubscriptionId(). * - * See {@link PhoneStateListener#onActiveDataSubscriptionIdChanged(int)} for the details. + * @return Active data subscription id if any is chosen, or {@link #INVALID_SUBSCRIPTION_ID} if + * not. * - * @return Active data subscription id if any is chosen, or - * SubscriptionManager.INVALID_SUBSCRIPTION_ID if not. + * @see TelephonyCallback.ActiveDataSubscriptionIdListener */ public static int getActiveDataSubscriptionId() { if (isSubscriptionManagerServiceEnabled()) { |