From fdd8945c3952dd368918e24c84028f19092fc663 Mon Sep 17 00:00:00 2001 From: Rebecca Silberstein Date: Tue, 8 May 2018 18:22:52 -0700 Subject: SoftApManager: no teardown when iface destroyed When softap mode shuts down due to the iface being destroyed, no need to explicitly call to teardown the iface. Bug: 79441131 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: manually toggled wifi and tethering to verify client mode came up Change-Id: I03a75b4569d4e86fd01a1ec0e144865a789a2bc9 --- service/java/com/android/server/wifi/SoftApManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java index a23d046e3..1716015a2 100644 --- a/service/java/com/android/server/wifi/SoftApManager.java +++ b/service/java/com/android/server/wifi/SoftApManager.java @@ -456,10 +456,9 @@ public class SoftApManager implements ActiveModeManager { @Override public void exit() { - if (mApInterfaceName == null) { - return; + if (mApInterfaceName != null) { + stopSoftAp(); } - stopSoftAp(); if (mSettingObserver != null) { mSettingObserver.unregister(); } @@ -531,6 +530,7 @@ public class SoftApManager implements ActiveModeManager { Log.d(TAG, "Interface was cleanly destroyed."); updateApState(WifiManager.WIFI_AP_STATE_DISABLING, WifiManager.WIFI_AP_STATE_ENABLED, 0); + mApInterfaceName = null; transitionTo(mIdleState); break; case CMD_INTERFACE_DOWN: -- cgit v1.2.3 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