Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00dc8a15 authored by Jack Yu's avatar Jack Yu
Browse files

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
parent 51c68aaa
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -748,6 +748,18 @@ public final class TelephonyPermissions {
     */
    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 (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());
    }

+44 −14
Original line number Diff line number Diff line
@@ -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()) {