summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRandy Pan <zpan@google.com>2016-10-10 22:33:39 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-10-10 22:33:39 +0000
commitc6bb020ed7716acea6d143caef04ff082c4005ec (patch)
tree00f9e56a469a0313135195380d2210d33ee0ad8f /service
parent20bc8bcbf274c74eef06fe2b8ecf5c5fecdf23a3 (diff)
parent67075d5538cbed1102f221448eb962d280c5015d (diff)
ExternalScoreEvaluator: factor in active network am: 0b9b32c53a am: 818ebf5894
am: 67075d5538 Change-Id: I3bb9a70a537cd9c564c9e7b253a72a18ae146e08
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));