summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-01-04 23:00:22 -0800
committerRebecca Silberstein <silberst@google.com>2017-01-04 23:15:30 -0800
commit392506310ec5bf00d9908bebef4ed0a90c0150e5 (patch)
tree3f2c59ae2ed8c809b91b4cc68071bb6695386e6b
parenta0519deb15342a5eeb82b27db94a305d5e1d6990 (diff)
[DO NOT MERGE] WifiStateMachine: prevent erroneous wifi toggle
The icon for wifi toggles on/off quickly when transitioning between states if location scans are enabled. This is due to two errors: 1 - WifiStateMachine sends the wifi enabled broadcast before wifi has entered client mode. 2 - WifiStateMachine assumes it is entering client mode if it has not been told otherwise. This CL works around the assumptions in WifiStateMachine and avoids sending the wifi enabled broadcast when it should be going in to scan mode and not client mode. Bug: 28336982 Test: verified state transitions manually Test: runtest frameworks-wifi Change-Id: I5e34ee4f0ef90668ecc97f5d6d726444fd08ffb3
-rw-r--r--service/java/com/android/server/wifi/WifiController.java4
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java22
2 files changed, 18 insertions, 8 deletions
diff --git a/service/java/com/android/server/wifi/WifiController.java b/service/java/com/android/server/wifi/WifiController.java
index bfbf44906..67a7a423e 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);
mWifiStateMachine.setDriverStart(true);
// Supplicant can't restart right away, so not the time we switched off
mDisabledTimestamp = SystemClock.elapsedRealtime();
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 9cc26b108..73780b8b7 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -4459,7 +4459,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
switch(message.what) {
case WifiMonitor.SUP_CONNECTION_EVENT:
if (DBG) 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 */
@@ -4517,10 +4517,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
class SupplicantStartedState extends State {
@Override
public void 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);
@@ -5392,18 +5388,30 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
@Override
public void enter() {
+ // Let the system know that wifi is enabled
+ 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
if (mWifiConnectivityManager != null) {
mWifiConnectivityManager.setWifiEnabled(true);
}
// Inform metrics that Wifi is Enabled (but not yet connected)
mWifiMetrics.setWifiState(WifiMetricsProto.WifiLog.WIFI_DISCONNECTED);
-
-
}
@Override
public void exit() {
+ // Let the system know that wifi is not available since we are exiting client mode.
+ setWifiState(WIFI_STATE_DISABLED);
+ mNetworkInfo.setIsAvailable(false);
+ if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo);
+
// Inform WifiConnectivityManager that Wifi is disabled
if (mWifiConnectivityManager != null) {
mWifiConnectivityManager.setWifiEnabled(false);