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

Commit 8d72046b authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Don't show no sim icon on wifi devices" into lmp-mr1-dev

parents 195c4388 21d05a08
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -428,8 +428,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();
+12 −0
Original line number Diff line number Diff line
@@ -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);
+24 −0
Original line number Diff line number Diff line
@@ -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++) {