summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Chen <jimmycmchen@google.com>2020-07-07 10:04:38 +0800
committerJimmy Chen <jimmycmchen@google.com>2020-07-07 10:48:43 +0800
commit1cc4d564f2e0901c9f44211ff60958ab0471f363 (patch)
treec298ecce5d3747392d98beaecf9e5715a4504775
parent839c296197a28377c026ae8fdd282ca02a85c2e6 (diff)
wifi: remove cached hal data on updating a network
Bug: 160551408 Test: atest FrameworksWifiTests Change-Id: I1369978c9af1bb75ff76edd3b7ba8b22f921884c
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java14
2 files changed, 17 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 678defbf2..6c31185da 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -1109,6 +1109,9 @@ public class ClientModeImpl extends StateMachine {
@Override
public void onNetworkUpdated(WifiConfiguration newConfig, WifiConfiguration oldConfig) {
+ // Clear invalid cached data.
+ mWifiNative.removeNetworkCachedData(oldConfig.networkId);
+
// Check if user/app change meteredOverride for connected network.
if (newConfig.networkId != mLastNetworkId
|| newConfig.meteredOverride == oldConfig.meteredOverride) {
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 11ee5cd7c..23726786d 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -5237,6 +5237,20 @@ public class ClientModeImplTest extends WifiBaseTest {
verify(mWifiNative, never()).removeNetworkCachedData(anyInt());
}
+ /**
+ * Verify that network cached data is cleared on updating a network.
+ */
+ @Test
+ public void testNetworkCachedDataIsClearedOnUpdatingNetwork() throws Exception {
+ WifiConfiguration oldConfig = new WifiConfiguration(mConnectedNetwork);
+ mConnectedNetwork.meteredOverride = METERED_OVERRIDE_METERED;
+
+ mConfigUpdateListenerCaptor.getValue().onNetworkUpdated(mConnectedNetwork, oldConfig);
+ mLooper.dispatchAll();
+ verify(mWifiNative).removeNetworkCachedData(eq(oldConfig.networkId));
+ }
+
+
@Test
public void testIpReachabilityLostAndRoamEventsRace() throws Exception {
connect();