summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2019-12-18 15:12:40 -0800
committerMichael Plass <mplass@google.com>2019-12-20 15:38:04 -0800
commitee541ac09fac139272f4000756af1143aa6fe459 (patch)
treef3eacb9950a0b76fd65cc3d00251568ea2e21424 /service
parent52fe8849980aa979a72fff53443429101f5f6277 (diff)
Parameterize ThroughputScorer
This makes the salient parameters of ThroughputScorer configurable via an overlay. Set the default parameters so that unmetered networks are preferred over metered networks, and within each of those categories, saved networks are preferred over suggestions. However, being the last-suggested network can override both of these for a limited time. Bug: 136675430 Bug: 142081306 Test: atest FrameworksWifiTests (currently 1 disabled) Change-Id: I54ba20c93a99c3bd3e261faca1b0ec3f1c46e50a
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ScoringParams.java87
-rw-r--r--service/java/com/android/server/wifi/ThroughputScorer.java55
-rw-r--r--service/res/values/config.xml26
-rw-r--r--service/res/values/overlayable.xml8
4 files changed, 142 insertions, 34 deletions
diff --git a/service/java/com/android/server/wifi/ScoringParams.java b/service/java/com/android/server/wifi/ScoringParams.java
index b36c3e9fa..94efde198 100644
--- a/service/java/com/android/server/wifi/ScoringParams.java
+++ b/service/java/com/android/server/wifi/ScoringParams.java
@@ -87,6 +87,16 @@ public class ScoringParams {
public static final int MAX_EXPID = Integer.MAX_VALUE;
public int expid = 0;
+ /** CandidateScorer parameters */
+ public int throughputBonusNumerator = 120;
+ public int throughputBonusDenominator = 433;
+ public int throughputBonusLimit = 200;
+ public int savedNetworkBonus = 500;
+ public int unmeteredNetworkBonus = 1000;
+ public int currentNetworkBonus = 20;
+ public int secureNetworkBonus = 10;
+ public int lastSelectionBonus = 1999;
+
Values() {
}
@@ -258,6 +268,23 @@ public class ScoringParams {
R.integer.config_wifiFrameworkScoreLowRssiThreshold6ghz);
mVal.rssi6[GOOD] = context.getResources().getInteger(
R.integer.config_wifiFrameworkScoreGoodRssiThreshold6ghz);
+ mVal.throughputBonusNumerator = context.getResources().getInteger(
+ R.integer.config_wifiFrameworkThroughputBonusNumerator);
+ mVal.throughputBonusDenominator = context.getResources().getInteger(
+ R.integer.config_wifiFrameworkThroughputBonusDenominator);
+ mVal.throughputBonusLimit = context.getResources().getInteger(
+ R.integer.config_wifiFrameworkThroughputBonusLimit);
+ mVal.savedNetworkBonus = context.getResources().getInteger(
+ R.integer.config_wifiFrameworkSavedNetworkBonus);
+ mVal.unmeteredNetworkBonus = context.getResources().getInteger(
+ R.integer.config_wifiFrameworkUnmeteredNetworkBonus);
+ mVal.currentNetworkBonus = context.getResources().getInteger(
+ R.integer.config_wifiFrameworkCurrentNetworkBonus);
+ mVal.secureNetworkBonus = context.getResources().getInteger(
+ R.integer.config_wifiFrameworkSecureNetworkBonus);
+ mVal.lastSelectionBonus = context.getResources().getInteger(
+ R.integer.config_wifiFrameworkLastSelectionBonus);
+
try {
mVal.validate();
} catch (IllegalArgumentException e) {
@@ -402,6 +429,66 @@ public class ScoringParams {
}
/**
+ */
+ public int getThroughputBonusNumerator() {
+ return mVal.throughputBonusNumerator;
+ }
+
+ /**
+ */
+ public int getThroughputBonusDenominator() {
+ return mVal.throughputBonusDenominator;
+ }
+
+ /*
+ * Returns the maximum bonus for the network selection candidate score
+ * for the contribution of the selected score.
+ */
+ public int getThroughputBonusLimit() {
+ return mVal.throughputBonusLimit;
+ }
+
+ /*
+ * Returns the bonus for the network selection candidate score
+ * for a saved network (i.e., not a suggestion).
+ */
+ public int getSavedNetworkBonus() {
+ return mVal.savedNetworkBonus;
+ }
+
+ /*
+ * Returns the bonus for the network selection candidate score
+ * for an unmetered network.
+ */
+ public int getUnmeteredNetworkBonus() {
+ return mVal.unmeteredNetworkBonus;
+ }
+
+ /*
+ * Returns the bonus for the network selection candidate score
+ * for the currently connected network.
+ */
+ public int getCurrentNetworkBonus() {
+ return mVal.currentNetworkBonus;
+ }
+
+ /*
+ * Returns the bonus for the network selection candidate score
+ * for a secure network.
+ */
+ public int getSecureNetworkBonus() {
+ return mVal.secureNetworkBonus;
+ }
+
+ /*
+ * Returns the bonus for the network selection candidate score
+ * for a recently selected network.
+ */
+ public int getLastSelectionBonus() {
+ return mVal.lastSelectionBonus;
+ }
+
+ /**
* Returns the experiment identifier.
*
* This value may be used to tag a set of experimental settings.
diff --git a/service/java/com/android/server/wifi/ThroughputScorer.java b/service/java/com/android/server/wifi/ThroughputScorer.java
index 8177462de..a95bf8fcf 100644
--- a/service/java/com/android/server/wifi/ThroughputScorer.java
+++ b/service/java/com/android/server/wifi/ThroughputScorer.java
@@ -44,29 +44,6 @@ final class ThroughputScorer implements WifiCandidates.CandidateScorer {
// config_wifi_framework_RSSI_SCORE_SLOPE
public static final int RSSI_SCORE_SLOPE_IS_4 = 4;
- // config_wifi_framework_SECURITY_AWARD
- public static final int SECURITY_AWARD = 10;
-
- // config_wifi_framework_LAST_SELECTION_AWARD
- public static final int LAST_SELECTION_AWARD_IS_480 = 480;
-
- // Bonus score for current network
- // High RSSI case:
- // Bonus RSSI score: 10 (equivalent to RSSI variation 2.5dB)
- // Bonus throughput score: 10 (equivalent to ~ 40Mbps).
- // Low RSSI case:
- // Bonus RSSI score: 16 (equivalent to RSSI variation 4dB)
- // Bonus throughput score: 4 (equivalent to ~ 16Mbps).
- public static final int CURRENT_NETWORK_BOOST = 20;
-
- // Max throughput in 11AC 40MHz 2SS mode with zero channel utilization
- public static final int MAX_THROUGHPUT_AC_40_MHZ_2SS_MBPS = 433;
- // Max throughput score in 11AC 40MHz 2SS mode
- public static final int MAX_THROUGHPUT_BONUS_SCORE_AC_40_MHZ_2SS = 120;
-
- // Max throughput bonus score for all possible modes
- public static final int MAX_THROUGHPUT_BONUS_SCORE = 200;
-
private static final boolean USE_USER_CONNECT_CHOICE = true;
ThroughputScorer(ScoringParams scoringParams) {
@@ -89,18 +66,27 @@ final class ThroughputScorer implements WifiCandidates.CandidateScorer {
int throughputBonusScore = calculateThroughputBonusScore(candidate);
int lastSelectionBonusScore = (int)
- (candidate.getLastSelectionWeight() * LAST_SELECTION_AWARD_IS_480);
+ (candidate.getLastSelectionWeight() * mScoringParams.getLastSelectionBonus());
+
+ int currentNetworkBoost = candidate.isCurrentNetwork()
+ ? mScoringParams.getCurrentNetworkBonus()
+ : 0;
- int currentNetworkBoost = candidate.isCurrentNetwork() ? CURRENT_NETWORK_BOOST : 0;
+ int securityAward = candidate.isOpenNetwork()
+ ? 0
+ : mScoringParams.getSecureNetworkBonus();
- int securityAward = candidate.isOpenNetwork() ? 0 : SECURITY_AWARD;
+ int unmeteredAward = candidate.isMetered()
+ ? 0
+ : mScoringParams.getUnmeteredNetworkBonus();
- // To simulate the old strict priority rule, subtract a penalty based on
- // which evaluator added the candidate.
- int evaluatorGroupScore = -1000 * candidate.getNominatorId();
+ int savedNetworkAward = (candidate.getNominatorId()
+ == WifiNetworkSelector.NetworkNominator.NOMINATOR_ID_SAVED)
+ ? mScoringParams.getSavedNetworkBonus()
+ : 0;
int score = rssiBaseScore + throughputBonusScore + lastSelectionBonusScore
- + currentNetworkBoost + securityAward + evaluatorGroupScore;
+ + currentNetworkBoost + securityAward + unmeteredAward + savedNetworkAward;
if (DBG) {
Log.d(TAG, " rssiScore: " + rssiBaseScore
@@ -108,7 +94,8 @@ final class ThroughputScorer implements WifiCandidates.CandidateScorer {
+ " lastSelectionBonus: " + lastSelectionBonusScore
+ " currentNetworkBoost: " + currentNetworkBoost
+ " securityAward: " + securityAward
- + " evaluatorScore: " + evaluatorGroupScore
+ + " unmeteredAward: " + unmeteredAward
+ + " savedNetworkAward: " + savedNetworkAward
+ " final score: " + score);
}
@@ -121,9 +108,9 @@ final class ThroughputScorer implements WifiCandidates.CandidateScorer {
private int calculateThroughputBonusScore(Candidate candidate) {
int throughputScoreRaw = candidate.getPredictedThroughputMbps()
- * MAX_THROUGHPUT_BONUS_SCORE_AC_40_MHZ_2SS
- / MAX_THROUGHPUT_AC_40_MHZ_2SS_MBPS;
- return Math.min(throughputScoreRaw, MAX_THROUGHPUT_BONUS_SCORE);
+ * mScoringParams.getThroughputBonusNumerator()
+ / mScoringParams.getThroughputBonusDenominator();
+ return Math.min(throughputScoreRaw, mScoringParams.getThroughputBonusLimit());
}
@Override
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index f95f4d6c1..fb3b02fe5 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -72,6 +72,32 @@
<!-- Boolean indicating whether or not wifi should turn off when emergency call is made -->
<bool translatable="false" name="config_wifi_turn_off_during_emergency_call">false</bool>
+ <!-- Parameters for controlling network selection by the framework -->
+
+ <!-- The ratio of the next two parameters is the multiplier that converts the estimated
+ throughput in Mbps to score points. -->
+ <integer translatable="false" name="config_wifiFrameworkThroughputBonusNumerator">120</integer>
+ <integer translatable="false" name="config_wifiFrameworkThroughputBonusDenominator">433</integer>
+
+ <!-- Maximum contribution (in score points) due to the estimated throughput. -->
+ <integer translatable="false" name="config_wifiFrameworkThroughputBonusLimit">200</integer>
+
+ <!-- The default values chosen here establish four non-overlapping categories:
+ saved, unmetered
+ unsaved, unmetered
+ saved, metered
+ unsaved, metered
+ These values can be reduced to allow overlapping between categories. -->
+ <integer translatable="false" name="config_wifiFrameworkSavedNetworkBonus">500</integer>
+ <integer translatable="false" name="config_wifiFrameworkUnmeteredNetworkBonus">1000</integer>
+
+ <integer translatable="false" name="config_wifiFrameworkCurrentNetworkBonus">20</integer>
+ <integer translatable="false" name="config_wifiFrameworkSecureNetworkBonus">10</integer>
+
+ <!-- The bonus for the last-selected network starts out very large to override the category
+ boundaries. -->
+ <integer translatable="false" name="config_wifiFrameworkLastSelectionBonus">1999</integer>
+
<!-- Integers specifying the max packet Tx/Rx rates for full scan -->
<integer translatable="false" name="config_wifi_framework_max_tx_rate_for_full_scan">8</integer>
<integer translatable="false" name="config_wifi_framework_max_rx_rate_for_full_scan">16</integer>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 0ce05eaa0..e5a522353 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -32,6 +32,14 @@
<item type="integer" name="config_wifi_logger_ring_buffer_verbose_size_limit_kb" />
<item type="array" name="config_wifi_fatal_firmware_alert_error_code_list" />
<item type="bool" name="config_wifi_turn_off_during_emergency_call" />
+ <item type="integer" name="config_wifiFrameworkThroughputBonusNumerator" />
+ <item type="integer" name="config_wifiFrameworkThroughputBonusDenominator" />
+ <item type="integer" name="config_wifiFrameworkThroughputBonusLimit" />
+ <item type="integer" name="config_wifiFrameworkSavedNetworkBonus" />
+ <item type="integer" name="config_wifiFrameworkUnmeteredNetworkBonus" />
+ <item type="integer" name="config_wifiFrameworkCurrentNetworkBonus" />
+ <item type="integer" name="config_wifiFrameworkSecureNetworkBonus" />
+ <item type="integer" name="config_wifiFrameworkLastSelectionBonus" />
<item type="integer" name="config_wifi_framework_max_tx_rate_for_full_scan" />
<item type="integer" name="config_wifi_framework_max_rx_rate_for_full_scan" />
<item type="integer" name="config_wifi_framework_min_tx_rate_for_staying_on_network" />