summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRandy Pan <zpan@google.com>2016-10-10 21:26:19 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-10-10 21:26:19 +0000
commit818ebf58946a7235aa5d54e9afce9e9d22b945e3 (patch)
tree65b04734bcaf86ebd726fe011b3776f4a8effc69 /service
parent6a5e90ea3e9054ad67f74483215d37cd6d712675 (diff)
parent0b9b32c53a83dea56417bda7bc9ddc1dc1e4222e (diff)
ExternalScoreEvaluator: factor in active network
am: 0b9b32c53a Change-Id: I9cdaad1221048b6494ffef562d80eb8b68068b24
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ExternalScoreEvaluator.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/ExternalScoreEvaluator.java b/service/java/com/android/server/wifi/ExternalScoreEvaluator.java
index 03d89b040..07fb95cf9 100644
--- a/service/java/com/android/server/wifi/ExternalScoreEvaluator.java
+++ b/service/java/com/android/server/wifi/ExternalScoreEvaluator.java
@@ -24,6 +24,7 @@ import android.net.WifiKey;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.os.Process;
+import android.text.TextUtils;
import android.util.LocalLog;
import android.util.Log;
import android.util.Pair;
@@ -140,13 +141,17 @@ public class ExternalScoreEvaluator implements WifiNetworkSelector.NetworkEvalua
* Returns the available external network score or null if no score is available.
*
* @param scanResult The scan result of the network to score.
+ * @param scoreCache Wifi network score cache.
+ * @param active Flag which indicates whether this is the currently connected network.
* @return A valid external score if one is available or NULL.
*/
@Nullable
- Integer getNetworkScore(ScanResult scanResult, WifiNetworkScoreCache scoreCache) {
+ Integer getNetworkScore(ScanResult scanResult, WifiNetworkScoreCache scoreCache,
+ boolean active) {
if (scoreCache != null && scoreCache.isScoredNetwork(scanResult)) {
- int score = scoreCache.getNetworkScore(scanResult, false);
- localLog(WifiNetworkSelector.toScanId(scanResult) + " has score: " + score);
+ int score = scoreCache.getNetworkScore(scanResult, active);
+ localLog(WifiNetworkSelector.toScanId(scanResult) + " has score: " + score
+ + " active network: " + active);
return score;
}
return null;
@@ -247,7 +252,11 @@ public class ExternalScoreEvaluator implements WifiNetworkSelector.NetworkEvalua
if (isPotentialEphemeralNetwork(associatedConfigs)) {
if (untrustedNetworkAllowed) {
if (!mWifiConfigManager.wasEphemeralNetworkDeleted(scanResult.SSID)) {
- Integer score = getNetworkScore(scanResult, mScoreCache);
+ // Ephemeral network has either one WifiConfiguration or none yet.
+ // Checking BSSID is sufficient to determine whether this is the
+ // currently connected network.
+ boolean active = TextUtils.equals(currentBssid, scanResult.BSSID);
+ Integer score = getNetworkScore(scanResult, mScoreCache, active);
externalScoreTracker.trackUntrustedCandidate(score, scanResult);
if (connectableNetworks != null) {
connectableNetworks.add(Pair.create(scanDetail,
@@ -278,7 +287,9 @@ public class ExternalScoreEvaluator implements WifiNetworkSelector.NetworkEvalua
if (network.useExternalScores) {
localLog("Network " + WifiNetworkSelector.toNetworkString(network)
+ " uses external score");
- Integer score = getNetworkScore(scanResult, mScoreCache);
+ boolean active = currentNetwork != null && currentNetwork == network
+ && TextUtils.equals(currentBssid, scanResult.BSSID);
+ Integer score = getNetworkScore(scanResult, mScoreCache, active);
externalScoreTracker.trackSavedCandidate(score, network, scanResult);
if (connectableNetworks != null) {
connectableNetworks.add(Pair.create(scanDetail, network));