diff options
author | Michael Plass <mplass@google.com> | 2020-02-07 12:18:10 -0800 |
---|---|---|
committer | Michael Plass <mplass@google.com> | 2020-02-11 11:09:59 -0800 |
commit | 8c0fb1e3a7129bf1a921568970e4eb8b5a389950 (patch) | |
tree | 3bd42037d180ee42d916f25845bba5a0c0b3d6fb /service | |
parent | da15dd5f065a4ccdba3f2bf8b262fcf152c1632b (diff) |
[WifiCandidates] Remove the nominator score
The nominators are no longer generating scores, so do not bother to
store them.
Relax the candidate replacement rules so that new candidate can replace
one with a numerically lower (or equal) nominatorId. This is to allow
a candidate for the current connection to be added as a default, with
the possibility of replacing it using via the nominators.
Bug: 147751334
Test: atest WifiCandidatesTest WifiNetworkSelectorTest
Change-Id: I9d231ecccc6821e8446b4047fdd7509691859ecd
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiCandidates.java | 39 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkSelector.java | 1 |
2 files changed, 11 insertions, 29 deletions
diff --git a/service/java/com/android/server/wifi/WifiCandidates.java b/service/java/com/android/server/wifi/WifiCandidates.java index 604086024..255c80fe0 100644 --- a/service/java/com/android/server/wifi/WifiCandidates.java +++ b/service/java/com/android/server/wifi/WifiCandidates.java @@ -87,13 +87,7 @@ public class WifiCandidates { */ @WifiNetworkSelector.NetworkNominator.NominatorId int getNominatorId(); - /** - * Gets the score that was provided by the nominator. - * - * Not all nominators provide a useful score. Scores from different nominators - * are not directly comparable. - */ - int getNominatorScore(); + /** * Returns true if the candidate is in the same network as the * current connection. @@ -136,7 +130,6 @@ public class WifiCandidates { public final WifiConfiguration config; // First nominator to nominate this config public final @WifiNetworkSelector.NetworkNominator.NominatorId int nominatorId; - public final int nominatorScore; // Score provided by first nominator public final double lastSelectionWeight; // Value between 0 and 1 private final int mScanRssi; @@ -151,7 +144,6 @@ public class WifiCandidates { ScanDetail scanDetail, WifiConfiguration config, @WifiNetworkSelector.NetworkNominator.NominatorId int nominatorId, - int nominatorScore, WifiScoreCard.PerBssid perBssid, double lastSelectionWeight, boolean isCurrentNetwork, @@ -161,7 +153,6 @@ public class WifiCandidates { this.key = key; this.config = config; this.nominatorId = nominatorId; - this.nominatorScore = nominatorScore; this.mScanRssi = scanDetail.getScanResult().level; this.mFrequency = scanDetail.getScanResult().frequency; this.mPerBssid = perBssid; @@ -214,11 +205,6 @@ public class WifiCandidates { } @Override - public int getNominatorScore() { - return nominatorScore; - } - - @Override public double getLastSelectionWeight() { return lastSelectionWeight; } @@ -363,15 +349,14 @@ public class WifiCandidates { /** * Adds a new candidate * - * @returns true if added or replaced, false otherwise + * @return true if added or replaced, false otherwise */ public boolean add(ScanDetail scanDetail, - WifiConfiguration config, - @WifiNetworkSelector.NetworkNominator.NominatorId int nominatorId, - int nominatorScore, - double lastSelectionWeightBetweenZeroAndOne, - boolean isMetered, - int predictedThroughputMbps) { + WifiConfiguration config, + @WifiNetworkSelector.NetworkNominator.NominatorId int nominatorId, + double lastSelectionWeightBetweenZeroAndOne, + boolean isMetered, + int predictedThroughputMbps) { if (!validConfigAndScanDetail(config, scanDetail)) return false; ScanResult scanResult = scanDetail.getScanResult(); MacAddress bssid = MacAddress.fromString(scanResult.BSSID); @@ -379,9 +364,7 @@ public class WifiCandidates { CandidateImpl old = mCandidates.get(key); if (old != null) { // check if we want to replace this old candidate - if (nominatorId < old.nominatorId) return failure(); if (nominatorId > old.nominatorId) return false; - if (nominatorScore <= old.nominatorScore) return false; remove(old); } WifiScoreCard.PerBssid perBssid = mWifiScoreCard.lookupBssid( @@ -391,7 +374,7 @@ public class WifiCandidates { WifiScoreCardProto.SecurityType.forNumber(key.matchInfo.networkType)); perBssid.setNetworkConfigId(config.networkId); CandidateImpl candidate = new CandidateImpl(key, - scanDetail, config, nominatorId, nominatorScore, perBssid, + scanDetail, config, nominatorId, perBssid, Math.min(Math.max(lastSelectionWeightBetweenZeroAndOne, 0.0), 1.0), config.networkId == mCurrentNetworkId, bssid.equals(mCurrentBssid), @@ -433,7 +416,7 @@ public class WifiCandidates { /** * Removes a candidate - * @returns true if the candidate was successfully removed + * @return true if the candidate was successfully removed */ public boolean remove(Candidate candidate) { if (!(candidate instanceof CandidateImpl)) return failure(); @@ -466,7 +449,7 @@ public class WifiCandidates { /** * Make a choice from among the candidates, using the provided scorer. * - * @returns the chosen scored candidate, or ScoredCandidate.NONE. + * @return the chosen scored candidate, or ScoredCandidate.NONE. */ public @NonNull ScoredCandidate choose(@NonNull CandidateScorer candidateScorer) { Preconditions.checkNotNull(candidateScorer); @@ -511,7 +494,7 @@ public class WifiCandidates { * This captures a stack trace, so don't bother to construct a string message, just * supply any culprits (convertible to strings) that might aid diagnosis. * - * @returns false + * @return false * @throws RuntimeException (if in picky mode) */ private boolean failure(Object... culprits) { diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index 90a5e88c5..5d43b5536 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -714,7 +714,6 @@ public class WifiNetworkSelector { if (config != null) { boolean added = wifiCandidates.add(scanDetail, config, registeredNominator.getId(), - 0, (config.networkId == lastUserSelectedNetworkId) ? lastSelectionWeight : 0.0, WifiConfiguration.isMetered(config, wifiInfo), |