diff options
author | Roshan Pius <rpius@google.com> | 2019-09-27 08:13:02 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-10-01 19:16:04 -0700 |
commit | 2c004a1c8f0ab178a48b92b5c6b9f407c1b1340d (patch) | |
tree | 2a5597497f3812ab2e786ec1b9fd6feb81c1ad17 /tests | |
parent | 6f813a702eaf19bd48a79a10745e5510e3ef3743 (diff) |
ActiveModeWarden: Support multiple ClientModeManagers
Changes in the CL:
a) Rename WifiController states to Enabled & Disabled state to better
incorporate Softap into the overall state management.
EnableState - One or more ActiveModeManager active (we transition to
Enabled when the first ActiveModeManager is started).
DisabledState - No ActiveModeManager active.
b) Create ClientModeManager/ClientListener similar to how
SoftApManager is created.
c) Ensure we have a consistent setup/teardown flow for both
ClientModeManager/SoftApManager.
Any time SoftapManager is stopped/start failure, check if we
need to create a ClientModeManager.
d) The logic to create secondary ClientModeManager has not been added.
This will come later once we have a target use-case.
d) All active client mode managers are treated equaly. i.e
stopped/switched modes all done on global toggles.
e) Also, reworked some of the emergency handling code. If we're in
EnabledState when the emergency mode starts (&
getConfigWifiDisabledInEcbm returns true), we need to allow the state
machine to switch to DisableState. This is needed becauase we now
transition to DisabledState only when all the mode managers are
completely stopped.
Bug: 139157226
Bug: 141540849.
Test: Manual tests in progress.
Change-Id: I7b1c2cde7ed679ad2c35bfd1b0527cdfc8a37c01
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java | 445 |
1 files changed, 274 insertions, 171 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java index db2f36158..321c078c1 100644 --- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java @@ -40,6 +40,7 @@ import androidx.test.filters.SmallTest; import com.android.internal.R; import com.android.internal.app.IBatteryStats; +import com.android.server.wifi.util.GeneralUtil; import com.android.server.wifi.util.WifiPermissionsUtil; import org.junit.After; @@ -64,8 +65,8 @@ import java.util.stream.Collectors; public class ActiveModeWardenTest extends WifiBaseTest { public static final String TAG = "WifiActiveModeWardenTest"; - private static final String STA_ENABLED_STATE_STRING = "StaEnabledState"; - private static final String STA_DISABLED_STATE_STRING = "StaDisabledState"; + private static final String ENABLED_STATE_STRING = "EnabledState"; + private static final String DISABLED_STATE_STRING = "DisabledState"; private static final String WIFI_IFACE_NAME = "mockWlan"; private static final int TEST_WIFI_RECOVERY_DELAY_MS = 2000; @@ -183,29 +184,36 @@ public class ActiveModeWardenTest extends WifiBaseTest { } /** - * Helper method to enter the StaEnabledState and set ClientModeManager in ConnectMode. + * Helper method to enter the EnabledState and set ClientModeManager in ConnectMode. */ private void enterClientModeActiveState() throws Exception { + String fromState = mActiveModeWarden.getCurrentMode(); when(mClientModeManager.getScanMode()).thenReturn(SCAN_WITH_HIDDEN_NETWORKS); + when(mClientModeManager.isInConnectMode()).thenReturn(true); when(mSettingsStore.isWifiToggleEnabled()).thenReturn(true); mActiveModeWarden.wifiToggled(); mLooper.dispatchAll(); mClientListener.onStarted(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); verify(mClientModeManager).switchToConnectMode(); verify(mScanRequestProxy).enableScanning(true, true); - verify(mBatteryStats).noteWifiOn(); + if (fromState.equals(DISABLED_STATE_STRING)) { + verify(mBatteryStats).noteWifiOn(); + } } /** - * Helper method to enter the StaEnabledState and set ClientModeManager in ScanOnlyMode. + * Helper method to enter the EnabledState and set ClientModeManager in ScanOnlyMode. */ private void enterScanOnlyModeActiveState() throws Exception { + String fromState = mActiveModeWarden.getCurrentMode(); when(mClientModeManager.getScanMode()).thenReturn(SCAN_WITHOUT_HIDDEN_NETWORKS); + when(mClientModeManager.isInScanOnlyMode()).thenReturn(true); when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(true); + when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(true); when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false); mActiveModeWarden.wifiToggled(); @@ -213,11 +221,13 @@ public class ActiveModeWardenTest extends WifiBaseTest { mClientListener.onStarted(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); verify(mClientModeManager).switchToScanOnlyMode(); verify(mScanRequestProxy).enableScanning(true, false); - verify(mBatteryStats).noteWifiOn(); + if (fromState.equals(DISABLED_STATE_STRING)) { + verify(mBatteryStats).noteWifiOn(); + } verify(mBatteryStats).noteWifiState(BatteryStats.WIFI_STATE_OFF_SCANNING, null); } @@ -235,25 +245,35 @@ public class ActiveModeWardenTest extends WifiBaseTest { String fromState = mActiveModeWarden.getCurrentMode(); mActiveModeWarden.startSoftAp(softApConfig); mLooper.dispatchAll(); + mSoftApListener.onStarted(); + mLooper.dispatchAll(); + + assertInEnabledState(); assertThat(softApConfig).isEqualTo(mSoftApConfig); verify(mSoftApManager).start(); - if (fromState.equals(STA_DISABLED_STATE_STRING)) { + if (fromState.equals(DISABLED_STATE_STRING)) { verify(mBatteryStats).noteWifiOn(); - } else if (!fromState.equals(STA_ENABLED_STATE_STRING)) { - verify(mScanRequestProxy, atLeastOnce()).enableScanning(false, false); } } - private void enterStaDisabledState() { + private void enterStaDisabledMode(boolean isSoftApModeManagerActive) { String fromState = mActiveModeWarden.getCurrentMode(); when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false); when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(false); when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(false); mActiveModeWarden.wifiToggled(); mLooper.dispatchAll(); + if (mClientListener != null) { + mClientListener.onStopped(); + mLooper.dispatchAll(); + } - assertInStaDisabledState(); - if (fromState.equals(STA_ENABLED_STATE_STRING)) { + if (isSoftApModeManagerActive) { + assertInEnabledState(); + } else { + assertInDisabledState(); + } + if (fromState.equals(ENABLED_STATE_STRING)) { verify(mScanRequestProxy).enableScanning(false, false); } } @@ -263,16 +283,16 @@ public class ActiveModeWardenTest extends WifiBaseTest { mLooper.dispatchAll(); } - private void assertInStaEnabledState() { - assertThat(mActiveModeWarden.getCurrentMode()).isEqualTo(STA_ENABLED_STATE_STRING); + private void assertInEnabledState() { + assertThat(mActiveModeWarden.getCurrentMode()).isEqualTo(ENABLED_STATE_STRING); } - private void assertInStaDisabledState() { - assertThat(mActiveModeWarden.getCurrentMode()).isEqualTo(STA_DISABLED_STATE_STRING); + private void assertInDisabledState() { + assertThat(mActiveModeWarden.getCurrentMode()).isEqualTo(DISABLED_STATE_STRING); } /** - * Emergency mode is a sub-mode within each main state (ScanOnly, Client, StaDisabled). + * Emergency mode is a sub-mode within each main state (ScanOnly, Client, DisabledState). */ private void assertInEmergencyMode() { assertThat(mActiveModeWarden.isInEmergencyMode()).isTrue(); @@ -385,15 +405,15 @@ public class ActiveModeWardenTest extends WifiBaseTest { .isEqualTo(expectedStopInvocationCounts); } - /** Test that after starting up, ActiveModeWarden is in the StaDisabled State. */ + /** Test that after starting up, ActiveModeWarden is in the DisabledState State. */ @Test - public void testStaDisabledAtStartup() { - assertInStaDisabledState(); + public void testDisabledStateAtStartup() { + assertInDisabledState(); } /** - * Test that ActiveModeWarden properly enters the StaEnabledState (in ScanOnlyMode) from the - * StaDisabled state. + * Test that ActiveModeWarden properly enters the EnabledState (in ScanOnlyMode) from the + * DisabledState state. */ @Test public void testEnterScanOnlyModeFromDisabled() throws Exception { @@ -402,7 +422,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { /** * Test that ActiveModeWarden properly starts the SoftApManager from the - * StaDisabled state. + * DisabledState state. */ @Test public void testEnterSoftApModeFromDisabled() throws Exception { @@ -415,13 +435,13 @@ public class ActiveModeWardenTest extends WifiBaseTest { @Test public void testEnterSoftApModeFromDifferentState() throws Exception { enterClientModeActiveState(); - assertInStaEnabledState(); + assertInEnabledState(); reset(mBatteryStats, mScanRequestProxy); enterSoftApActiveMode(); } /** - * Test that we can disable wifi fully from the StaEnabledState (in ScanOnlyMode). + * Test that we can disable wifi fully from the EnabledState (in ScanOnlyMode). */ @Test public void testDisableWifiFromScanOnlyModeActiveState() throws Exception { @@ -430,10 +450,12 @@ public class ActiveModeWardenTest extends WifiBaseTest { when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(false); mActiveModeWarden.scanAlwaysModeChanged(); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); verify(mClientModeManager).stop(); verify(mBatteryStats).noteWifiOff(); - assertInStaDisabledState(); + assertInDisabledState(); } /** @@ -442,16 +464,16 @@ public class ActiveModeWardenTest extends WifiBaseTest { @Test public void testDisableWifiFromSoftApModeActiveStateDoesNotStopSoftAp() throws Exception { enterSoftApActiveMode(); + enterScanOnlyModeActiveState(); reset(mDefaultModeManager); - enterStaDisabledState(); + enterStaDisabledMode(true); verify(mSoftApManager, never()).stop(); verify(mBatteryStats, never()).noteWifiOff(); - assertInStaDisabledState(); } /** - * Test that we can switch from the StaEnabledState (in ScanOnlyMode) to another mode. + * Test that we can switch from the EnabledState (in ScanOnlyMode) to another mode. */ @Test public void testSwitchModeWhenScanOnlyModeActiveState() throws Exception { @@ -461,11 +483,11 @@ public class ActiveModeWardenTest extends WifiBaseTest { enterClientModeActiveState(); mLooper.dispatchAll(); verify(mClientModeManager).switchToConnectMode(); - assertInStaEnabledState(); + assertInEnabledState(); } /** - * Reentering StaEnabledState should be a NOP. + * Reentering EnabledState should be a NOP. */ @Test public void testReenterClientModeActiveStateIsNop() throws Exception { @@ -489,12 +511,12 @@ public class ActiveModeWardenTest extends WifiBaseTest { enterClientModeActiveState(); mLooper.dispatchAll(); verify(mSoftApManager, never()).stop(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mWifiNative, never()).teardownAllInterfaces(); } /** - * Test that we activate SoftApModeManager if we are already in StaDisabledState due to + * Test that we activate SoftApModeManager if we are already in DisabledState due to * a failure. */ @Test @@ -503,7 +525,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { // now inject failure through the SoftApManager.Listener mSoftApListener.onStartFailure(); mLooper.dispatchAll(); - assertInStaDisabledState(); + assertInDisabledState(); // clear the first call to start SoftApManager reset(mSoftApManager, mBatteryStats); @@ -511,8 +533,8 @@ public class ActiveModeWardenTest extends WifiBaseTest { } /** - * Test that we return to the StaDisabledState after a failure is reported when in the - * StaEnabledState. + * Test that we return to the DisabledState after a failure is reported when in the + * EnabledState. */ @Test public void testScanOnlyModeFailureWhenActive() throws Exception { @@ -520,13 +542,12 @@ public class ActiveModeWardenTest extends WifiBaseTest { // now inject a failure through the ScanOnlyModeManager.Listener mClientListener.onStartFailure(); mLooper.dispatchAll(); - assertInStaDisabledState(); - verify(mClientModeManager).stop(); + assertInDisabledState(); verify(mBatteryStats).noteWifiOff(); } /** - * Test that we return to the StaDisabledState after a failure is reported when + * Test that we return to the DisabledState after a failure is reported when * SoftApManager is active. */ @Test @@ -550,13 +571,12 @@ public class ActiveModeWardenTest extends WifiBaseTest { mClientListener.onStopped(); mLooper.dispatchAll(); - assertInStaDisabledState(); - verify(mClientModeManager).stop(); + assertInDisabledState(); verify(mBatteryStats).noteWifiOff(); } /** - * Test that we return to the StaDisabledState after the SoftApManager is stopped. + * Test that we return to the DisabledState after the SoftApManager is stopped. */ @Test public void testSoftApDisabledWhenActive() throws Exception { @@ -657,7 +677,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { // now inject success through the Listener mClientListener.onStarted(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager, never()).stop(); } @@ -702,20 +722,34 @@ public class ActiveModeWardenTest extends WifiBaseTest { SoftApModeConfiguration softApConfig2 = new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, config2); - when(mWifiInjector.makeSoftApManager(any(ActiveModeManager.Listener.class), - any(WifiManager.SoftApCallback.class), - eq(softApConfig1))) - .thenReturn(mSoftApManager); + doAnswer(new Answer<SoftApManager>() { + public SoftApManager answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + mSoftApListener = (ActiveModeManager.Listener) args[0]; + return mSoftApManager; + } + }).when(mWifiInjector).makeSoftApManager(any(ActiveModeManager.Listener.class), + any(WifiManager.SoftApCallback.class), eq(softApConfig1)); // make a second softap manager SoftApManager softapManager = mock(SoftApManager.class); - when(mWifiInjector.makeSoftApManager(any(ActiveModeManager.Listener.class), - any(WifiManager.SoftApCallback.class), - eq(softApConfig2))) - .thenReturn(softapManager); + GeneralUtil.Mutable<ActiveModeManager.Listener> softApListener = + new GeneralUtil.Mutable<>(); + doAnswer(new Answer<SoftApManager>() { + public SoftApManager answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + softApListener.value = (ActiveModeManager.Listener) args[0]; + return softapManager; + } + }).when(mWifiInjector).makeSoftApManager(any(ActiveModeManager.Listener.class), + any(WifiManager.SoftApCallback.class), eq(softApConfig2)); mActiveModeWarden.startSoftAp(softApConfig1); + mLooper.dispatchAll(); + mSoftApListener.onStarted(); mActiveModeWarden.startSoftAp(softApConfig2); mLooper.dispatchAll(); + softApListener.value.onStarted(); + verify(mSoftApManager).start(); verify(softapManager).start(); verify(mBatteryStats).noteWifiOn(); @@ -726,7 +760,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void disableWifiWhenAlreadyOff() throws Exception { - enterStaDisabledState(); + enterStaDisabledMode(false); verifyZeroInteractions(mWifiNative); } @@ -766,7 +800,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { shutdownWifi(); - assertInStaDisabledState(); + assertInDisabledState(); } /** @@ -781,7 +815,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mClientListener.onStopped(); mLooper.dispatchAll(); - assertInStaDisabledState(); + assertInDisabledState(); } /** @@ -792,6 +826,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { enterSoftApActiveMode(); mSoftApListener.onStopped(); + mLooper.dispatchAll(); mSoftApManagerCallback.onStateChanged(WifiManager.WIFI_AP_STATE_DISABLED, 0); mLooper.dispatchAll(); @@ -833,8 +868,6 @@ public class ActiveModeWardenTest extends WifiBaseTest { public void dumpCallsActiveModeManagers() throws Exception { enterSoftApActiveMode(); enterClientModeActiveState(); - reset(mScanRequestProxy); - enterScanOnlyModeActiveState(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter(stream); @@ -860,21 +893,34 @@ public class ActiveModeWardenTest extends WifiBaseTest { // mock SoftAPManagers when(mSoftApManager.getIpMode()).thenReturn(WifiManager.IFACE_IP_MODE_TETHERED); - when(mWifiInjector.makeSoftApManager(any(ActiveModeManager.Listener.class), - any(WifiManager.SoftApCallback.class), - eq(tetherConfig))) - .thenReturn(mSoftApManager); + doAnswer(new Answer<SoftApManager>() { + public SoftApManager answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + mSoftApListener = (ActiveModeManager.Listener) args[0]; + return mSoftApManager; + } + }).when(mWifiInjector).makeSoftApManager(any(ActiveModeManager.Listener.class), + any(WifiManager.SoftApCallback.class), eq(tetherConfig)); + // make a second softap manager SoftApManager lohsSoftapManager = mock(SoftApManager.class); - when(lohsSoftapManager.getIpMode()).thenReturn(WifiManager.IFACE_IP_MODE_LOCAL_ONLY); - when(mWifiInjector.makeSoftApManager(any(ActiveModeManager.Listener.class), - any(WifiManager.SoftApCallback.class), - eq(lohsConfig))) - .thenReturn(lohsSoftapManager); + GeneralUtil.Mutable<ActiveModeManager.Listener> lohsSoftApListener = + new GeneralUtil.Mutable<>(); + doAnswer(new Answer<SoftApManager>() { + public SoftApManager answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + lohsSoftApListener.value = (ActiveModeManager.Listener) args[0]; + return lohsSoftapManager; + } + }).when(mWifiInjector).makeSoftApManager(any(ActiveModeManager.Listener.class), + any(WifiManager.SoftApCallback.class), eq(lohsConfig)); // enable tethering and LOHS mActiveModeWarden.startSoftAp(tetherConfig); + mLooper.dispatchAll(); + mSoftApListener.onStarted(); mActiveModeWarden.startSoftAp(lohsConfig); mLooper.dispatchAll(); + lohsSoftApListener.value.onStarted(); verify(mSoftApManager).start(); verify(lohsSoftapManager).start(); verify(mBatteryStats).noteWifiOn(); @@ -891,13 +937,16 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void enableWifi() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); when(mSettingsStore.isWifiToggleEnabled()).thenReturn(true); mActiveModeWarden.wifiToggled(); mLooper.dispatchAll(); - assertInStaEnabledState(); + mClientListener.onStarted(); + mLooper.dispatchAll(); + + assertInEnabledState(); } /** @@ -910,7 +959,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mLooper.dispatchAll(); verify(mClientModeManager).start(); verify(mClientModeManager).switchToScanOnlyMode(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager, never()).stop(); } @@ -925,7 +974,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.start(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -939,7 +988,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.start(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); verify(mClientModeManager).switchToConnectMode(); @@ -959,14 +1008,14 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.start(); mLooper.dispatchAll(); - assertInStaDisabledState(); + assertInDisabledState(); // toggling scan always available is not sufficient for scan mode when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(true); mActiveModeWarden.scanAlwaysModeChanged(); mLooper.dispatchAll(); - assertInStaDisabledState(); + assertInDisabledState(); } /** @@ -988,14 +1037,14 @@ public class ActiveModeWardenTest extends WifiBaseTest { verify(mContext).registerReceiver(bcastRxCaptor.capture(), any(IntentFilter.class)); BroadcastReceiver broadcastReceiver = bcastRxCaptor.getValue(); - assertInStaDisabledState(); + assertInDisabledState(); when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(true); Intent intent = new Intent(LocationManager.MODE_CHANGED_ACTION); broadcastReceiver.onReceive(mContext, intent); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); } @@ -1005,6 +1054,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { @Test public void testExitScanModeWhenLocationModeDisabled() throws Exception { when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(true); + when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(true); reset(mContext); @@ -1012,20 +1062,25 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden = createActiveModeWarden(); mActiveModeWarden.start(); mLooper.dispatchAll(); + mClientListener.onStarted(); + mLooper.dispatchAll(); ArgumentCaptor<BroadcastReceiver> bcastRxCaptor = ArgumentCaptor.forClass(BroadcastReceiver.class); verify(mContext).registerReceiver(bcastRxCaptor.capture(), any(IntentFilter.class)); BroadcastReceiver broadcastReceiver = bcastRxCaptor.getValue(); - assertInStaEnabledState(); + assertInEnabledState(); when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(false); Intent intent = new Intent(LocationManager.MODE_CHANGED_ACTION); broadcastReceiver.onReceive(mContext, intent); mLooper.dispatchAll(); - assertInStaDisabledState(); + mClientListener.onStopped(); + mLooper.dispatchAll(); + + assertInDisabledState(); } /** @@ -1070,7 +1125,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { @Test public void testEcmDisabledReturnsToClientMode() throws Exception { enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1085,7 +1140,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.emergencyCallbackModeChanged(false); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1098,7 +1153,10 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.scanAlwaysModeChanged(); mLooper.dispatchAll(); - assertInStaEnabledState(); + mClientListener.onStarted(); + mLooper.dispatchAll(); + + assertInEnabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1120,7 +1178,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.scanAlwaysModeChanged(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); // Test with WifiDisableInECBM turned off: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(false); @@ -1141,7 +1199,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.scanAlwaysModeChanged(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1156,7 +1214,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.emergencyCallbackModeChanged(false); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1201,7 +1259,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testEcmDisabledRemainsDisabledWhenSoftApHadBeenOn() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); enterSoftApActiveMode(); @@ -1215,13 +1273,15 @@ public class ActiveModeWardenTest extends WifiBaseTest { // test ecm changed mActiveModeWarden.emergencyCallbackModeChanged(true); mLooper.dispatchAll(); + mSoftApListener.onStopped(); + mLooper.dispatchAll(); }); // test ecm changed mActiveModeWarden.emergencyCallbackModeChanged(false); mLooper.dispatchAll(); - assertInStaDisabledState(); + assertInDisabledState(); // verify no additional calls to enable softap verify(mSoftApManager).start(); @@ -1232,7 +1292,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testEcmOnFromDisabledMode() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); verify(mSoftApManager, never()).start(); verify(mClientModeManager, never()).start(); @@ -1252,10 +1312,10 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testEnterEcmOnEmergencyCallStateChange() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1264,12 +1324,14 @@ public class ActiveModeWardenTest extends WifiBaseTest { // test call state changed mActiveModeWarden.emergencyCallStateChanged(true); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); }); mActiveModeWarden.emergencyCallStateChanged(false); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1277,10 +1339,10 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testEnterEcmWithBothSignals() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1288,6 +1350,8 @@ public class ActiveModeWardenTest extends WifiBaseTest { assertWifiShutDown(() -> { mActiveModeWarden.emergencyCallStateChanged(true); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); }); assertWifiShutDown(() -> { @@ -1303,8 +1367,9 @@ public class ActiveModeWardenTest extends WifiBaseTest { // stay in ecm, do not send an additional client mode trigger assertInEmergencyMode(); - // assert that the underlying state is still client state - assertInStaEnabledState(); + // assert that the underlying state is in disabled state + assertInDisabledState(); + // client mode still only started once verify(mClientModeManager).start(); @@ -1313,7 +1378,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { // now we can re-enable wifi verify(mClientModeManager, times(2)).start(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1321,11 +1386,11 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testEnterEcmWithBothSignalsOutOfOrder() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); // Test with WifiDisableInECBM turned on: @@ -1334,8 +1399,10 @@ public class ActiveModeWardenTest extends WifiBaseTest { assertEnteredEcmMode(() -> { mActiveModeWarden.emergencyCallbackModeChanged(true); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); }); - assertInStaEnabledState(); + assertInDisabledState(); assertEnteredEcmMode(() -> { mActiveModeWarden.emergencyCallStateChanged(true); @@ -1346,15 +1413,19 @@ public class ActiveModeWardenTest extends WifiBaseTest { mLooper.dispatchAll(); // stay in ecm, do not send an additional client mode trigger + assertInEmergencyMode(); + // assert that the underlying state is in disabled state + assertInDisabledState(); + + // client mode still only started once verify(mClientModeManager).start(); - assertInStaEnabledState(); mActiveModeWarden.emergencyCallbackModeChanged(false); mLooper.dispatchAll(); // now we can re-enable wifi verify(mClientModeManager, times(2)).start(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1363,11 +1434,11 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testEnterEcmWithBothSignalsOppositeOrder() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); // Test with WifiDisableInECBM turned on: @@ -1376,8 +1447,10 @@ public class ActiveModeWardenTest extends WifiBaseTest { assertEnteredEcmMode(() -> { mActiveModeWarden.emergencyCallStateChanged(true); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); }); - assertInStaEnabledState(); + assertInDisabledState(); assertEnteredEcmMode(() -> { mActiveModeWarden.emergencyCallbackModeChanged(true); @@ -1388,15 +1461,19 @@ public class ActiveModeWardenTest extends WifiBaseTest { mLooper.dispatchAll(); // stay in ecm, do not send an additional client mode trigger + assertInEmergencyMode(); + // assert that the underlying state is in disabled state + assertInDisabledState(); + + // client mode still only started once verify(mClientModeManager).start(); - assertInStaEnabledState(); mActiveModeWarden.emergencyCallStateChanged(false); mLooper.dispatchAll(); // now we can re-enable wifi verify(mClientModeManager, times(2)).start(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1408,12 +1485,12 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testProperExitFromEcmModeWithMultipleMessages() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); enableWifi(); verify(mClientModeManager).start(); - assertInStaEnabledState(); + assertInEnabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1425,8 +1502,10 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.emergencyCallbackModeChanged(true); mActiveModeWarden.emergencyCallbackModeChanged(true); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); }); - assertInStaEnabledState(); + assertInDisabledState(); assertEnteredEcmMode(() -> { mActiveModeWarden.emergencyCallbackModeChanged(false); @@ -1441,7 +1520,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { // didn't enter client mode again verify(mClientModeManager).start(); - assertInStaEnabledState(); + assertInDisabledState(); // now we will exit ECM mActiveModeWarden.emergencyCallStateChanged(false); @@ -1449,7 +1528,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { // now we can re-enable wifi verify(mClientModeManager, times(2)).start(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1457,7 +1536,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testWifiDoesNotToggleOnWhenInEcm() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1473,7 +1552,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mLooper.dispatchAll(); verify(mClientModeManager, never()).start(); - assertInStaDisabledState(); + assertInDisabledState(); } @Test @@ -1487,7 +1566,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testScanModeDoesNotToggleOnWhenInEcm() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1504,7 +1583,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mLooper.dispatchAll(); verify(mClientModeManager, never()).start(); - assertInStaDisabledState(); + assertInDisabledState(); } @@ -1513,7 +1592,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testSoftApModeDoesNotToggleOnWhenInEcm() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1528,7 +1607,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mLooper.dispatchAll(); verify(mSoftApManager, never()).start(); - assertInStaDisabledState(); + assertInDisabledState(); } /** @@ -1536,7 +1615,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testSoftApStoppedDoesNotSwitchModesWhenInEcm() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1549,7 +1628,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.stopSoftAp(WifiManager.IFACE_IP_MODE_UNSPECIFIED); mLooper.dispatchAll(); - assertInStaDisabledState(); + assertInDisabledState(); verifyNoMoreInteractions(mSoftApManager, mClientModeManager); } @@ -1578,9 +1657,9 @@ public class ActiveModeWardenTest extends WifiBaseTest { * Toggling off scan mode when in ECM does not induce a mode change */ @Test - public void testScanModeStoppedDoesNotSwitchModesWhenInEcm() throws Exception { + public void testScanModeStoppedSwitchModeToDisabledStateWhenInEcm() throws Exception { enterScanOnlyModeActiveState(); - assertInStaEnabledState(); + assertInEnabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1588,21 +1667,24 @@ public class ActiveModeWardenTest extends WifiBaseTest { // test ecm changed mActiveModeWarden.emergencyCallbackModeChanged(true); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); }); + // Spurious onStopped mClientListener.onStopped(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInDisabledState(); } /** * Toggling off client mode when in ECM does not induce a mode change */ @Test - public void testClientModeStoppedDoesNotSwitchModesWhenInEcm() throws Exception { + public void testClientModeStoppedSwitchModeToDisabledStateWhenInEcm() throws Exception { enterClientModeActiveState(); - assertInStaEnabledState(); + assertInEnabledState(); // Test with WifiDisableInECBM turned on: when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); @@ -1610,25 +1692,28 @@ public class ActiveModeWardenTest extends WifiBaseTest { // test ecm changed mActiveModeWarden.emergencyCallbackModeChanged(true); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); }); + // Spurious onStopped mClientListener.onStopped(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInDisabledState(); } /** * When AP mode is enabled and wifi was previously in AP mode, we should return to - * StaEnabledState after the AP is disabled. - * Enter StaEnabledState, activate AP mode, disable AP mode. + * EnabledState after the AP is disabled. + * Enter EnabledState, activate AP mode, disable AP mode. * <p> - * Expected: AP should successfully start and exit, then return to StaEnabledState. + * Expected: AP should successfully start and exit, then return to EnabledState. */ @Test - public void testReturnToStaEnabledStateAfterAPModeShutdown() throws Exception { + public void testReturnToEnabledStateAfterAPModeShutdown() throws Exception { enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); mActiveModeWarden.startSoftAp( @@ -1637,11 +1722,13 @@ public class ActiveModeWardenTest extends WifiBaseTest { mClientListener.onStopped(); mLooper.dispatchAll(); - mActiveModeWarden.softApStopped(); + // Now stop the AP + mSoftApListener.onStopped(); mLooper.dispatchAll(); + // We should re-enable client mode verify(mClientModeManager, times(2)).start(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1650,14 +1737,14 @@ public class ActiveModeWardenTest extends WifiBaseTest { * * Then when the AP is disabled, we should remain in STA mode. * - * Enter StaEnabledState, activate AP mode, toggle WiFi off. + * Enter EnabledState, activate AP mode, toggle WiFi off. * <p> - * Expected: AP should successfully start and exit, then return to StaEnabledState. + * Expected: AP should successfully start and exit, then return to EnabledState. */ @Test - public void testReturnToStaEnabledStateAfterWifiEnabledShutdown() throws Exception { + public void testReturnToEnabledStateAfterWifiEnabledShutdown() throws Exception { enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); mActiveModeWarden.startSoftAp( @@ -1666,16 +1753,16 @@ public class ActiveModeWardenTest extends WifiBaseTest { when(mSettingsStore.isWifiToggleEnabled()).thenReturn(true); mActiveModeWarden.wifiToggled(); - mActiveModeWarden.softApStopped(); + mSoftApListener.onStopped(); mLooper.dispatchAll(); // wasn't called again verify(mClientModeManager).start(); - assertInStaEnabledState(); + assertInEnabledState(); } @Test - public void testRestartWifiStackInStaEnabledStateTriggersBugReport() throws Exception { + public void testRestartWifiStackInEnabledStateTriggersBugReport() throws Exception { enableWifi(); mActiveModeWarden.recoveryRestartWifi(SelfRecovery.REASON_WIFINATIVE_FAILURE); mLooper.dispatchAll(); @@ -1696,11 +1783,13 @@ public class ActiveModeWardenTest extends WifiBaseTest { @Test public void testRecoveryDisabledTurnsWifiOff() throws Exception { enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); mActiveModeWarden.recoveryDisableWifi(); mLooper.dispatchAll(); verify(mClientModeManager).stop(); - assertInStaDisabledState(); + mClientListener.onStopped(); + mLooper.dispatchAll(); + assertInDisabledState(); } /** @@ -1708,7 +1797,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { */ @Test public void testRecoveryDisabledWhenWifiAlreadyOff() throws Exception { - assertInStaDisabledState(); + assertInDisabledState(); assertWifiShutDown(() -> { mActiveModeWarden.recoveryDisableWifi(); mLooper.dispatchAll(); @@ -1720,18 +1809,18 @@ public class ActiveModeWardenTest extends WifiBaseTest { * are not in STA mode. * WiFi is not in connect mode, so any calls to reset the wifi stack due to connection failures * should be ignored. - * Create and start WifiController in StaDisabledState, send command to restart WiFi + * Create and start WifiController in DisabledState, send command to restart WiFi * <p> * Expected: WiFiController should not call ActiveModeWarden.disableWifi() */ @Test - public void testRestartWifiStackInStaDisabledState() throws Exception { - assertInStaDisabledState(); + public void testRestartWifiStackInDisabledState() throws Exception { + assertInDisabledState(); mActiveModeWarden.recoveryRestartWifi(SelfRecovery.REASON_WIFINATIVE_FAILURE); mLooper.dispatchAll(); - assertInStaDisabledState(); + assertInDisabledState(); verifyNoMoreInteractions(mClientModeManager, mSoftApManager); } @@ -1740,20 +1829,20 @@ public class ActiveModeWardenTest extends WifiBaseTest { * are not in STA mode, even if scans are allowed. * WiFi is not in connect mode, so any calls to reset the wifi stack due to connection failures * should be ignored. - * Create and start WifiController in StaDisabledState, send command to restart WiFi + * Create and start WifiController in DisabledState, send command to restart WiFi * <p> * Expected: WiFiController should not call ActiveModeWarden.disableWifi() or * ActiveModeWarden.shutdownWifi(). */ @Test - public void testRestartWifiStackInStaDisabledWithScanState() throws Exception { - assertInStaDisabledState(); + public void testRestartWifiStackInDisabledStateWithScanState() throws Exception { + assertInDisabledState(); when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(true); mActiveModeWarden.scanAlwaysModeChanged(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); verify(mClientModeManager).switchToScanOnlyMode(); @@ -1761,14 +1850,16 @@ public class ActiveModeWardenTest extends WifiBaseTest { mLooper.dispatchAll(); verify(mClientModeManager).stop(); - assertInStaDisabledState(); + mClientListener.onStopped(); + mLooper.dispatchAll(); + assertInDisabledState(); mLooper.moveTimeForward(TEST_WIFI_RECOVERY_DELAY_MS); mLooper.dispatchAll(); verify(mClientModeManager, times(2)).start(); verify(mClientModeManager, times(2)).switchToScanOnlyMode(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1776,20 +1867,23 @@ public class ActiveModeWardenTest extends WifiBaseTest { * the ActiveModeWarden.shutdownWifi() call when in STA mode. * WiFi is in connect mode, calls to reset the wifi stack due to connection failures * should trigger a supplicant stop, and subsequently, a driver reload. - * Create and start WifiController in StaEnabledState, send command to restart WiFi + * Create and start WifiController in EnabledState, send command to restart WiFi * <p> * Expected: WiFiController should call ActiveModeWarden.shutdownWifi() and * ActiveModeWarden should enter CONNECT_MODE and the wifi driver should be started. */ @Test - public void testRestartWifiStackInStaEnabledState() throws Exception { + public void testRestartWifiStackInEnabledState() throws Exception { enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); assertWifiShutDown(() -> { mActiveModeWarden.recoveryRestartWifi(SelfRecovery.REASON_WIFINATIVE_FAILURE); mLooper.dispatchAll(); + // Complete the stop + mClientListener.onStopped(); + mLooper.dispatchAll(); }); // still only started once @@ -1800,7 +1894,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { // started again verify(mClientModeManager, times(2)).start(); - assertInStaEnabledState(); + assertInEnabledState(); } /** @@ -1813,16 +1907,21 @@ public class ActiveModeWardenTest extends WifiBaseTest { @Test public void testRestartWifiStackDoesNotExitECMMode() throws Exception { enableWifi(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); + verify(mClientModeManager).getScanMode(); + verify(mClientModeManager).isInScanOnlyMode(); verify(mClientModeManager).switchToConnectMode(); when(mFacade.getConfigWiFiDisableInECBM(mContext)).thenReturn(true); assertEnteredEcmMode(() -> { mActiveModeWarden.emergencyCallStateChanged(true); mLooper.dispatchAll(); + mClientListener.onStopped(); + mLooper.dispatchAll(); }); - assertInStaEnabledState(); + assertInEmergencyMode(); + assertInDisabledState(); verify(mClientModeManager).stop(); mActiveModeWarden.recoveryRestartWifi(SelfRecovery.REASON_LAST_RESORT_WATCHDOG); @@ -1830,7 +1929,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { verify(mClientModeManager).start(); // wasn't called again assertInEmergencyMode(); - assertInStaEnabledState(); + assertInDisabledState(); verifyNoMoreInteractions(mClientModeManager, mSoftApManager); } @@ -1854,32 +1953,36 @@ public class ActiveModeWardenTest extends WifiBaseTest { } /** - * Tests that when Wifi is already disabled and another Wifi toggle command arrives, but we're - * in airplane mode, don't enter scan mode. + * Tests that when Wifi is already disabled and another Wifi toggle command arrives, + * don't enter scan mode if {@link WifiSettingsStore#isScanAlwaysAvailable()} is false. + * Note: {@link WifiSettingsStore#isScanAlwaysAvailable()} returns false if either the wifi + * scanning is disabled and airplane mode is on. */ @Test - public void staDisabled_toggleWifiOff_scanAvailable_airplaneModeOn_dontGoToScanMode() { - assertInStaDisabledState(); + public void staDisabled_toggleWifiOff_scanNotAvailable_dontGoToScanMode() { + assertInDisabledState(); when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false); when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(true); - when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(true); + when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(false); when(mSettingsStore.isAirplaneModeOn()).thenReturn(true); mActiveModeWarden.wifiToggled(); mLooper.dispatchAll(); - assertInStaDisabledState(); + assertInDisabledState(); verify(mClientModeManager, never()).start(); } /** - * Tests that when Wifi is already disabled and another Wifi toggle command arrives, but we're - * not in airplane mode, enter scan mode. + * Tests that when Wifi is already disabled and another Wifi toggle command arrives, + * enter scan mode if {@link WifiSettingsStore#isScanAlwaysAvailable()} is true. + * Note: {@link WifiSettingsStore#isScanAlwaysAvailable()} returns true if both the wifi + * scanning is enabled and airplane mode is off. */ @Test - public void staDisabled_toggleWifiOff_scanAvailable_airplaneModeOff_goToScanMode() { - assertInStaDisabledState(); + public void staDisabled_toggleWifiOff_scanAvailable_goToScanMode() { + assertInDisabledState(); when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false); when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(true); @@ -1889,7 +1992,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.wifiToggled(); mLooper.dispatchAll(); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).start(); verify(mClientModeManager).switchToScanOnlyMode(); } @@ -1909,7 +2012,7 @@ public class ActiveModeWardenTest extends WifiBaseTest { mActiveModeWarden.emergencyCallbackModeChanged(true); mLooper.dispatchAll(); }); - assertInStaEnabledState(); + assertInEnabledState(); verify(mClientModeManager).stop(); mActiveModeWarden.emergencyCallbackModeChanged(false); @@ -1918,6 +2021,6 @@ public class ActiveModeWardenTest extends WifiBaseTest { assertThat(mActiveModeWarden.isInEmergencyMode()).isFalse(); // client mode restarted verify(mClientModeManager, times(2)).start(); - assertInStaEnabledState(); + assertInEnabledState(); } } |