summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2018-05-09 20:48:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-05-09 20:48:21 +0000
commit2c88f670aad308c91801c7bfeabbce8d78a506fe (patch)
tree96fdc82c8a5686304e1e10258e8ffd0e38d8009b
parent1a0ff86a3520e9b79ded4746171a883a7f72fcdf (diff)
parent5b63400e5624455eeb9ddb3fe8078e1bc5ebcd13 (diff)
Merge changes I848ba9b1,I03a75b45 into pi-dev
* changes: ClientModeManager: immediately clean up state onDestroyed SoftApManager: no teardown when iface destroyed
-rw-r--r--service/java/com/android/server/wifi/ClientModeManager.java7
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java6
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java8
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeManagerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java2
5 files changed, 21 insertions, 4 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/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:
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 18241d57a..bca20e43d 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -1440,6 +1440,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();
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index 759d8dd0b..7534f78ce 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -498,7 +498,7 @@ public class SoftApManagerTest {
order.verify(mContext).sendStickyBroadcastAsUser(intentCaptor.capture(),
eq(UserHandle.ALL));
checkApStateChangedBroadcast(intentCaptor.getValue(), WIFI_AP_STATE_DISABLED,
- WIFI_AP_STATE_DISABLING, HOTSPOT_NO_ERROR, TEST_INTERFACE_NAME,
+ WIFI_AP_STATE_DISABLING, HOTSPOT_NO_ERROR, null,
softApModeConfig.getTargetMode());
}