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

Commit f01f6a6c authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Gerrit Code Review
Browse files

Merge changes from topics "128455935", "123661746"

* changes:
  Better description and parameter name of setPreferredDataSubscriptionId
  Remove SubscriptionManager#setMetered API.
parents d337ba5e d36fcc37
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -22,7 +22,7 @@ import static android.telephony.PhoneStateListener.LISTEN_PRECISE_CALL_STATE;
import static android.telephony.SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
import static android.telephony.SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
import static android.telephony.SubscriptionManager.INVALID_PHONE_INDEX;
import static android.telephony.SubscriptionManager.INVALID_PHONE_INDEX;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_INVALID_PARAMETER;
import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION;
import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_SUCCESS;
import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_SUCCESS;
import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED;
import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED;


@@ -814,7 +814,7 @@ public class PhoneSwitcher extends Handler {
            ISetOpportunisticDataCallback callback) {
            ISetOpportunisticDataCallback callback) {
        if (!mSubscriptionController.isActiveSubId(subId)) {
        if (!mSubscriptionController.isActiveSubId(subId)) {
            log("Can't switch data to inactive subId " + subId);
            log("Can't switch data to inactive subId " + subId);
            sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_INVALID_PARAMETER);
            sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION);
            return;
            return;
        }
        }


