diff options
author | Ningyuan Wang <nywang@google.com> | 2017-09-25 14:46:38 -0700 |
---|---|---|
committer | Ningyuan Wang <nywang@google.com> | 2017-09-29 09:58:28 -0700 |
commit | 2f5d10a29d17781e903eeddedb4a547e62c55524 (patch) | |
tree | 19eae9d98dafe28929f51b738a182807db994170 | |
parent | 75dc8a494a00a37d19772220fdc639abc05ea3d0 (diff) | |
download | android_frameworks_opt_net_wifi-2f5d10a29d17781e903eeddedb4a547e62c55524.tar.gz android_frameworks_opt_net_wifi-2f5d10a29d17781e903eeddedb4a547e62c55524.tar.bz2 android_frameworks_opt_net_wifi-2f5d10a29d17781e903eeddedb4a547e62c55524.zip |
Cherry-pick: Remove temporarily disabled networks from PNO list
This also adds corresponding unit tests.
Bug: 66910426
Test: compile, unit tests
Merged-In: I58f7061887ebc1dd78d3941218653460f80abb1f
Change-Id: I58f7061887ebc1dd78d3941218653460f80abb1f
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 5 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 39 |
2 files changed, 42 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 75b39b261..06b53be85 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -2330,12 +2330,13 @@ public class WifiConfigManager { public List<WifiScanner.PnoSettings.PnoNetwork> retrievePnoNetworkList() { List<WifiScanner.PnoSettings.PnoNetwork> pnoList = new ArrayList<>(); List<WifiConfiguration> networks = new ArrayList<>(getInternalConfiguredNetworks()); - // Remove any permanently disabled networks. + // Remove any permanently or temporarily disabled networks. Iterator<WifiConfiguration> iter = networks.iterator(); while (iter.hasNext()) { WifiConfiguration config = iter.next(); if (config.ephemeral || config.isPasspoint() - || config.getNetworkSelectionStatus().isNetworkPermanentlyDisabled()) { + || config.getNetworkSelectionStatus().isNetworkPermanentlyDisabled() + || config.getNetworkSelectionStatus().isNetworkTemporaryDisabled()) { iter.remove(); } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index d14c8fc9f..7ce53629b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -1519,6 +1519,45 @@ public class WifiConfigManagerTest { } /** + * Verifies that the list of PNO networks does not contain any permanently or temporarily + * disabled networks. + * {@link WifiConfigManager#retrievePnoNetworkList()}. + */ + @Test + public void testRetrievePnoListDoesNotContainDisabledNetworks() throws Exception { + // Create and add 2 networks. + WifiConfiguration network1 = WifiConfigurationTestUtil.createEapNetwork(); + WifiConfiguration network2 = WifiConfigurationTestUtil.createPskNetwork(); + + NetworkUpdateResult result1 = verifyAddNetworkToWifiConfigManager(network1); + NetworkUpdateResult result2 = verifyAddNetworkToWifiConfigManager(network2); + + // Enable all of them. + verifyUpdateNetworkSelectionStatus( + result1.getNetworkId(), NetworkSelectionStatus.NETWORK_SELECTION_ENABLE, 0); + verifyUpdateNetworkSelectionStatus( + result2.getNetworkId(), NetworkSelectionStatus.NETWORK_SELECTION_ENABLE, 0); + + // Set network1 to temporarily disabled. The threshold for association rejection is 5, so + // disable it 5 times to actually mark it temporarily disabled. + int assocRejectReason = NetworkSelectionStatus.DISABLED_ASSOCIATION_REJECTION; + int assocRejectThreshold = + WifiConfigManager.NETWORK_SELECTION_DISABLE_THRESHOLD[assocRejectReason]; + for (int i = 1; i <= assocRejectThreshold; i++) { + verifyUpdateNetworkSelectionStatus(result1.getNetworkId(), assocRejectReason, i); + } + + // Set network 2 to permanently disabled. + verifyUpdateNetworkSelectionStatus( + result2.getNetworkId(), NetworkSelectionStatus.DISABLED_BY_WIFI_MANAGER, 0); + + // Retrieve the Pno network list & verify both networks are not included. + List<WifiScanner.PnoSettings.PnoNetwork> pnoNetworks = + mWifiConfigManager.retrievePnoNetworkList(); + assertEquals(0, pnoNetworks.size()); + } + + /** * Verifies the linking of networks when they have the same default GW Mac address in * {@link WifiConfigManager#getOrCreateScanDetailCacheForNetwork(WifiConfiguration)}. */ |