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

Commit 8fd47197 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:...

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

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2796775



Change-Id: I81cc9b715b561ada0140c7d8bda739d8c31fb44d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents bcd77140 1c5e280d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1546,7 +1546,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
@@ -678,6 +678,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 {
@@ -1357,7 +1388,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();
@@ -1992,7 +2023,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();
        for (Phone phone : mPhones) {