diff options
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 18 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 31 |
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; |