diff options
3 files changed, 39 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java index 5e71047..1d2a49a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java @@ -406,8 +406,9 @@ public class NetworkControllerImpl extends BroadcastReceiver updateNoSims(); } - private void updateNoSims() { - boolean hasNoSims = mPhone.getPhoneCount() != 0 && mMobileSignalControllers.size() == 0; + @VisibleForTesting + protected void updateNoSims() { + boolean hasNoSims = mHasMobileDataFeature && mMobileSignalControllers.size() == 0; if (hasNoSims != mHasNoSims) { mHasNoSims = hasNoSims; notifyListeners(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java index eaf2f78..020bc00 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java @@ -195,6 +195,18 @@ public class NetworkControllerBaseTest extends AndroidTestCase { mPhoneStateListener.onDataActivity(dataActivity); } + protected void verifyHasNoSims(boolean hasNoSimsVisible) { + ArgumentCaptor<Boolean> hasNoSimsArg = ArgumentCaptor.forClass(Boolean.class); + + Mockito.verify(mSignalCluster, Mockito.atLeastOnce()).setNoSims(hasNoSimsArg.capture()); + assertEquals("No sims in status bar", hasNoSimsVisible, (boolean) hasNoSimsArg.getValue()); + + Mockito.verify(mNetworkSignalChangedCallback, Mockito.atLeastOnce()) + .onNoSimVisibleChanged(hasNoSimsArg.capture()); + assertEquals("No sims in quick settings", hasNoSimsVisible, + (boolean) hasNoSimsArg.getValue()); + } + protected void verifyLastQsMobileDataIndicators(boolean visible, int icon, int typeIcon, boolean dataIn, boolean dataOut) { ArgumentCaptor<Integer> iconArg = ArgumentCaptor.forClass(Integer.class); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java index b5d97d9..33eb4d6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java @@ -25,6 +25,30 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest { verifyLastMobileDataIndicators(false, 0, 0); } + public void testNoSimsIconPresent() { + // No Subscriptions. + mNetworkController.mMobileSignalControllers.clear(); + mNetworkController.updateNoSims(); + + verifyHasNoSims(true); + } + + public void testNoSimlessIconWithoutMobile() { + // Turn off mobile network support. + Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false); + // Create a new NetworkController as this is currently handled in constructor. + mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm, + mConfig, mock(AccessPointControllerImpl.class), + mock(MobileDataControllerImpl.class)); + setupNetworkController(); + + // No Subscriptions. + mNetworkController.mMobileSignalControllers.clear(); + mNetworkController.updateNoSims(); + + verifyHasNoSims(false); + } + public void testSignalStrength() { for (int testStrength = SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN; testStrength <= SignalStrength.SIGNAL_STRENGTH_GREAT; testStrength++) { |