+2 −42
Original line number Original line Diff line number Diff line
@@ -366,8 +366,6 @@ public class SubscriptionController extends ISub.Stub {
                SubscriptionManager.IS_OPPORTUNISTIC)) == 1;
                SubscriptionManager.IS_OPPORTUNISTIC)) == 1;
        String groupUUID = cursor.getString(cursor.getColumnIndexOrThrow(
        String groupUUID = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.GROUP_UUID));
                SubscriptionManager.GROUP_UUID));
        boolean isMetered = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.IS_METERED)) == 1;
        int profileClass = cursor.getInt(cursor.getColumnIndexOrThrow(
        int profileClass = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.PROFILE_CLASS));
                SubscriptionManager.PROFILE_CLASS));
        int subType = cursor.getInt(cursor.getColumnIndexOrThrow(
        int subType = cursor.getInt(cursor.getColumnIndexOrThrow(
@@ -384,8 +382,7 @@ public class SubscriptionController extends ISub.Stub {
                    + isEmbedded + " accessRules:" + Arrays.toString(accessRules)
                    + isEmbedded + " accessRules:" + Arrays.toString(accessRules)
                    + " cardId:" + cardIdToPrint + " publicCardId:" + publicCardId
                    + " cardId:" + cardIdToPrint + " publicCardId:" + publicCardId
                    + " isOpportunistic:" + isOpportunistic + " groupUUID:" + groupUUID
                    + " isOpportunistic:" + isOpportunistic + " groupUUID:" + groupUUID
                    + " isMetered:" + isMetered + " profileClass:" + profileClass
                    + " profileClass:" + profileClass + " subscriptionType: " + subType);
                    + " subscriptionType: " + subType);
        }
        }


        // If line1number has been set to a different number, use it instead.
        // If line1number has been set to a different number, use it instead.
@@ -396,7 +393,7 @@ public class SubscriptionController extends ISub.Stub {
        return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName,
        return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName,
            nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso,
            nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso,
            isEmbedded, accessRules, cardId, publicCardId, isOpportunistic, groupUUID,
            isEmbedded, accessRules, cardId, publicCardId, isOpportunistic, groupUUID,
            isMetered, false /* isGroupDisabled */, carrierId, profileClass, subType);
            false /* isGroupDisabled */, carrierId, profileClass, subType);
    }
    }


    /**
    /**
@@ -2417,7 +2414,6 @@ public class SubscriptionController extends ISub.Stub {
            case SubscriptionManager.CB_OPT_OUT_DIALOG:
            case SubscriptionManager.CB_OPT_OUT_DIALOG:
            case SubscriptionManager.ENHANCED_4G_MODE_ENABLED:
            case SubscriptionManager.ENHANCED_4G_MODE_ENABLED:
            case SubscriptionManager.IS_OPPORTUNISTIC:
            case SubscriptionManager.IS_OPPORTUNISTIC:
            case SubscriptionManager.IS_METERED:
            case SubscriptionManager.VT_IMS_ENABLED:
            case SubscriptionManager.VT_IMS_ENABLED:
            case SubscriptionManager.WFC_IMS_ENABLED:
            case SubscriptionManager.WFC_IMS_ENABLED:
            case SubscriptionManager.WFC_IMS_MODE:
            case SubscriptionManager.WFC_IMS_MODE:
@@ -2478,7 +2474,6 @@ public class SubscriptionController extends ISub.Stub {
                        case SubscriptionManager.WFC_IMS_ROAMING_ENABLED:
                        case SubscriptionManager.WFC_IMS_ROAMING_ENABLED:
                        case SubscriptionManager.IS_OPPORTUNISTIC:
                        case SubscriptionManager.IS_OPPORTUNISTIC:
                        case SubscriptionManager.GROUP_UUID:
                        case SubscriptionManager.GROUP_UUID:
                        case SubscriptionManager.IS_METERED:
                            resultValue = cursor.getInt(0) + "";
                            resultValue = cursor.getInt(0) + "";
                            break;
                            break;
                        default:
                        default:
@@ -2652,41 +2647,6 @@ public class SubscriptionController extends ISub.Stub {
        }
        }
    }
    }


    /**
     * Set whether a subscription is metered
     *
     * Throws SecurityException if doesn't have required permission.
     *
     * @param isMetered whether it’s a metered subscription.
     * @param subId the unique SubscriptionInfo index in database
     * @param callingPackage The package making the IPC.
     * @return the number of records updated
     */
    @Override
    public int setMetered(boolean isMetered, int subId, String callingPackage) {
        try {
            TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
                    mContext, subId, callingPackage);
        } catch (SecurityException e) {
            // The subscription may be inactive eSIM profile. If so, check the access rule in
            // database.
            enforceCarrierPrivilegeOnInactiveSub(subId, callingPackage,
                    "Caller requires permission on sub " + subId);
        }

        long token = Binder.clearCallingIdentity();
        try {
            int ret = setSubscriptionProperty(subId, SubscriptionManager.IS_METERED,
                    String.valueOf(isMetered ? 1 : 0));

            if (ret != 0) notifySubscriptionInfoChanged();

            return ret;
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    /**
    /**
     * Get subscription info from database, and check whether caller has carrier privilege
     * Get subscription info from database, and check whether caller has carrier privilege
     * permission with it. If checking fails, throws SecurityException.
     * permission with it. If checking fails, throws SecurityException.
+3 −3
Original line number Original line Diff line number Diff line
@@ -66,19 +66,19 @@ public class MultiSimSettingControllerTest extends TelephonyTest {


    private SubscriptionInfo mSubInfo2 = new SubscriptionInfo(2, "subInfo2 IccId", 1, "T-mobile",
    private SubscriptionInfo mSubInfo2 = new SubscriptionInfo(2, "subInfo2 IccId", 1, "T-mobile",
            "T-mobile", 0, 255, "12345", 0, null, "310", "260",
            "T-mobile", 0, 255, "12345", 0, null, "310", "260",
            "156", false, null, null, -1, false, "group1", true, false,
            "156", false, null, null, -1, false, "group1", false,
            TelephonyManager.UNKNOWN_CARRIER_ID, SubscriptionManager.PROFILE_CLASS_DEFAULT,
            TelephonyManager.UNKNOWN_CARRIER_ID, SubscriptionManager.PROFILE_CLASS_DEFAULT,
            SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
            SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);


    private SubscriptionInfo mSubInfo3 = new SubscriptionInfo(3, "subInfo3 IccId", -1, "T-mobile",
    private SubscriptionInfo mSubInfo3 = new SubscriptionInfo(3, "subInfo3 IccId", -1, "T-mobile",
            "T-mobile", 0, 255, "12345", 0, null, "310", "260",
            "T-mobile", 0, 255, "12345", 0, null, "310", "260",
            "156", false, null, null, -1, false, "group1", true, false,
            "156", false, null, null, -1, false, "group1", false,
            TelephonyManager.UNKNOWN_CARRIER_ID, SubscriptionManager.PROFILE_CLASS_DEFAULT,
            TelephonyManager.UNKNOWN_CARRIER_ID, SubscriptionManager.PROFILE_CLASS_DEFAULT,
            SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
            SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);


    private SubscriptionInfo mSubInfo4 = new SubscriptionInfo(4, "subInfo4 IccId", -1, "T-mobile",
    private SubscriptionInfo mSubInfo4 = new SubscriptionInfo(4, "subInfo4 IccId", -1, "T-mobile",
            "T-mobile", 0, 255, "12345", 0, null, "310", "260",
            "T-mobile", 0, 255, "12345", 0, null, "310", "260",
            "156", false, null, null, -1, false, "group1", true, false,
            "156", false, null, null, -1, false, "group1", false,
            TelephonyManager.UNKNOWN_CARRIER_ID, SubscriptionManager.PROFILE_CLASS_DEFAULT,
            TelephonyManager.UNKNOWN_CARRIER_ID, SubscriptionManager.PROFILE_CLASS_DEFAULT,
            SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
            SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);


+0 −5
Original line number Original line Diff line number Diff line
@@ -147,7 +147,6 @@ public class SubscriptionControllerTest extends TelephonyTest {
        String disName = "TESTING";
        String disName = "TESTING";
        String disNum = "12345";
        String disNum = "12345";
        boolean isOpportunistic = true;
        boolean isOpportunistic = true;
        boolean isMetered = false;


        testInsertSim();
        testInsertSim();
        /* Get SUB ID */
        /* Get SUB ID */
@@ -158,8 +157,6 @@ public class SubscriptionControllerTest extends TelephonyTest {
        /* Getting, there is no direct getter function for each fields of property */
        /* Getting, there is no direct getter function for each fields of property */
        SubscriptionInfo subInfo = mSubscriptionControllerUT
        SubscriptionInfo subInfo = mSubscriptionControllerUT
                .getActiveSubscriptionInfo(subID, mCallingPackage);
                .getActiveSubscriptionInfo(subID, mCallingPackage);
        //isMetered should initialize as true
        assertTrue(subInfo.isMetered());


        /* Setting */
        /* Setting */
        mSubscriptionControllerUT.setDisplayName(disName, subID);
        mSubscriptionControllerUT.setDisplayName(disName, subID);
@@ -167,7 +164,6 @@ public class SubscriptionControllerTest extends TelephonyTest {
        mSubscriptionControllerUT.setDisplayNumber(disNum, subID);
        mSubscriptionControllerUT.setDisplayNumber(disNum, subID);
        mSubscriptionControllerUT.setIconTint(iconTint, subID);
        mSubscriptionControllerUT.setIconTint(iconTint, subID);
        mSubscriptionControllerUT.setOpportunistic(isOpportunistic, subID, mCallingPackage);
        mSubscriptionControllerUT.setOpportunistic(isOpportunistic, subID, mCallingPackage);
        mSubscriptionControllerUT.setMetered(isMetered, subID, mCallingPackage);


        subInfo = mSubscriptionControllerUT
        subInfo = mSubscriptionControllerUT
            .getActiveSubscriptionInfo(subID, mCallingPackage);
            .getActiveSubscriptionInfo(subID, mCallingPackage);
@@ -178,7 +174,6 @@ public class SubscriptionControllerTest extends TelephonyTest {
        assertEquals(iconTint, subInfo.getIconTint());
        assertEquals(iconTint, subInfo.getIconTint());
        assertEquals(disNum, subInfo.getNumber());
        assertEquals(disNum, subInfo.getNumber());
        assertEquals(isOpportunistic, subInfo.isOpportunistic());
        assertEquals(isOpportunistic, subInfo.isOpportunistic());
        assertEquals(isMetered, subInfo.isMetered());


        /* verify broadcast intent */
        /* verify broadcast intent */
        ArgumentCaptor<Intent> captorIntent = ArgumentCaptor.forClass(Intent.class);
        ArgumentCaptor<Intent> captorIntent = ArgumentCaptor.forClass(Intent.class);
+3 −3
Original line number Original line Diff line number Diff line
@@ -980,7 +980,7 @@ public class EuiccControllerTest extends TelephonyTest {
        SubscriptionInfo subInfo = new SubscriptionInfo(
        SubscriptionInfo subInfo = new SubscriptionInfo(
                0, "", 0, "", "", 0, 0, "", 0, null, "", "", "", true /* isEmbedded */,
                0, "", 0, "", "", 0, 0, "", 0, null, "", "", "", true /* isEmbedded */,
                hasPrivileges ? new UiccAccessRule[] { ACCESS_RULE } : null, "", CARD_ID,
                hasPrivileges ? new UiccAccessRule[] { ACCESS_RULE } : null, "", CARD_ID,
                false, "", false, false, 0, 0, 0);
                false, "", false, 0, 0, 0);
        when(mSubscriptionManager.canManageSubscription(subInfo, PACKAGE_NAME)).thenReturn(
        when(mSubscriptionManager.canManageSubscription(subInfo, PACKAGE_NAME)).thenReturn(
                hasPrivileges);
                hasPrivileges);
        when(mSubscriptionManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(
        when(mSubscriptionManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(
@@ -1001,11 +1001,11 @@ public class EuiccControllerTest extends TelephonyTest {
        SubscriptionInfo subInfo1 = new SubscriptionInfo(
        SubscriptionInfo subInfo1 = new SubscriptionInfo(
                0, "", 0, "", "", 0, 0, "", 0, null, "", "", "", true /* isEmbedded */,
                0, "", 0, "", "", 0, 0, "", 0, null, "", "", "", true /* isEmbedded */,
                hasPrivileges ? new UiccAccessRule[] { ACCESS_RULE } : null, "", CARD_ID,
                hasPrivileges ? new UiccAccessRule[] { ACCESS_RULE } : null, "", CARD_ID,
                false, "", false, false, 0, 0, 0);
                false, "", false, 0, 0, 0);
        SubscriptionInfo subInfo2 = new SubscriptionInfo(
        SubscriptionInfo subInfo2 = new SubscriptionInfo(
                0, "", 0, "", "", 0, 0, "", 0, null, "", "", "", true /* isEmbedded */,
                0, "", 0, "", "", 0, 0, "", 0, null, "", "", "", true /* isEmbedded */,
                hasPrivileges ? new UiccAccessRule[] { ACCESS_RULE } : null, "",
                hasPrivileges ? new UiccAccessRule[] { ACCESS_RULE } : null, "",
                1 /* cardId */, false, "", false, false, 0, 0, 0);
                1 /* cardId */, false, "", false, 0, 0, 0);
        when(mSubscriptionManager.canManageSubscription(subInfo1, PACKAGE_NAME)).thenReturn(
        when(mSubscriptionManager.canManageSubscription(subInfo1, PACKAGE_NAME)).thenReturn(
                hasPrivileges);
                hasPrivileges);
        when(mSubscriptionManager.canManageSubscription(subInfo2, PACKAGE_NAME)).thenReturn(
        when(mSubscriptionManager.canManageSubscription(subInfo2, PACKAGE_NAME)).thenReturn(