diff options
author | lesl <lesl@google.com> | 2020-08-05 22:16:40 +0800 |
---|---|---|
committer | Les Lee <lesl@google.com> | 2020-08-10 02:03:06 +0000 |
commit | 636b3519ba904a53f52076ab8eca8d24b9311142 (patch) | |
tree | 716ea57c8b211d74a10c26e8122acef512730772 | |
parent | 3d21e9bec522725367443361d4a027280d66e5b0 (diff) |
wifi: Move stop softap flow to looper thread
WifiService will change state to enabling before SoftApManager running.
If stop cmd executed(main thread) before start cmd(looper thread).
It will cause state stuck in enabling
Bug: 162714979
Test: atest FrameworksWifiTests
Change-Id: Ibd309b669d10f917fbd3f6d3c1d9de6258cedac7
Merged-In: Ibd309b669d10f917fbd3f6d3c1d9de6258cedac7
-rw-r--r-- | service/java/com/android/server/wifi/SoftApManager.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java index 9ef52e796..b321a78a1 100644 --- a/service/java/com/android/server/wifi/SoftApManager.java +++ b/service/java/com/android/server/wifi/SoftApManager.java @@ -221,16 +221,7 @@ public class SoftApManager implements ActiveModeManager { public void stop() { Log.d(TAG, " currentstate: " + getCurrentStateName()); mTargetRole = ROLE_UNSPECIFIED; - if (mApInterfaceName != null) { - if (mIfaceIsUp) { - updateApState(WifiManager.WIFI_AP_STATE_DISABLING, - WifiManager.WIFI_AP_STATE_ENABLED, 0); - } else { - updateApState(WifiManager.WIFI_AP_STATE_DISABLING, - WifiManager.WIFI_AP_STATE_ENABLING, 0); - } - } - mStateMachine.quitNow(); + mStateMachine.sendMessage(SoftApStateMachine.CMD_STOP); } @Override @@ -517,6 +508,7 @@ public class SoftApManager implements ActiveModeManager { private class SoftApStateMachine extends StateMachine { // Commands for the state machine. public static final int CMD_START = 0; + public static final int CMD_STOP = 1; public static final int CMD_FAILURE = 2; public static final int CMD_INTERFACE_STATUS_CHANGED = 3; public static final int CMD_ASSOCIATED_STATIONS_CHANGED = 4; @@ -574,6 +566,9 @@ public class SoftApManager implements ActiveModeManager { @Override public boolean processMessage(Message message) { switch (message.what) { + case CMD_STOP: + mStateMachine.quitNow(); + break; case CMD_START: mApInterfaceName = mWifiNative.setupInterfaceForSoftApMode( mWifiNativeInterfaceCallback); @@ -908,6 +903,16 @@ public class SoftApManager implements ActiveModeManager { boolean isUp = message.arg1 == 1; onUpChanged(isUp); break; + case CMD_STOP: + if (mIfaceIsUp) { + updateApState(WifiManager.WIFI_AP_STATE_DISABLING, + WifiManager.WIFI_AP_STATE_ENABLED, 0); + } else { + updateApState(WifiManager.WIFI_AP_STATE_DISABLING, + WifiManager.WIFI_AP_STATE_ENABLING, 0); + } + transitionTo(mIdleState); + break; case CMD_START: // Already started, ignore this command. break; |