diff options
author | Randy Pan <zpan@google.com> | 2016-11-10 12:09:32 -0800 |
---|---|---|
committer | Randy Pan <zpan@google.com> | 2016-11-10 12:09:32 -0800 |
commit | 6491dffa5242829ccafa59a9a7243d56beafe7e6 (patch) | |
tree | 05df4ab54979ca8a20392289581c8afde468de8b /service | |
parent | 836fdd6fdf021f058eb9f9d5dfd40e39f75d4ca0 (diff) |
WNS: less agressive roaming
When connected, WNS no longer triggers network switching if the
current network didn't show up in the scan results.
While there, fixed the comments of
WifiNetworkSelectorTest#filterOutBlacklistedBssid.
Bug: 31707128
Test: Wifi Unit Tests
Change-Id: Ieebc71151396608cd63e0b834e3f1c572e4cb557
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkSelector.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index 753b4460e..38151eab4 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -253,12 +253,14 @@ public class WifiNetworkSelector { return (network.SSID + ":" + network.networkId); } - private List<ScanDetail> filterScanResults(List<ScanDetail> scanDetails) { + private List<ScanDetail> filterScanResults(List<ScanDetail> scanDetails, boolean isConnected, + String currentBssid) { ArrayList<NetworkKey> unscoredNetworks = new ArrayList<NetworkKey>(); List<ScanDetail> validScanDetails = new ArrayList<ScanDetail>(); StringBuffer noValidSsid = new StringBuffer(); StringBuffer blacklistedBssid = new StringBuffer(); StringBuffer lowRssi = new StringBuffer(); + boolean scanResultsHaveCurrentBssid = false; for (ScanDetail scanDetail : scanDetails) { ScanResult scanResult = scanDetail.getScanResult(); @@ -268,6 +270,11 @@ public class WifiNetworkSelector { continue; } + // Check if the scan results contain the currently connected BSSID + if (scanResult.BSSID.equals(currentBssid)) { + scanResultsHaveCurrentBssid = true; + } + final String scanId = toScanId(scanResult); if (isBssidDisabled(scanResult.BSSID)) { @@ -289,6 +296,17 @@ public class WifiNetworkSelector { validScanDetails.add(scanDetail); } + // WNS listens to all single scan results. Some scan requests may not include + // the channel of the currently connected network, so the currently connected + // network won't show up in the scan results. We don't act on these scan results + // to avoid aggressive network switching which might trigger disconnection. + if (isConnected && !scanResultsHaveCurrentBssid) { + localLog("Current connected BSSID " + currentBssid + " is not in the scan results." + + " Skip network selection."); + validScanDetails.clear(); + return validScanDetails; + } + if (noValidSsid.length() != 0) { localLog("Networks filtered out due to invalid SSID: " + noValidSsid); } @@ -473,7 +491,8 @@ public class WifiNetworkSelector { updateBssidBlacklist(); // Filter out unwanted networks. - List<ScanDetail> filteredScanDetails = filterScanResults(scanDetails); + List<ScanDetail> filteredScanDetails = filterScanResults(scanDetails, connected, + currentBssid); if (filteredScanDetails.size() == 0) { return null; } |