diff options
3 files changed, 17 insertions, 0 deletions
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 @@ -1474,6 +1474,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 */ public void setOperationalMode(int mode, String ifaceName) { diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeManagerTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeManagerTest.java index fbdcb7ba3..b04caf54d 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeManagerTest.java @@ -294,6 +294,7 @@ public class ClientModeManagerTest { mInterfaceCallbackCaptor.getValue().onDestroyed(TEST_INTERFACE_NAME); mLooper.dispatchAll(); verifyNotificationsForCleanShutdown(WIFI_STATE_ENABLED); + verify(mWifiStateMachine).handleIfaceDestroyed(); } /** @@ -318,5 +319,6 @@ public class ClientModeManagerTest { mLooper.dispatchAll(); verifyNoMoreInteractions(mListener); + verify(mWifiStateMachine, never()).handleIfaceDestroyed(); } } |