From 63e847ec063cdb7567e242104f25352745393707 Mon Sep 17 00:00:00 2001 From: Rebecca Silberstein Date: Thu, 16 Feb 2017 10:47:32 -0800 Subject: WifiStateMachine: merge scan mode handling There are two flavors of scan mode that are not handled consistently. This causes issues like wifi being reported as enabled when it is disabled. This CL merges the two scan mode options. SCAN_ONLY_MODE and SCAN_ONLY_WITH_WIFI_OFF_MODE both are now handled the same way in WifiStateMachine and will report wifi as disabled (when ScanMode is the operational state). There will not be special handling between the two modes. Full cleanup will be done with the WifiStateMachine refactor. An update to the scan mode transition to connect mode was also cleaned up. With the cleanup of the connect mode enter method, we now set wifi enabled, notify p2p and also no longer need to load the configs. These calls were removed since they are now redundant. A test was added to check the wifi disabled/enabled state for the operating modes of connect, scan, softap and disabled (not a real state, but implemented as the InitialState). A helper function was also added to advance the state machine thru SupplicantStarting and SupplicantStarted states. One test name typo was also fixed. Bug: 33367804 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: frameworks/base/wifi/tests/runtests.sh Test: passed wifi integration tests Change-Id: I9d2c2c898a36f8029a108bda5b8a9aabef9c4762 --- .../java/com/android/server/wifi/WifiStateMachine.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 7670320f2..af845d9b9 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4111,9 +4111,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss if (mOperationalMode == SCAN_ONLY_MODE || mOperationalMode == SCAN_ONLY_WITH_WIFI_OFF_MODE) { mWifiNative.disconnect(); - if (mOperationalMode == SCAN_ONLY_WITH_WIFI_OFF_MODE) { - setWifiState(WIFI_STATE_DISABLED); - } + setWifiState(WIFI_STATE_DISABLED); transitionTo(mScanModeState); } else if (mOperationalMode == CONNECT_MODE) { @@ -4425,13 +4423,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss switch(message.what) { case CMD_SET_OPERATIONAL_MODE: if (message.arg1 == CONNECT_MODE) { - if (mLastOperationMode == SCAN_ONLY_WITH_WIFI_OFF_MODE) { - setWifiState(WIFI_STATE_ENABLED); - // Load and re-enable networks when going back to enabled state - // This is essential for networks to show up after restore - mWifiConfigManager.loadFromStore(); - p2pSendMessage(CMD_ENABLE_P2P); - } mOperationalMode = CONNECT_MODE; transitionTo(mDisconnectedState); } else if (message.arg1 == DISABLED_MODE) { @@ -6337,12 +6328,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mOperationalMode = message.arg1; if (mOperationalMode == DISABLED_MODE) { transitionTo(mSupplicantStoppingState); - } else if (mOperationalMode == SCAN_ONLY_WITH_WIFI_OFF_MODE) { + } else if (mOperationalMode == SCAN_ONLY_MODE + || mOperationalMode == SCAN_ONLY_WITH_WIFI_OFF_MODE) { p2pSendMessage(CMD_DISABLE_P2P_REQ); setWifiState(WIFI_STATE_DISABLED); transitionTo(mScanModeState); - } else if (mOperationalMode == SCAN_ONLY_MODE) { - transitionTo(mScanModeState); } } break; -- cgit v1.2.3