summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-04-18 12:59:37 -0700
committerRoshan Pius <rpius@google.com>2019-04-18 13:22:23 -0700
commitf9ce345318244e26b173dd2fc54038bccf2388cf (patch)
tree305965bf71ccf6ab3ce3b00b2f1351a3f477c966
parentbe70cc2e5eb921f4c49ad2ca118211335df8a5dd (diff)
WifiConfigManager: Remove user choice on disableEphemeralNetwork
For ephemeral networks, disableEpehemeralNetwork() call is equivalent to the user forgetting the network (albeit for 24 hours). So, remove user choice set by that network on any other networks. Also, a minor refactor of disableEphemeralNetwork(return early on null). Bug: 130816398 Test: Manual verification Test: atest com.android.server.wifi.WifiConfigManagerTest Change-Id: I92c01b71ecad4bff3da77bc0cdaf3aa979037bd8
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java18
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java31
2 files changed, 40 insertions, 9 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 48e7e713a..af0207eee 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -2759,19 +2759,19 @@ public class WifiConfigManager {
break;
}
}
+ if (foundConfig == null) return null;
// Store the ssid & the wall clock time at which the network was disabled.
mDeletedEphemeralSsidsToTimeMap.put(ssid, mClock.getWallClockMillis());
Log.d(TAG, "Forget ephemeral SSID " + ssid + " num="
+ mDeletedEphemeralSsidsToTimeMap.size());
- if (foundConfig != null) {
- if (foundConfig.ephemeral) {
- Log.d(TAG, "Found ephemeral config in disableEphemeralNetwork: "
- + foundConfig.networkId);
- } else if (foundConfig.isPasspoint()) {
- Log.d(TAG, "Found Passpoint config in disableEphemeralNetwork: "
- + foundConfig.networkId + ", FQDN: " + foundConfig.FQDN);
- }
- }
+ if (foundConfig.ephemeral) {
+ Log.d(TAG, "Found ephemeral config in disableEphemeralNetwork: "
+ + foundConfig.networkId);
+ } else if (foundConfig.isPasspoint()) {
+ Log.d(TAG, "Found Passpoint config in disableEphemeralNetwork: "
+ + foundConfig.networkId + ", FQDN: " + foundConfig.FQDN);
+ }
+ removeConnectChoiceFromAllNetworks(foundConfig.configKey());
return foundConfig;
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 2f73ca7f0..4808dd789 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -4450,6 +4450,37 @@ public class WifiConfigManagerTest {
verifyExpiryOfTimeout(passpointNetwork);
}
+ /**
+ * Verifies the disconnection of Passpoint network using
+ * {@link WifiConfigManager#disableEphemeralNetwork(String)} and ensures that any user choice
+ * set over other networks is removed.
+ */
+ @Test
+ public void testDisablePasspointNetworkRemovesUserChoice() throws Exception {
+ WifiConfiguration passpointNetwork = WifiConfigurationTestUtil.createPasspointNetwork();
+ WifiConfiguration savedNetwork = WifiConfigurationTestUtil.createOpenNetwork();
+
+ verifyAddNetworkToWifiConfigManager(savedNetwork);
+ verifyAddPasspointNetworkToWifiConfigManager(passpointNetwork);
+
+ // Set connect choice of passpoint network over saved network.
+ assertTrue(
+ mWifiConfigManager.setNetworkConnectChoice(
+ savedNetwork.networkId, passpointNetwork.configKey(), 78L));
+
+ WifiConfiguration retrievedSavedNetwork =
+ mWifiConfigManager.getConfiguredNetwork(savedNetwork.networkId);
+ assertEquals(
+ passpointNetwork.configKey(),
+ retrievedSavedNetwork.getNetworkSelectionStatus().getConnectChoice());
+
+ // Disable the passpoint network & ensure the user choice is now removed from saved network.
+ mWifiConfigManager.disableEphemeralNetwork(passpointNetwork.SSID);
+
+ retrievedSavedNetwork = mWifiConfigManager.getConfiguredNetwork(savedNetwork.networkId);
+ assertNull(retrievedSavedNetwork.getNetworkSelectionStatus().getConnectChoice());
+ }
+
private void verifyExpiryOfTimeout(WifiConfiguration config) {
// Disable the ephemeral network.
long disableTimeMs = 546643L;