summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2020-05-20 14:54:16 -0700
committerKai Shi <kaishi@google.com>2020-05-20 17:51:48 -0700
commit7ac44dcfd673f0408ecfa668bf05dea637bad2a0 (patch)
tree5c445a0be859238d5ba29e89dbb5723f46683554
parente536cd115bddb9ea5fa38c8ceaf495b3ece78c3d (diff)
Increase security bonus score to 40 and reduce rssi cap
1) Increase security bonus score from 10 to 40 to be more in favor of secure network. 2) Reduce rssi cap from good_rssi_threshold to low_rssi_threshold (also known as sufficient_rssi_threshold) so that the network with clean channel and higher BW is more likely to be selected at middle range/rssi. Bug: 157081384 Test: atest com.android.server.wifi Test: manual test with adb shell dumpsys wifi and check wifiNetworkSelector logs Change-Id: I791ed9c683358003bb8e264ebf5c72c2fb710a6c
-rw-r--r--service/java/com/android/server/wifi/ScoringParams.java2
-rw-r--r--service/java/com/android/server/wifi/ThroughputScorer.java2
-rw-r--r--service/res/values/config.xml2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java15
4 files changed, 12 insertions, 9 deletions
diff --git a/service/java/com/android/server/wifi/ScoringParams.java b/service/java/com/android/server/wifi/ScoringParams.java
index 460cb9c20..f2a318261 100644
--- a/service/java/com/android/server/wifi/ScoringParams.java
+++ b/service/java/com/android/server/wifi/ScoringParams.java
@@ -91,7 +91,7 @@ public class ScoringParams {
public int unmeteredNetworkBonus = 1000;
public int currentNetworkBonusMin = 20;
public int currentNetworkBonusPercent = 20;
- public int secureNetworkBonus = 10;
+ public int secureNetworkBonus = 40;
public int lastSelectionMinutes = 480;
public static final int MIN_MINUTES = 1;
public static final int MAX_MINUTES = Integer.MAX_VALUE / (60 * 1000);
diff --git a/service/java/com/android/server/wifi/ThroughputScorer.java b/service/java/com/android/server/wifi/ThroughputScorer.java
index 0371568b6..ed0d0da73 100644
--- a/service/java/com/android/server/wifi/ThroughputScorer.java
+++ b/service/java/com/android/server/wifi/ThroughputScorer.java
@@ -70,7 +70,7 @@ final class ThroughputScorer implements WifiCandidates.CandidateScorer {
* Calculates an individual candidate's score.
*/
private ScoredCandidate scoreCandidate(Candidate candidate) {
- int rssiSaturationThreshold = mScoringParams.getGoodRssi(candidate.getFrequency());
+ int rssiSaturationThreshold = mScoringParams.getSufficientRssi(candidate.getFrequency());
int rssi = Math.min(candidate.getScanRssi(), rssiSaturationThreshold);
int rssiBaseScore = (rssi + RSSI_SCORE_OFFSET) * RSSI_SCORE_SLOPE_IS_4;
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index 5d8a47ca9..9c8c73c2a 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -101,7 +101,7 @@
<!-- Integer specifying the percent bonus for current network. The percent is applied to
the sum of rssi base score and throughput score-->
<integer translatable="false" name="config_wifiFrameworkCurrentNetworkBonusPercent">20</integer>
- <integer translatable="false" name="config_wifiFrameworkSecureNetworkBonus">10</integer>
+ <integer translatable="false" name="config_wifiFrameworkSecureNetworkBonus">40</integer>
<!-- The duration in minutes to strongly favor the last-selected network over other options. -->
<integer translatable="false" name="config_wifiFrameworkLastSelectionMinutes">480</integer>
diff --git a/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java b/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java
index 7562da206..7b45848f7 100644
--- a/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java
@@ -156,8 +156,8 @@ public class CandidateScorerTest extends WifiBaseTest {
*/
@Test
public void testPreferHigherRssi() throws Exception {
- assertThat(evaluate(mCandidate1.setScanRssi(-63)),
- greaterThan(evaluate(mCandidate2.setScanRssi(-64))));
+ assertThat(evaluate(mCandidate1.setScanRssi(-70)),
+ greaterThan(evaluate(mCandidate2.setScanRssi(-71))));
}
/**
@@ -174,9 +174,9 @@ public class CandidateScorerTest extends WifiBaseTest {
*/
@Test
public void testPreferTheCurrentNetworkEvenIfRssiDifferenceIsSignificant() throws Exception {
- assertThat(evaluate(mCandidate1.setScanRssi(-65).setCurrentNetwork(true)
+ assertThat(evaluate(mCandidate1.setScanRssi(-76).setCurrentNetwork(true)
.setPredictedThroughputMbps(433)),
- greaterThan(evaluate(mCandidate2.setScanRssi(-57)
+ greaterThan(evaluate(mCandidate2.setScanRssi(-69)
.setPredictedThroughputMbps(433))));
}
@@ -248,12 +248,15 @@ public class CandidateScorerTest extends WifiBaseTest {
*/
@Test
public void testAboveSaturationDoNotSwitchAwayEvenWithALargeRssiDifference() throws Exception {
- int goodRssi = mScoringParams.getGoodRssi(mCandidate1.getFrequency());
+ int currentRssi = (mExpectedExpId == ThroughputScorer.THROUGHPUT_SCORER_DEFAULT_EXPID)
+ ? mScoringParams.getSufficientRssi(mCandidate1.getFrequency()) :
+ mScoringParams.getGoodRssi(mCandidate1.getFrequency());
int unbelievablyGoodRssi = -1;
- assertThat(evaluate(mCandidate1.setScanRssi(goodRssi).setCurrentNetwork(true)),
+ assertThat(evaluate(mCandidate1.setScanRssi(currentRssi).setCurrentNetwork(true)),
greaterThan(evaluate(mCandidate2.setScanRssi(unbelievablyGoodRssi))));
}
+
/**
* Prefer high throughput network.
*/