From 5b63400e5624455eeb9ddb3fe8078e1bc5ebcd13 Mon Sep 17 00:00:00 2001 From: Rebecca Silberstein Date: Tue, 8 May 2018 23:05:18 -0700 Subject: ClientModeManager: immediately clean up state onDestroyed When onDestroyed is called in Client mode, make sure we immediately handle the network disconnect. This avoids a race in connectivity when dynamically switching between operating modes. Bug: 79400794 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: atest android.net.wifi.cts Test: manually toggled wifi tethering when wifi on and connected Test: manually toggled wifi tethering when wifi on and disconnected Test: manually toggled wifi tethering when wifi off and scan mode on Test: manually toggled wifi tethering when wifi fully disabled Change-Id: I848ba9b1f4a16687e48adb76513213a0906144c4 --- service/java/com/android/server/wifi/ClientModeManager.java | 7 +++++++ service/java/com/android/server/wifi/WifiStateMachine.java | 8 ++++++++ 2 files changed, 15 insertions(+) (limited to 'service') diff --git a/service/java/com/android/server/wifi/ClientModeManager.java b/service/java/com/android/server/wifi/ClientModeManager.java index 8aecd1ebd..f55d9d297 100644 --- a/service/java/com/android/server/wifi/ClientModeManager.java +++ b/service/java/com/android/server/wifi/ClientModeManager.java @@ -133,6 +133,13 @@ public class ClientModeManager implements ActiveModeManager { @Override public void onDestroyed(String ifaceName) { if (mClientInterfaceName != null && mClientInterfaceName.equals(ifaceName)) { + Log.d(TAG, "STA iface " + ifaceName + " was destroyed, stopping client mode"); + + // we must immediately clean up state in WSM to unregister all client mode + // related objects + // Note: onDestroyed is only called from the WSM thread + mWifiStateMachine.handleIfaceDestroyed(); + sendMessage(CMD_INTERFACE_DESTROYED); } } diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 4a0a24a21..6754da32a 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -1473,6 +1473,14 @@ public class WifiStateMachine extends StateMachine { } } + /** + * When the underlying interface is destroyed, we must immediately tell connectivity service to + * mark network agent as disconnected and stop the ip client. + */ + public void handleIfaceDestroyed() { + handleNetworkDisconnect(); + } + /** * TODO: doc */ -- cgit v1.2.3