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

Commit 1ed93ad6 authored by Ling Ma's avatar Ling Ma Committed by Cherrypicker Worker
Browse files

Clear auto select sub correctly

When requested validation, if the requested sub is already the preferred sub, also make sure to clear auto select sub Id before short-circuit to successful callback.

Fix: 327468739
Test: basic voice + data browsing
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:744eb0e52ed2545a2f592e26cd8a8977db9b3536)
Merged-In: I89e885779b53d57679fc220867b08e65eae26bea
Change-Id: I89e885779b53d57679fc220867b08e65eae26bea
parent 45566e4b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1554,6 +1554,9 @@ public class PhoneSwitcher extends Handler {
        mPendingSwitchSubId = INVALID_SUBSCRIPTION_ID;

        if (subIdToValidate == mPreferredDataSubId.get()) {
            if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
                mAutoSelectedDataSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
            }
            sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_SUCCESS);
            return;
        }
+47 −0
Original line number Diff line number Diff line
@@ -1517,6 +1517,53 @@ public class PhoneSwitcherTest extends TelephonyTest {
        verify(mSetOpptDataCallback2).onComplete(SET_OPPORTUNISTIC_SUB_SUCCESS);
    }

    @Test
    public void testSetPreferredDataCallback_voiceCall() throws Exception {
        doReturn(true).when(mMockRadioConfig).isSetPreferredDataCommandSupported();
        initialize();
        setAllPhonesInactive();

        // 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);
        assertEquals(1, mPhoneSwitcherUT.getActiveDataSubId());

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

        // First temporarily switched to the opportunistic sub 2
        mPhoneSwitcherUT.trySetOpportunisticDataSubscription(2, false, mSetOpptDataCallback1);
        processAllMessages();
        mPhoneSwitcherUT.mValidationCallback.onNetworkAvailable(null, 2);
        processAllMessages();
        verify(mSetOpptDataCallback1).onComplete(SET_OPPORTUNISTIC_SUB_SUCCESS);

        // Voice call led back to default sub 1
        doReturn(mImsPhone).when(mPhone).getImsPhone();
        doReturn(true).when(mPhone).isUserDataEnabled();
        doReturn(true).when(mDataSettingsManager).isDataEnabled();
        mockImsRegTech(0, REGISTRATION_TECH_LTE);
        notifyPhoneAsInCall(mPhone);

        assertEquals(1, mPhoneSwitcherUT.getActiveDataSubId());
        assertEquals(2, mPhoneSwitcherUT.getAutoSelectedDataSubId());

        // CBRS set preferred data back to default during the phone call
        clearInvocations(mSetOpptDataCallback1);
        mPhoneSwitcherUT.trySetOpportunisticDataSubscription(SubscriptionManager
                .DEFAULT_SUBSCRIPTION_ID, false, mSetOpptDataCallback1);
        processAllMessages();

        verify(mSetOpptDataCallback1).onComplete(SET_OPPORTUNISTIC_SUB_SUCCESS);
        assertEquals(1, mPhoneSwitcherUT.getActiveDataSubId());
        assertEquals(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
                mPhoneSwitcherUT.getAutoSelectedDataSubId());
    }

    @Test
    @SmallTest
    public void testMultiSimConfigChange() throws Exception {