Loading src/java/com/android/internal/telephony/MultiSimSettingController.java +3 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading tests/telephonytests/src/com/android/internal/telephony/MultiSimSettingControllerTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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() { Loading Loading
src/java/com/android/internal/telephony/MultiSimSettingController.java +3 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading
tests/telephonytests/src/com/android/internal/telephony/MultiSimSettingControllerTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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() { Loading