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

Commit 3e3e0a4e authored by Ling Ma's avatar Ling Ma
Browse files

Auto selected sub should never be actual default sub

Not using featureflag because this change revert to the behavior prior to ag/19933665, which accidentally made auto selected sub to be the actual sub id, instead of max_int. This is an issue if the device is uncapable of validation before switching.

Fix: 303941269
Test: voice call + data browsing
Change-Id: Ib331554e5fa31136f375e6532269610a717f7ce8
parent f236b741
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) {