summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-01-11 18:08:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-01-11 18:08:55 +0000
commitc1d7caf1a0db0068d1d3f1133a05eba4b0f592e3 (patch)
tree2f88a8b7c02ee527e7095f5d432073ad1565480d
parentd6a732981224e703416ff1787c1de912175b12ad (diff)
parent392506310ec5bf00d9908bebef4ed0a90c0150e5 (diff)
downloadandroid_frameworks_opt_net_wifi-c1d7caf1a0db0068d1d3f1133a05eba4b0f592e3.tar.gz
android_frameworks_opt_net_wifi-c1d7caf1a0db0068d1d3f1133a05eba4b0f592e3.tar.bz2
android_frameworks_opt_net_wifi-c1d7caf1a0db0068d1d3f1133a05eba4b0f592e3.zip
Merge "[DO NOT MERGE] WifiStateMachine: prevent erroneous wifi toggle" into nyc-mr2-dev
-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 d5e9d02ba..4b2496213 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);