diff options
author | Randy Pan <zpan@google.com> | 2016-04-26 16:05:59 -0700 |
---|---|---|
committer | Randy Pan <zpan@google.com> | 2016-04-26 16:32:58 -0700 |
commit | 1f4fa946d229906500f381fa5561821fba164ba8 (patch) | |
tree | 00f2e4b298bb4639841d1bbe31817928e6d6d981 /service | |
parent | c8a21e495dfaa5c44e87fda330621a1ed6c8aace (diff) |
Fix setEnableAutoJoinWhenAssociated() handling
Move the execution of this method to the thread of
WifiStateMachine to address a potential WifiConnectivityManager
concurrent access issue.
While there, remove a dead method.
Bug: 28369823
Change-Id: I49f424637ee6897495daedbf4b1cc06477e78798
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 869a09f43..d464fdb55 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -255,12 +255,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss } } } - public void registerNetworkDisabled(int netId) { - // Initiate a connectivity scan - if (mWifiConnectivityManager != null) { - mWifiConnectivityManager.forceConnectivityScan(); - } - } // Testing various network disconnect cases by sending lots of spurious // disconnect to supplicant @@ -800,6 +794,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss /* Enable/Disable WifiConnectivityManager */ static final int CMD_ENABLE_WIFI_CONNECTIVITY_MANAGER = BASE + 166; + /* Enable/Disable AutoJoin when associated */ + static final int CMD_ENABLE_AUTOJOIN_WHEN_ASSOCIATED = BASE + 167; + /** * Used to handle messages bounced between WifiStateMachine and IpManager. */ @@ -1360,14 +1357,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss return mWifiConfigManager.mAlwaysEnableScansWhileAssociated.get(); } + /* + * Dynamically turn on/off if switching networks while connected is allowd. + */ public boolean setEnableAutoJoinWhenAssociated(boolean enabled) { - boolean old_state = mWifiConfigManager.getEnableAutoJoinWhenAssociated(); - mWifiConfigManager.setEnableAutoJoinWhenAssociated(enabled); - if (!old_state && enabled && mScreenOn && getCurrentState() == mConnectedState) { - if (mWifiConnectivityManager != null) { - mWifiConnectivityManager.forceConnectivityScan(); - } - } + sendMessage(CMD_ENABLE_AUTOJOIN_WHEN_ASSOCIATED, enabled ? 1 : 0); return true; } @@ -4850,6 +4844,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mWifiConnectivityManager.enable(message.arg1 == 1 ? true : false); } break; + case CMD_ENABLE_AUTOJOIN_WHEN_ASSOCIATED: + final boolean allowed = (message.arg1 > 0); + boolean old_state = mWifiConfigManager.getEnableAutoJoinWhenAssociated(); + mWifiConfigManager.setEnableAutoJoinWhenAssociated(allowed); + if (!old_state && allowed && mScreenOn + && getCurrentState() == mConnectedState) { + if (mWifiConnectivityManager != null) { + mWifiConnectivityManager.forceConnectivityScan(); + } + } + break; default: return NOT_HANDLED; } |