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
This commit is contained in:
@@ -748,6 +748,18 @@ public final class TelephonyPermissions {
|
|||||||
*/
|
*/
|
||||||
public static void enforceAnyPermissionGrantedOrCarrierPrivileges(Context context, int subId,
|
public static void enforceAnyPermissionGrantedOrCarrierPrivileges(Context context, int subId,
|
||||||
int uid, String message, String... permissions) {
|
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;
|
if (permissions.length == 0) return;
|
||||||
boolean isGranted = false;
|
boolean isGranted = false;
|
||||||
for (String perm : permissions) {
|
for (String perm : permissions) {
|
||||||
@@ -758,7 +770,12 @@ public final class TelephonyPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isGranted) return;
|
if (isGranted) return;
|
||||||
|
|
||||||
|
if (allowCarrierPrivilegeOnAnySub) {
|
||||||
|
if (checkCarrierPrivilegeForAnySubId(context, Binder.getCallingUid())) return;
|
||||||
|
} else {
|
||||||
if (checkCarrierPrivilegeForSubId(context, subId)) return;
|
if (checkCarrierPrivilegeForSubId(context, subId)) return;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder b = new StringBuilder(message);
|
StringBuilder b = new StringBuilder(message);
|
||||||
b.append(": Neither user ");
|
b.append(": Neither user ");
|
||||||
@@ -769,7 +786,8 @@ public final class TelephonyPermissions {
|
|||||||
b.append(" or ");
|
b.append(" or ");
|
||||||
b.append(permissions[i]);
|
b.append(permissions[i]);
|
||||||
}
|
}
|
||||||
b.append(" or carrier privileges");
|
b.append(" or carrier privileges. subId=" + subId + ", allowCarrierPrivilegeOnAnySub="
|
||||||
|
+ allowCarrierPrivilegeOnAnySub);
|
||||||
throw new SecurityException(b.toString());
|
throw new SecurityException(b.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -731,6 +731,15 @@ public class SubscriptionManager {
|
|||||||
/** Indicates that data roaming is disabled for a subscription */
|
/** Indicates that data roaming is disabled for a subscription */
|
||||||
public static final int DATA_ROAMING_DISABLE = SimInfo.DATA_ROAMING_DISABLE;
|
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.
|
* TelephonyProvider column name for subscription carrier id.
|
||||||
* @see TelephonyManager#getSimCarrierId()
|
* @see TelephonyManager#getSimCarrierId()
|
||||||
@@ -3671,10 +3680,15 @@ public class SubscriptionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DO NOT USE.
|
* Check if a subscription is active.
|
||||||
* This API is designed for features that are not finished at this point. Do not call this API.
|
*
|
||||||
|
* @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
|
* @hide
|
||||||
* TODO b/135547512: further clean up
|
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
@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
|
* 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
|
* app uses this method to indicate with whom they wish to share device to device status
|
||||||
* information.
|
* 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)
|
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
public void setDeviceToDeviceStatusSharingPreference(int subscriptionId,
|
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.
|
* 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
|
* The setting app uses this method to indicate with whom they wish to share device to device
|
||||||
* status information.
|
* 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)
|
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
public void setDeviceToDeviceStatusSharingContacts(int subscriptionId,
|
public void setDeviceToDeviceStatusSharingContacts(int subscriptionId,
|
||||||
@@ -3758,16 +3780,24 @@ public class SubscriptionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DO NOT USE.
|
* Get the active subscription id by logical SIM slot index.
|
||||||
* This API is designed for features that are not finished at this point. Do not call this API.
|
*
|
||||||
|
* @param slotIndex The logical SIM slot index.
|
||||||
|
* @return The active subscription id.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if the provided slot index is invalid.
|
||||||
|
*
|
||||||
* @hide
|
* @hide
|
||||||
* TODO b/135547512: further clean up
|
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||||
public int getEnabledSubscriptionId(int slotIndex) {
|
public int getEnabledSubscriptionId(int slotIndex) {
|
||||||
int subId = INVALID_SUBSCRIPTION_ID;
|
int subId = INVALID_SUBSCRIPTION_ID;
|
||||||
|
|
||||||
|
if (!isValidSlotIndex(slotIndex)) {
|
||||||
|
throw new IllegalArgumentException("Invalid slot index " + slotIndex);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ISub iSub = TelephonyManager.getSubscriptionService();
|
ISub iSub = TelephonyManager.getSubscriptionService();
|
||||||
if (iSub != null) {
|
if (iSub != null) {
|
||||||
@@ -3809,12 +3839,12 @@ public class SubscriptionManager {
|
|||||||
/**
|
/**
|
||||||
* Get active data subscription id. Active data subscription refers to the subscription
|
* 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
|
* 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
|
* @see TelephonyCallback.ActiveDataSubscriptionIdListener
|
||||||
* SubscriptionManager.INVALID_SUBSCRIPTION_ID if not.
|
|
||||||
*/
|
*/
|
||||||
public static int getActiveDataSubscriptionId() {
|
public static int getActiveDataSubscriptionId() {
|
||||||
if (isSubscriptionManagerServiceEnabled()) {
|
if (isSubscriptionManagerServiceEnabled()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user