From 56ee240e9e4c6a4967f08faa50cef95bfd5c2949 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 20 Mar 2017 08:13:39 -0700 Subject: WifiStateMachine: Remove networks on enter/exit ConnectMode Bug: 36189070 Test: Unit tests Test: Turned on/off wifi several times & verified that the networks are removed. Change-Id: I0faf4cffacb440746516122845667a7a7a5e6546 --- service/java/com/android/server/wifi/WifiStateMachine.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index b49268163..20f7ac5af 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4682,6 +4682,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss @Override public void enter() { + if (!mWifiNative.removeAllNetworks()) { + loge("Failed to remove networks on entering connect mode"); + } + // Let the system know that wifi is available in client mode. setWifiState(WIFI_STATE_ENABLED); @@ -4691,7 +4695,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // 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) @@ -4705,10 +4708,15 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // 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) mWifiMetrics.setWifiState(WifiMetricsProto.WifiLog.WIFI_DISABLED); + + if (!mWifiNative.removeAllNetworks()) { + loge("Failed to remove networks on exiting connect mode"); + } } @Override -- cgit v1.2.3