Loading packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +32 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.qs.tiles.dialog; import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import static com.android.settingslib.mobile.MobileMappings.getIconKey; import static com.android.settingslib.mobile.MobileMappings.mapIconSets; import static com.android.settingslib.wifi.WifiUtils.getHotspotIconResource; Loading Loading @@ -190,7 +192,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi private DialogTransitionAnimator mDialogTransitionAnimator; private boolean mHasWifiEntries; private WifiStateWorker mWifiStateWorker; private boolean mHasActiveSubId; private boolean mHasActiveSubIdOnDds; @VisibleForTesting static final float TOAST_PARAMS_HORIZONTAL_WEIGHT = 1.0f; Loading Loading @@ -298,7 +300,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi mExecutor); // Listen the subscription changes mOnSubscriptionsChangedListener = new InternetOnSubscriptionChangedListener(); refreshHasActiveSubId(); refreshHasActiveSubIdOnDds(); mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor, mOnSubscriptionsChangedListener); mDefaultDataSubId = getDefaultDataSubscriptionId(); Loading Loading @@ -428,7 +430,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi } boolean isActiveOnNonDds = getActiveAutoSwitchNonDdsSubId() != SubscriptionManager .INVALID_SUBSCRIPTION_ID; if (!hasActiveSubId() || (!isVoiceStateInService(mDefaultDataSubId) if (!hasActiveSubIdOnDds() || (!isVoiceStateInService(mDefaultDataSubId) && !isDataStateInService(mDefaultDataSubId) && !isActiveOnNonDds)) { if (DEBUG) { Log.d(TAG, "No carrier or service is out of service."); Loading Loading @@ -901,23 +903,42 @@ public class InternetDialogController implements AccessPointController.AccessPoi /** * @return whether there is the carrier item in the slice. */ boolean hasActiveSubId() { boolean hasActiveSubIdOnDds() { if (isAirplaneModeEnabled() || mTelephonyManager == null) { return false; } return mHasActiveSubId; return mHasActiveSubIdOnDds; } private static boolean isEmbeddedSubscriptionVisible(@NonNull SubscriptionInfo subInfo) { if (subInfo.isEmbedded() && subInfo.getProfileClass() == PROFILE_CLASS_PROVISIONING) { return false; } return true; } private void refreshHasActiveSubId() { private void refreshHasActiveSubIdOnDds() { if (mSubscriptionManager == null) { mHasActiveSubId = false; mHasActiveSubIdOnDds = false; Log.e(TAG, "SubscriptionManager is null, set mHasActiveSubId = false"); return; } int dds = getDefaultDataSubscriptionId(); if (dds == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { mHasActiveSubIdOnDds = false; Log.d(TAG, "DDS is INVALID_SUBSCRIPTION_ID"); return; } SubscriptionInfo ddsSubInfo = mSubscriptionManager.getActiveSubscriptionInfo(dds); if (ddsSubInfo == null) { mHasActiveSubIdOnDds = false; Log.e(TAG, "Can't get DDS subscriptionInfo"); return; } mHasActiveSubId = mSubscriptionManager.getActiveSubscriptionIdList().length > 0; Log.i(TAG, "mHasActiveSubId:" + mHasActiveSubId); mHasActiveSubIdOnDds = isEmbeddedSubscriptionVisible(ddsSubInfo); Log.i(TAG, "mHasActiveSubId:" + mHasActiveSubIdOnDds); } /** Loading Loading @@ -1209,7 +1230,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi @Override public void onSubscriptionsChanged() { refreshHasActiveSubId(); refreshHasActiveSubIdOnDds(); updateListener(); } } Loading Loading @@ -1306,6 +1327,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi Log.d(TAG, "ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED"); } mConfig = MobileMappings.Config.readConfig(context); refreshHasActiveSubIdOnDds(); updateListener(); } else if (WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION.equals(action)) { updateListener(); Loading packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java +1 −1 Original line number Diff line number Diff line Loading @@ -429,7 +429,7 @@ public class InternetDialogDelegate implements } boolean isWifiEnabled = mInternetDialogController.isWifiEnabled(); if (!mInternetDialogController.hasActiveSubId() if (!mInternetDialogController.hasActiveSubIdOnDds() && (!isWifiEnabled || !isCarrierNetworkActive)) { mMobileNetworkLayout.setVisibility(View.GONE); if (mSecondaryMobileNetworkLayout != null) { Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateControllerTest.java +24 −6 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import static android.provider.Settings.Global.AIRPLANE_MODE_ON; import static android.telephony.SignalStrength.NUM_SIGNAL_STRENGTH_BINS; import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GREAT; import static android.telephony.SignalStrength.SIGNAL_STRENGTH_POOR; import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; import static com.android.settingslib.wifi.WifiUtils.getHotspotIconResource; Loading Loading @@ -217,6 +218,8 @@ public class InternetDialogDelegateControllerTest extends SysuiTestCase { when(mAccessPointController.getMergedCarrierEntry()).thenReturn(mMergedCarrierEntry); when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID}); when(SubscriptionManager.getDefaultDataSubscriptionId()).thenReturn(SUB_ID); SubscriptionInfo info = mock(SubscriptionInfo.class); when(mSubscriptionManager.getActiveSubscriptionInfo(SUB_ID)).thenReturn(info); when(mToastFactory.createToast(any(), anyString(), anyString(), anyInt(), anyInt())) .thenReturn(mSystemUIToast); when(mSystemUIToast.getView()).thenReturn(mToastView); Loading Loading @@ -1083,19 +1086,34 @@ public class InternetDialogDelegateControllerTest extends SysuiTestCase { } @Test public void hasActiveSubId_activeSubIdListIsEmpty_returnFalse() { when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{}); public void hasActiveSubIdOnDds_noDds_returnFalse() { when(SubscriptionManager.getDefaultDataSubscriptionId()) .thenReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID); mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubId()).isFalse(); assertThat(mInternetDialogController.hasActiveSubIdOnDds()).isFalse(); } @Test public void hasActiveSubId_activeSubIdListNotEmpty_returnTrue() { when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID}); public void hasActiveSubIdOnDds_activeDds_returnTrue() { mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubIdOnDds()).isTrue(); } @Test public void hasActiveSubIdOnDds_activeDdsAndHasProvisioning_returnFalse() { when(SubscriptionManager.getDefaultDataSubscriptionId()) .thenReturn(SUB_ID); SubscriptionInfo info = mock(SubscriptionInfo.class); when(info.isEmbedded()).thenReturn(true); when(info.getProfileClass()).thenReturn(PROFILE_CLASS_PROVISIONING); when(mSubscriptionManager.getActiveSubscriptionInfo(SUB_ID)).thenReturn(info); mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubId()).isTrue(); assertThat(mInternetDialogController.hasActiveSubIdOnDds()).isFalse(); } private String getResourcesString(String name) { Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -251,7 +251,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { // Mobile network should be gone if the list of active subscriptionId is null. when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(false); when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false); when(mInternetDialogController.hasActiveSubId()).thenReturn(false); when(mInternetDialogController.hasActiveSubIdOnDds()).thenReturn(false); mInternetDialogDelegate.updateDialog(true); Loading Loading @@ -336,7 +336,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { @Test public void updateDialog_mobileDataIsEnabled_checkMobileDataSwitch() { doReturn(true).when(mInternetDialogController).hasActiveSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubIdOnDds(); when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true); when(mInternetDialogController.isMobileDataEnabled()).thenReturn(true); mMobileToggleSwitch.setChecked(false); Loading @@ -348,7 +348,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { @Test public void updateDialog_mobileDataIsNotChanged_checkMobileDataSwitch() { doReturn(true).when(mInternetDialogController).hasActiveSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubIdOnDds(); when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true); when(mInternetDialogController.isMobileDataEnabled()).thenReturn(false); mMobileToggleSwitch.setChecked(false); Loading @@ -361,7 +361,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { @Test public void updateDialog_wifiOnAndHasInternetWifi_showConnectedWifi() { mInternetDialogDelegate.dismissDialog(); doReturn(true).when(mInternetDialogController).hasActiveSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubIdOnDds(); createInternetDialog(); // The preconditions WiFi ON and Internet WiFi are already in setUp() doReturn(false).when(mInternetDialogController).activeNetworkIsCellular(); Loading Loading @@ -522,7 +522,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { public void updateDialog_showSecondaryDataSub() { mInternetDialogDelegate.dismissDialog(); doReturn(1).when(mInternetDialogController).getActiveAutoSwitchNonDdsSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubIdOnDds(); doReturn(false).when(mInternetDialogController).isAirplaneModeEnabled(); createInternetDialog(); Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +32 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.qs.tiles.dialog; import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import static com.android.settingslib.mobile.MobileMappings.getIconKey; import static com.android.settingslib.mobile.MobileMappings.mapIconSets; import static com.android.settingslib.wifi.WifiUtils.getHotspotIconResource; Loading Loading @@ -190,7 +192,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi private DialogTransitionAnimator mDialogTransitionAnimator; private boolean mHasWifiEntries; private WifiStateWorker mWifiStateWorker; private boolean mHasActiveSubId; private boolean mHasActiveSubIdOnDds; @VisibleForTesting static final float TOAST_PARAMS_HORIZONTAL_WEIGHT = 1.0f; Loading Loading @@ -298,7 +300,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi mExecutor); // Listen the subscription changes mOnSubscriptionsChangedListener = new InternetOnSubscriptionChangedListener(); refreshHasActiveSubId(); refreshHasActiveSubIdOnDds(); mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor, mOnSubscriptionsChangedListener); mDefaultDataSubId = getDefaultDataSubscriptionId(); Loading Loading @@ -428,7 +430,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi } boolean isActiveOnNonDds = getActiveAutoSwitchNonDdsSubId() != SubscriptionManager .INVALID_SUBSCRIPTION_ID; if (!hasActiveSubId() || (!isVoiceStateInService(mDefaultDataSubId) if (!hasActiveSubIdOnDds() || (!isVoiceStateInService(mDefaultDataSubId) && !isDataStateInService(mDefaultDataSubId) && !isActiveOnNonDds)) { if (DEBUG) { Log.d(TAG, "No carrier or service is out of service."); Loading Loading @@ -901,23 +903,42 @@ public class InternetDialogController implements AccessPointController.AccessPoi /** * @return whether there is the carrier item in the slice. */ boolean hasActiveSubId() { boolean hasActiveSubIdOnDds() { if (isAirplaneModeEnabled() || mTelephonyManager == null) { return false; } return mHasActiveSubId; return mHasActiveSubIdOnDds; } private static boolean isEmbeddedSubscriptionVisible(@NonNull SubscriptionInfo subInfo) { if (subInfo.isEmbedded() && subInfo.getProfileClass() == PROFILE_CLASS_PROVISIONING) { return false; } return true; } private void refreshHasActiveSubId() { private void refreshHasActiveSubIdOnDds() { if (mSubscriptionManager == null) { mHasActiveSubId = false; mHasActiveSubIdOnDds = false; Log.e(TAG, "SubscriptionManager is null, set mHasActiveSubId = false"); return; } int dds = getDefaultDataSubscriptionId(); if (dds == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { mHasActiveSubIdOnDds = false; Log.d(TAG, "DDS is INVALID_SUBSCRIPTION_ID"); return; } SubscriptionInfo ddsSubInfo = mSubscriptionManager.getActiveSubscriptionInfo(dds); if (ddsSubInfo == null) { mHasActiveSubIdOnDds = false; Log.e(TAG, "Can't get DDS subscriptionInfo"); return; } mHasActiveSubId = mSubscriptionManager.getActiveSubscriptionIdList().length > 0; Log.i(TAG, "mHasActiveSubId:" + mHasActiveSubId); mHasActiveSubIdOnDds = isEmbeddedSubscriptionVisible(ddsSubInfo); Log.i(TAG, "mHasActiveSubId:" + mHasActiveSubIdOnDds); } /** Loading Loading @@ -1209,7 +1230,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi @Override public void onSubscriptionsChanged() { refreshHasActiveSubId(); refreshHasActiveSubIdOnDds(); updateListener(); } } Loading Loading @@ -1306,6 +1327,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi Log.d(TAG, "ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED"); } mConfig = MobileMappings.Config.readConfig(context); refreshHasActiveSubIdOnDds(); updateListener(); } else if (WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION.equals(action)) { updateListener(); Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java +1 −1 Original line number Diff line number Diff line Loading @@ -429,7 +429,7 @@ public class InternetDialogDelegate implements } boolean isWifiEnabled = mInternetDialogController.isWifiEnabled(); if (!mInternetDialogController.hasActiveSubId() if (!mInternetDialogController.hasActiveSubIdOnDds() && (!isWifiEnabled || !isCarrierNetworkActive)) { mMobileNetworkLayout.setVisibility(View.GONE); if (mSecondaryMobileNetworkLayout != null) { Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateControllerTest.java +24 −6 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import static android.provider.Settings.Global.AIRPLANE_MODE_ON; import static android.telephony.SignalStrength.NUM_SIGNAL_STRENGTH_BINS; import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GREAT; import static android.telephony.SignalStrength.SIGNAL_STRENGTH_POOR; import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; import static com.android.settingslib.wifi.WifiUtils.getHotspotIconResource; Loading Loading @@ -217,6 +218,8 @@ public class InternetDialogDelegateControllerTest extends SysuiTestCase { when(mAccessPointController.getMergedCarrierEntry()).thenReturn(mMergedCarrierEntry); when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID}); when(SubscriptionManager.getDefaultDataSubscriptionId()).thenReturn(SUB_ID); SubscriptionInfo info = mock(SubscriptionInfo.class); when(mSubscriptionManager.getActiveSubscriptionInfo(SUB_ID)).thenReturn(info); when(mToastFactory.createToast(any(), anyString(), anyString(), anyInt(), anyInt())) .thenReturn(mSystemUIToast); when(mSystemUIToast.getView()).thenReturn(mToastView); Loading Loading @@ -1083,19 +1086,34 @@ public class InternetDialogDelegateControllerTest extends SysuiTestCase { } @Test public void hasActiveSubId_activeSubIdListIsEmpty_returnFalse() { when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{}); public void hasActiveSubIdOnDds_noDds_returnFalse() { when(SubscriptionManager.getDefaultDataSubscriptionId()) .thenReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID); mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubId()).isFalse(); assertThat(mInternetDialogController.hasActiveSubIdOnDds()).isFalse(); } @Test public void hasActiveSubId_activeSubIdListNotEmpty_returnTrue() { when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID}); public void hasActiveSubIdOnDds_activeDds_returnTrue() { mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubIdOnDds()).isTrue(); } @Test public void hasActiveSubIdOnDds_activeDdsAndHasProvisioning_returnFalse() { when(SubscriptionManager.getDefaultDataSubscriptionId()) .thenReturn(SUB_ID); SubscriptionInfo info = mock(SubscriptionInfo.class); when(info.isEmbedded()).thenReturn(true); when(info.getProfileClass()).thenReturn(PROFILE_CLASS_PROVISIONING); when(mSubscriptionManager.getActiveSubscriptionInfo(SUB_ID)).thenReturn(info); mInternetDialogController.mOnSubscriptionsChangedListener.onSubscriptionsChanged(); assertThat(mInternetDialogController.hasActiveSubId()).isTrue(); assertThat(mInternetDialogController.hasActiveSubIdOnDds()).isFalse(); } private String getResourcesString(String name) { Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -251,7 +251,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { // Mobile network should be gone if the list of active subscriptionId is null. when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(false); when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false); when(mInternetDialogController.hasActiveSubId()).thenReturn(false); when(mInternetDialogController.hasActiveSubIdOnDds()).thenReturn(false); mInternetDialogDelegate.updateDialog(true); Loading Loading @@ -336,7 +336,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { @Test public void updateDialog_mobileDataIsEnabled_checkMobileDataSwitch() { doReturn(true).when(mInternetDialogController).hasActiveSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubIdOnDds(); when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true); when(mInternetDialogController.isMobileDataEnabled()).thenReturn(true); mMobileToggleSwitch.setChecked(false); Loading @@ -348,7 +348,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { @Test public void updateDialog_mobileDataIsNotChanged_checkMobileDataSwitch() { doReturn(true).when(mInternetDialogController).hasActiveSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubIdOnDds(); when(mInternetDialogController.isCarrierNetworkActive()).thenReturn(true); when(mInternetDialogController.isMobileDataEnabled()).thenReturn(false); mMobileToggleSwitch.setChecked(false); Loading @@ -361,7 +361,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { @Test public void updateDialog_wifiOnAndHasInternetWifi_showConnectedWifi() { mInternetDialogDelegate.dismissDialog(); doReturn(true).when(mInternetDialogController).hasActiveSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubIdOnDds(); createInternetDialog(); // The preconditions WiFi ON and Internet WiFi are already in setUp() doReturn(false).when(mInternetDialogController).activeNetworkIsCellular(); Loading Loading @@ -522,7 +522,7 @@ public class InternetDialogDelegateTest extends SysuiTestCase { public void updateDialog_showSecondaryDataSub() { mInternetDialogDelegate.dismissDialog(); doReturn(1).when(mInternetDialogController).getActiveAutoSwitchNonDdsSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubId(); doReturn(true).when(mInternetDialogController).hasActiveSubIdOnDds(); doReturn(false).when(mInternetDialogController).isAirplaneModeEnabled(); createInternetDialog(); Loading