diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-01-04 14:13:05 -0800 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2017-01-04 23:21:58 -0800 |
commit | 48bba582a6735feae2d0834011cd30d9bc2d1100 (patch) | |
tree | a65d6cb5dd4020c5a0782de9636da6b2587f8adc /service | |
parent | 02938a0a735da7fafaaed84e31e1aa93cdf80a56 (diff) |
WifiStateMachine: erroneous wifi enabled updates
Update WifiStateMachine to only broadcast wifi availability when in
client mode. Prior to this fix, wifi would briefly enable/disable when
exiting airplane mode when location scans are enabled and wifi
(client mode) should be disabled.
This CL additionally fixes an issue in WifiController that works around
an assumption in WifiStateMachine that the default mode after supplicant
has started is client mode. The mode is now set before starting
supplicant so we do not erroneously enter client mode and then
immediately switch to scan only mode.
This CL addresses three known issues where wifi flickers on/off:
1 - wifi disabled, enable wifi location scans
2 - location scans enabled, wifi disabled, enter and exit airplane mode
3 - location scans enabled, wifi disabled, enter airplane mode, enable
and disable wifi, exit airplane mode
Bug: 28336982
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: frameworks/base/wifi/tests/runtests.sh
Test: manually confirmed wifi does not flash on after airplane mode
Change-Id: I9a1d4c7cf00e78c09e3f28e820e058c72c5114b9
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiController.java | 4 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 21 |
2 files changed, 18 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiController.java b/service/java/com/android/server/wifi/WifiController.java index 3e12b3418..6736213ca 100644 --- a/service/java/com/android/server/wifi/WifiController.java +++ b/service/java/com/android/server/wifi/WifiController.java @@ -581,8 +581,10 @@ public class WifiController extends StateMachine { @Override public void enter() { - mWifiStateMachine.setSupplicantRunning(true); + // need to set the mode before starting supplicant because WSM will assume we are going + // in to client mode mWifiStateMachine.setOperationalMode(WifiStateMachine.SCAN_ONLY_WITH_WIFI_OFF_MODE); + mWifiStateMachine.setSupplicantRunning(true); // Supplicant can't restart right away, so not the time we switched off mDisabledTimestamp = SystemClock.elapsedRealtime(); mDeferredEnableSerialNumber++; diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 4566d62e1..540fbd827 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4068,7 +4068,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss switch(message.what) { case WifiMonitor.SUP_CONNECTION_EVENT: if (mVerboseLoggingEnabled) log("Supplicant connection established"); - setWifiState(WIFI_STATE_ENABLED); + mSupplicantRestartCount = 0; /* Reset the supplicant state to indicate the supplicant * state is not known at this time */ @@ -4125,10 +4125,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss logd("SupplicantStartedState enter"); } - /* Wifi is available as long as we have a connection to supplicant */ - mNetworkInfo.setIsAvailable(true); - if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo); - int defaultInterval = mContext.getResources().getInteger( R.integer.config_wifi_supplicant_scan_interval); @@ -4169,7 +4165,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss * driver are changed to reduce interference with bluetooth */ mWifiNative.setBluetoothCoexistenceScanMode(mBluetoothConnectionActive); - /* initialize network state */ + // initialize network state setNetworkDetailedState(DetailedState.DISCONNECTED); // Disable legacy multicast filtering, which on some chipsets defaults to enabled. @@ -4743,6 +4739,16 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss @Override public void enter() { + // Let the system know that wifi is available in client mode. + setWifiState(WIFI_STATE_ENABLED); + + mNetworkInfo.setIsAvailable(true); + if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo); + + // initialize network state + setNetworkDetailedState(DetailedState.DISCONNECTED); + + // Inform WifiConnectivityManager that Wifi is enabled mWifiConnectivityManager.setWifiEnabled(true); // Inform metrics that Wifi is Enabled (but not yet connected) @@ -4751,6 +4757,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss @Override public void exit() { + // Let the system know that wifi is not available since we are exiting client mode. + mNetworkInfo.setIsAvailable(false); + if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo); // Inform WifiConnectivityManager that Wifi is disabled mWifiConnectivityManager.setWifiEnabled(false); // Inform metrics that Wifi is being disabled (Toggled, airplane enabled, etc) |