From 6491dffa5242829ccafa59a9a7243d56beafe7e6 Mon Sep 17 00:00:00 2001 From: Randy Pan Date: Thu, 10 Nov 2016 12:09:32 -0800 Subject: 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 --- .../android/server/wifi/WifiNetworkSelector.java | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'service') 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 filterScanResults(List scanDetails) { + private List filterScanResults(List scanDetails, boolean isConnected, + String currentBssid) { ArrayList unscoredNetworks = new ArrayList(); List validScanDetails = new ArrayList(); 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 filteredScanDetails = filterScanResults(scanDetails); + List filteredScanDetails = filterScanResults(scanDetails, connected, + currentBssid); if (filteredScanDetails.size() == 0) { return null; } -- cgit v1.2.3