summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java10
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java4
2 files changed, 13 insertions, 1 deletions
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
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 4a331e3cb..5755d9c4e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -820,6 +820,7 @@ public class WifiStateMachineTest {
mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE);
mLooper.dispatchAll();
+ verify(mWifiNative).removeAllNetworks();
mLooper.startAutoDispatch();
assertTrue(mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true));
@@ -857,6 +858,7 @@ public class WifiStateMachineTest {
mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE);
mLooper.dispatchAll();
+ verify(mWifiNative).removeAllNetworks();
mLooper.startAutoDispatch();
assertTrue(mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true));
@@ -893,6 +895,7 @@ public class WifiStateMachineTest {
mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE);
mLooper.dispatchAll();
+ verify(mWifiNative).removeAllNetworks();
mLooper.startAutoDispatch();
assertFalse(mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true));
@@ -915,6 +918,7 @@ public class WifiStateMachineTest {
mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE);
mLooper.dispatchAll();
+ verify(mWifiNative).removeAllNetworks();
mLooper.startAutoDispatch();
mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true);