From e9cfb8f54b276b3b5afc72a9fb239aab48f4d86f Mon Sep 17 00:00:00 2001 From: Kai Shi Date: Wed, 2 Sep 2020 18:05:03 -0700 Subject: wifi: bug fix of network selection when autoConnect == false Ensure current network has the correct throughput prediction value even when autoConnect is disabled. Test: atest com.android.server.wifi Test: manual test to ensre the current network is still selected when autoConnect is disabled. Bug: 167409983 Change-Id: I9e6059ee057d0f17c1cdf7cafd98dceafaef7eb5 Merged-In: I9e6059ee057d0f17c1cdf7cafd98dceafaef7eb5 --- .../java/com/android/server/wifi/WifiNetworkSelector.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index 50078b628..fbbcb3174 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -462,6 +462,17 @@ public class WifiNetworkSelector { return validScanDetails; } + private ScanDetail findScanDetailForBssid(List scanDetails, + String currentBssid) { + for (ScanDetail scanDetail : scanDetails) { + ScanResult scanResult = scanDetail.getScanResult(); + if (scanResult.BSSID.equals(currentBssid)) { + return scanDetail; + } + } + return null; + } + private boolean isEnhancedOpenSupported() { if (mIsEnhancedOpenSupportedInitialized) { return mIsEnhancedOpenSupported; @@ -790,6 +801,8 @@ public class WifiNetworkSelector { WifiCandidates.Key key = new WifiCandidates.Key( ScanResultMatchInfo.fromWifiConfiguration(currentNetwork), bssid, currentNetwork.networkId); + ScanDetail scanDetail = findScanDetailForBssid(mFilteredNetworks, currentBssid); + int predictedTputMbps = (scanDetail == null) ? 0 : predictThroughput(scanDetail); wifiCandidates.add(key, currentNetwork, NetworkNominator.NOMINATOR_ID_CURRENT, wifiInfo.getRssi(), @@ -797,7 +810,7 @@ public class WifiNetworkSelector { calculateLastSelectionWeight(currentNetwork.networkId), WifiConfiguration.isMetered(currentNetwork, wifiInfo), isFromCarrierOrPrivilegedApp(currentNetwork), - 0 /* Mbps */); + predictedTputMbps); } for (NetworkNominator registeredNominator : mNominators) { localLog("About to run " + registeredNominator.getName() + " :"); -- cgit v1.2.3