summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-04-16 09:40:26 -0700
committerRoshan Pius <rpius@google.com>2018-05-01 17:35:05 -0700
commitff16c9e2d8bf417d72d3d5d82d6e3719858ce36c (patch)
tree5b4e1e85b636b0e7c836928358c9cf05a5df999e
parentd47fd3791387eded068f6554c0dfdaa0ee5ceef2 (diff)
WifiStateMachine: Shutdown IpClient when exiting client mode
We should explicitly shutdown the previous IpClient instance when we exit client mode to cleanup its internal registrations. Bug: 77999594 Test: Unit tests Test: WifiManagerTest ACTS tests Change-Id: Ic0650c40f5e7544b886bc774010dd277cfd9d739
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java1
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java12
2 files changed, 13 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 10b55b9d5..7781f1253 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -3812,6 +3812,7 @@ public class WifiStateMachine extends StateMachine {
mIsRunning = false;
updateBatteryWorkSource(null);
+ if (mIpClient != null) mIpClient.shutdown();
mNetworkInfo.setIsAvailable(false);
if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo);
mCountryCode.setReadyForChange(false);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 1907c56b7..6fa9a2ff6 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -2451,4 +2451,16 @@ public class WifiStateMachineTest {
mWsm.setWifiStateForApiCalls(invalidStatePositive);
assertEquals(WifiManager.WIFI_STATE_DISABLED, mWsm.syncGetWifiState());
}
+
+ /**
+ * Verify that IPClient instance is shutdown when wifi is disabled.
+ */
+ @Test
+ public void verifyIpClientShutdownWhenDisabled() throws Exception {
+ loadComponentsInStaMode();
+
+ mWsm.setOperationalMode(WifiStateMachine.DISABLED_MODE, null);
+ mLooper.dispatchAll();
+ verify(mIpClient).shutdown();
+ }
}