diff options
author | Rebecca Silberstein <silberst@google.com> | 2018-06-27 16:35:57 -0700 |
---|---|---|
committer | Michael Plass <mplass@google.com> | 2018-07-03 10:47:03 -0700 |
commit | 2b0f742024b40e59c791b7b9831cc078672d2722 (patch) | |
tree | 0ee8171b14c3afdc29c3c7f12108d356189d064b /service | |
parent | d5c6cd7fae3384f351b51f129d6820e84ca9ba16 (diff) |
WifiController: merge client mode related states
With the refactor, we can simplify the state machine in WifiController
by merging DeviceActiveState into StaEnabledState.
Bug: 79209870
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: verified recovery path still working after killing supplicant
Change-Id: I0f4af6a68cbafba63dadc820c0e986e32f5e9846
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiController.java | 69 |
1 files changed, 25 insertions, 44 deletions
diff --git a/service/java/com/android/server/wifi/WifiController.java b/service/java/com/android/server/wifi/WifiController.java index ee436bba6..dd96828a3 100644 --- a/service/java/com/android/server/wifi/WifiController.java +++ b/service/java/com/android/server/wifi/WifiController.java @@ -93,7 +93,6 @@ public class WifiController extends StateMachine { private StaEnabledState mStaEnabledState = new StaEnabledState(); private StaDisabledState mStaDisabledState = new StaDisabledState(); private StaDisabledWithScanState mStaDisabledWithScanState = new StaDisabledWithScanState(); - private DeviceActiveState mDeviceActiveState = new DeviceActiveState(); private EcmState mEcmState = new EcmState(); private ScanOnlyModeManager.Listener mScanOnlyModeCallback = new ScanOnlyCallback(); @@ -114,7 +113,6 @@ public class WifiController extends StateMachine { addState(mDefaultState); addState(mStaDisabledState, mDefaultState); addState(mStaEnabledState, mDefaultState); - addState(mDeviceActiveState, mStaEnabledState); addState(mStaDisabledWithScanState, mDefaultState); addState(mEcmState, mDefaultState); // CHECKSTYLE:ON IndentationCheck @@ -283,7 +281,7 @@ public class WifiController extends StateMachine { } else { log("Airplane mode disabled, determine next state"); if (mSettingsStore.isWifiToggleEnabled()) { - transitionTo(mDeviceActiveState); + transitionTo(mStaEnabledState); } else if (checkScanOnlyModeAvailable()) { transitionTo(mStaDisabledWithScanState); } @@ -299,7 +297,7 @@ public class WifiController extends StateMachine { case CMD_AP_STOPPED: log("SoftAp mode disabled, determine next state"); if (mSettingsStore.isWifiToggleEnabled()) { - transitionTo(mDeviceActiveState); + transitionTo(mStaEnabledState); } else if (checkScanOnlyModeAvailable()) { transitionTo(mStaDisabledWithScanState); } @@ -339,7 +337,7 @@ public class WifiController extends StateMachine { mHaveDeferredEnable = !mHaveDeferredEnable; break; } - transitionTo(mDeviceActiveState); + transitionTo(mStaEnabledState); } else if (checkScanOnlyModeAvailable()) { // only go to scan mode if we aren't in airplane mode if (mSettingsStore.isAirplaneModeOn()) { @@ -376,7 +374,7 @@ public class WifiController extends StateMachine { if (mSettingsStore.isWifiToggleEnabled()) { // wifi is currently disabled but the toggle is on, must have had an // interface down before the recovery triggered - transitionTo(mDeviceActiveState); + transitionTo(mStaEnabledState); break; } else if (checkScanOnlyModeAvailable()) { transitionTo(mStaDisabledWithScanState); @@ -412,6 +410,7 @@ public class WifiController extends StateMachine { @Override public void enter() { log("StaEnabledState.enter()"); + mActiveModeWarden.enterClientMode(); } @Override @@ -457,9 +456,25 @@ public class WifiController extends StateMachine { // Client mode stopped. head to Disabled to wait for next command transitionTo(mStaDisabledState); break; + case CMD_RECOVERY_RESTART_WIFI: + final String bugTitle; + final String bugDetail; + if (msg.arg1 < SelfRecovery.REASON_STRINGS.length && msg.arg1 >= 0) { + bugDetail = SelfRecovery.REASON_STRINGS[msg.arg1]; + bugTitle = "Wi-Fi BugReport: " + bugDetail; + } else { + bugDetail = ""; + bugTitle = "Wi-Fi BugReport"; + } + if (msg.arg1 != SelfRecovery.REASON_LAST_RESORT_WATCHDOG) { + (new Handler(mClientModeImplLooper)).post(() -> { + mClientModeImpl.takeBugReport(bugTitle, bugDetail); + }); + } + // after the bug report trigger, more handling needs to be done + return NOT_HANDLED; default: return NOT_HANDLED; - } return HANDLED; } @@ -495,7 +510,7 @@ public class WifiController extends StateMachine { mHaveDeferredEnable = !mHaveDeferredEnable; break; } - transitionTo(mDeviceActiveState); + transitionTo(mStaEnabledState); } break; case CMD_SCAN_ALWAYS_MODE_CHANGED: @@ -559,7 +574,7 @@ public class WifiController extends StateMachine { */ private State getNextWifiState() { if (mSettingsStore.getWifiSavedState() == WifiSettingsStore.WIFI_ENABLED) { - return mDeviceActiveState; + return mStaEnabledState; } if (checkScanOnlyModeAvailable()) { @@ -642,7 +657,7 @@ public class WifiController extends StateMachine { if (exitEcm) { if (mSettingsStore.isWifiToggleEnabled()) { - transitionTo(mDeviceActiveState); + transitionTo(mStaEnabledState); } else if (checkScanOnlyModeAvailable()) { transitionTo(mStaDisabledWithScanState); } else { @@ -651,38 +666,4 @@ public class WifiController extends StateMachine { } } } - - /** - * Parent: StaEnabledState - * - * TODO (b/79209870): merge DeviceActiveState and StaEnabledState into a single state - */ - class DeviceActiveState extends State { - @Override - public void enter() { - mActiveModeWarden.enterClientMode(); - } - - @Override - public boolean processMessage(Message msg) { - if (msg.what == CMD_RECOVERY_RESTART_WIFI) { - final String bugTitle; - final String bugDetail; - if (msg.arg1 < SelfRecovery.REASON_STRINGS.length && msg.arg1 >= 0) { - bugDetail = SelfRecovery.REASON_STRINGS[msg.arg1]; - bugTitle = "Wi-Fi BugReport: " + bugDetail; - } else { - bugDetail = ""; - bugTitle = "Wi-Fi BugReport"; - } - if (msg.arg1 != SelfRecovery.REASON_LAST_RESORT_WATCHDOG) { - (new Handler(mClientModeImplLooper)).post(() -> { - mClientModeImpl.takeBugReport(bugTitle, bugDetail); - }); - } - return NOT_HANDLED; - } - return NOT_HANDLED; - } - } } |