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

Commit f98e38f5 authored by Ling Ma's avatar Ling Ma Committed by Automerger Merge Worker
Browse files

Merge "Auto selected sub should never be actual default sub" into main am: 2752add9

parents 3b055c3b 2752add9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1776,7 +1776,7 @@ public class PhoneSwitcher extends Handler {
        // If validation feature is not supported, set it directly. Otherwise,
        // start validation on the subscription first.
        if (!mValidator.isValidationFeatureSupported()) {
            setAutoSelectedDataSubIdInternal(subIdToValidate);
            setAutoSelectedDataSubIdInternal(subId);
            sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_SUCCESS);
            return;
        }
+33 −2
Original line number Diff line number Diff line
@@ -864,6 +864,37 @@ public class PhoneSwitcherTest extends TelephonyTest {
        assertEquals(1, mPhoneSwitcherUT.getActiveDataSubId());
    }

    @Test
    public void testSetAutoSelectedValidationFeatureNotSupported() throws Exception {
        doReturn(false).when(mCellularNetworkValidator).isValidationFeatureSupported();
        initialize();

        // Phone 0 has sub 1, phone 1 has sub 2.
        // Sub 1 is default data sub.
        // Both are active subscriptions are active sub, as they are in both active slots.
        setSlotIndexToSubId(0, 1);
        setSlotIndexToSubId(1, 2);
        setDefaultDataSubId(1);

        doReturn(new SubscriptionInfoInternal.Builder(mSubscriptionManagerService
                .getSubscriptionInfoInternal(2)).setOpportunistic(1).build())
                .when(mSubscriptionManagerService).getSubscriptionInfoInternal(2);

        mPhoneSwitcherUT.trySetOpportunisticDataSubscription(2, false, mSetOpptDataCallback1);
        processAllMessages();
        mPhoneSwitcherUT.mValidationCallback.onNetworkAvailable(null, 2);
        processAllMessages();
        assertEquals(2, mPhoneSwitcherUT.getAutoSelectedDataSubId());

        // Switch to the default sub, verify AutoSelectedDataSubId is the default value.
        clearInvocations(mSetOpptDataCallback1);
        mPhoneSwitcherUT.trySetOpportunisticDataSubscription(SubscriptionManager
                .DEFAULT_SUBSCRIPTION_ID, true, mSetOpptDataCallback1);
        processAllMessages();
        assertEquals(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
                mPhoneSwitcherUT.getAutoSelectedDataSubId());
    }

    @Test
    @SmallTest
    public void testSetPreferredDataModemCommand() throws Exception {
@@ -1540,7 +1571,7 @@ public class PhoneSwitcherTest extends TelephonyTest {
                .when(mSubscriptionManagerService).getSubscriptionInfoInternal(2);

        // Switch to primary before a primary is selected/inactive.
        setDefaultDataSubId(-1);
        setDefaultDataSubId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        mPhoneSwitcherUT.trySetOpportunisticDataSubscription(
                SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, false, mSetOpptDataCallback1);
        processAllMessages();
@@ -2158,7 +2189,7 @@ public class PhoneSwitcherTest extends TelephonyTest {
        doReturn(true).when(mDataConfigManager).isPingTestBeforeAutoDataSwitchRequired();
    }

    private void setDefaultDataSubId(int defaultDataSub) throws Exception {
    private void setDefaultDataSubId(int defaultDataSub) {
        mDefaultDataSub = defaultDataSub;
        doReturn(mDefaultDataSub).when(mSubscriptionManagerService).getDefaultDataSubId();
        if (defaultDataSub == 1) {