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

Commit 73461e8f authored by Amit Mahajan's avatar Amit Mahajan Committed by Android (Google) Code Review
Browse files

Merge "Show dialog to select default data sub on first boot."

parents 492b4373 22db3394
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -634,8 +634,9 @@ public class MultiSimSettingController extends Handler {
        if (mPrimarySubList.size() == 1 && change == PRIMARY_SUB_REMOVED
                && (!dataSelected || !smsSelected || !voiceSelected)) {
            dialogType = EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL;
        } else if (mPrimarySubList.size() > 1 && isUserVisibleChange(change)) {
            // If change is SWAPPED_IN_GROUP or MARKED_OPPT orINITIALIZED, don't ask user again.
        } else if (mPrimarySubList.size() > 1 && (isUserVisibleChange(change)
                || (change == PRIMARY_SUB_INITIALIZED && !dataSelected))) {
            // If change is SWAPPED_IN_GROUP or MARKED_OPPT, don't ask user again.
            dialogType = EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA;
        }

+36 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import android.content.Intent;
@@ -355,6 +356,41 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        assertEquals(2, intent.getIntExtra(EXTRA_SUBSCRIPTION_ID, -1));
    }

    @Test
    @SmallTest
    public void testSimpleDsdsFirstBoot() {
        // at first boot default is not set
        doReturn(-1).when(mSubControllerMock).getDefaultDataSubId();

        doReturn(true).when(mPhoneMock1).isUserDataEnabled();
        doReturn(true).when(mPhoneMock2).isUserDataEnabled();
        // After initialization, sub 2 should have mobile data off.
        mMultiSimSettingControllerUT.notifyAllSubscriptionLoaded();
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(0, 1);
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(1, 2);
        processAllMessages();
        verify(mDataEnabledSettingsMock1).setDataEnabled(
                TelephonyManager.DATA_ENABLED_REASON_USER, false);
        verify(mDataEnabledSettingsMock2).setDataEnabled(
                TelephonyManager.DATA_ENABLED_REASON_USER, false);

        // as a result of the above calls, update new values to be returned
        doReturn(false).when(mPhoneMock1).isUserDataEnabled();
        doReturn(false).when(mPhoneMock2).isUserDataEnabled();

        Intent intent = captureBroadcastIntent();
        assertEquals(ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED, intent.getAction());
        assertEquals(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA,
                intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, -1));

        // Setting default data should not trigger any more setDataEnabled().
        doReturn(2).when(mSubControllerMock).getDefaultDataSubId();
        mMultiSimSettingControllerUT.notifyDefaultDataSubChanged();
        processAllMessages();
        verify(mDataEnabledSettingsMock1, times(1)).setDataEnabled(anyInt(), anyBoolean());
        verify(mDataEnabledSettingsMock2, times(1)).setDataEnabled(anyInt(), anyBoolean());
    }

    @Test
    @SmallTest
    public void testDsdsGrouping() {