summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2020-03-13 18:07:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-13 18:07:28 +0000
commitc5a3615638b731f2bff115f9d376af3b107662e0 (patch)
treebb746d8c4bc039a50b2a2029dc683f48599a0a96
parenta6ae5dbcd85ed2336d0ec5a35de96df9b290bf14 (diff)
parent9094b84f4ce8e6340f8ab7a848e977ff16a19663 (diff)
Merge "[Wifi] Clear connect choice on autojoin disable" into rvc-dev
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java40
2 files changed, 44 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 57fe78c1a..c4cb51c0b 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -1892,6 +1892,10 @@ public class WifiConfigManager {
}
config.allowAutojoin = choice;
+ if (!choice) {
+ removeConnectChoiceFromAllNetworks(config.getKey());
+ clearNetworkConnectChoice(config.networkId);
+ }
sendConfiguredNetworkChangedBroadcast(config, WifiManager.CHANGE_REASON_CONFIG_CHANGE);
if (!config.ephemeral) {
saveToStore(true);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index d72e1c168..82addc2b3 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -3784,6 +3784,46 @@ public class WifiConfigManagerTest extends WifiBaseTest {
}
/**
+ * Disabling autojoin should clear associated connect choice links.
+ */
+ @Test
+ public void testDisableAutojoinRemovesConnectChoice() throws Exception {
+ WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
+ WifiConfiguration network2 = WifiConfigurationTestUtil.createPskNetwork();
+ WifiConfiguration network3 = WifiConfigurationTestUtil.createPskNetwork();
+ verifyAddNetworkToWifiConfigManager(network1);
+ verifyAddNetworkToWifiConfigManager(network2);
+ verifyAddNetworkToWifiConfigManager(network3);
+
+ // Set connect choice of network 2 over network 1 and network 3.
+ assertTrue(
+ mWifiConfigManager.setNetworkConnectChoice(
+ network1.networkId, network2.getKey()));
+ assertTrue(
+ mWifiConfigManager.setNetworkConnectChoice(
+ network3.networkId, network2.getKey()));
+
+ WifiConfiguration retrievedNetwork =
+ mWifiConfigManager.getConfiguredNetwork(network3.networkId);
+ assertEquals(
+ network2.getKey(),
+ retrievedNetwork.getNetworkSelectionStatus().getConnectChoice());
+
+ // Disable network 3
+ assertTrue(mWifiConfigManager.allowAutojoin(network3.networkId, false));
+ // Ensure that the connect choice on network 3 is removed.
+ retrievedNetwork = mWifiConfigManager.getConfiguredNetwork(network3.networkId);
+ assertEquals(
+ null,
+ retrievedNetwork.getNetworkSelectionStatus().getConnectChoice());
+ // Ensure that the connect choice on network 1 is not removed.
+ retrievedNetwork = mWifiConfigManager.getConfiguredNetwork(network1.networkId);
+ assertEquals(
+ network2.getKey(),
+ retrievedNetwork.getNetworkSelectionStatus().getConnectChoice());
+ }
+
+ /**
* Verifies that all the ephemeral and passpoint networks are removed when
* {@link WifiConfigManager#removeAllEphemeralOrPasspointConfiguredNetworks()} is invoked.
*/