diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/ScoringParams.java | 24 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/ThroughputScorer.java | 12 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiCandidates.java | 30 | ||||
-rw-r--r-- | service/res/values/config.xml | 7 | ||||
-rw-r--r-- | service/res/values/overlayable.xml | 3 |
5 files changed, 63 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/ScoringParams.java b/service/java/com/android/server/wifi/ScoringParams.java index 7588582b3..16230fa34 100644 --- a/service/java/com/android/server/wifi/ScoringParams.java +++ b/service/java/com/android/server/wifi/ScoringParams.java @@ -92,7 +92,8 @@ public class ScoringParams { public int throughputBonusLimit = 200; public int savedNetworkBonus = 500; public int unmeteredNetworkBonus = 1000; - public int currentNetworkBonus = 20; + public int currentNetworkBonusMin = 20; + public int currentNetworkBonusPercent = 20; public int secureNetworkBonus = 10; public int lastSelectionMinutes = 480; public static final int MIN_MINUTES = 1; @@ -275,8 +276,10 @@ public class ScoringParams { R.integer.config_wifiFrameworkSavedNetworkBonus); mVal.unmeteredNetworkBonus = context.getResources().getInteger( R.integer.config_wifiFrameworkUnmeteredNetworkBonus); - mVal.currentNetworkBonus = context.getResources().getInteger( - R.integer.config_wifiFrameworkCurrentNetworkBonus); + mVal.currentNetworkBonusMin = context.getResources().getInteger( + R.integer.config_wifiFrameworkCurrentNetworkBonusMin); + mVal.currentNetworkBonusPercent = context.getResources().getInteger( + R.integer.config_wifiFrameworkCurrentNetworkBonusPercent); mVal.secureNetworkBonus = context.getResources().getInteger( R.integer.config_wifiFrameworkSecureNetworkBonus); mVal.lastSelectionMinutes = context.getResources().getInteger( @@ -451,11 +454,20 @@ public class ScoringParams { } /* - * Returns the bonus for the network selection candidate score + * Returns the minimum bonus for the network selection candidate score * for the currently connected network. */ - public int getCurrentNetworkBonus() { - return mVal.currentNetworkBonus; + public int getCurrentNetworkBonusMin() { + return mVal.currentNetworkBonusMin; + } + + /* + * Returns the percentage bonus for the network selection candidate score + * for the currently connected network. The percent value is applied to rssi score and + * throughput score; + */ + public int getCurrentNetworkBonusPercent() { + return mVal.currentNetworkBonusPercent; } /* diff --git a/service/java/com/android/server/wifi/ThroughputScorer.java b/service/java/com/android/server/wifi/ThroughputScorer.java index 216dd858e..0371568b6 100644 --- a/service/java/com/android/server/wifi/ThroughputScorer.java +++ b/service/java/com/android/server/wifi/ThroughputScorer.java @@ -76,9 +76,15 @@ final class ThroughputScorer implements WifiCandidates.CandidateScorer { int throughputBonusScore = calculateThroughputBonusScore(candidate); - int currentNetworkBoost = candidate.isCurrentNetwork() - ? mScoringParams.getCurrentNetworkBonus() - : 0; + int rssiAndThroughputScore = rssiBaseScore + throughputBonusScore; + + boolean unExpectedNoInternet = candidate.hasNoInternetAccess() + && !candidate.isNoInternetAccessExpected(); + int currentNetworkBonusMin = mScoringParams.getCurrentNetworkBonusMin(); + int currentNetworkBonus = Math.max(currentNetworkBonusMin, rssiAndThroughputScore + * mScoringParams.getCurrentNetworkBonusPercent() / 100); + int currentNetworkBoost = (candidate.isCurrentNetwork() && !unExpectedNoInternet) + ? currentNetworkBonus : 0; int securityAward = candidate.isOpenNetwork() ? 0 diff --git a/service/java/com/android/server/wifi/WifiCandidates.java b/service/java/com/android/server/wifi/WifiCandidates.java index a264a49a7..24f814023 100644 --- a/service/java/com/android/server/wifi/WifiCandidates.java +++ b/service/java/com/android/server/wifi/WifiCandidates.java @@ -98,6 +98,18 @@ public class WifiCandidates { * Returns true for a metered network. */ boolean isMetered(); + + /** + * Returns true if network doesn't have internet access during last connection + */ + boolean hasNoInternetAccess(); + + /** + * Returns true if network is expected not to have Internet access + * (e.g., a wireless printer, a Chromecast hotspot, etc.). + */ + boolean isNoInternetAccessExpected(); + /** * Returns the ID of the nominator that provided the candidate. */ @@ -151,6 +163,8 @@ public class WifiCandidates { private final boolean mIsCurrentNetwork; private final boolean mIsCurrentBssid; private final boolean mIsMetered; + private final boolean mHasNoInternetAccess; + private final boolean mIsNoInternetAccessExpected; private final boolean mIsOpenNetwork; private final boolean mPasspoint; private final boolean mEphemeral; @@ -178,6 +192,8 @@ public class WifiCandidates { this.mIsCurrentNetwork = isCurrentNetwork; this.mIsCurrentBssid = isCurrentBssid; this.mIsMetered = isMetered; + this.mHasNoInternetAccess = config.hasNoInternetAccess(); + this.mIsNoInternetAccessExpected = config.isNoInternetAccessExpected(); this.mIsOpenNetwork = WifiConfigurationUtil.isConfigForOpenNetwork(config); this.mPasspoint = config.isPasspoint(); this.mEphemeral = config.isEphemeral(); @@ -223,7 +239,17 @@ public class WifiCandidates { @Override public boolean isMetered() { - return (mIsMetered); + return mIsMetered; + } + + @Override + public boolean hasNoInternetAccess() { + return mHasNoInternetAccess; + } + + @Override + public boolean isNoInternetAccessExpected() { + return mIsNoInternetAccessExpected; } @Override @@ -296,6 +322,8 @@ public class WifiCandidates { + (isTrusted() ? "trusted, " : "") + (isCarrierOrPrivileged() ? "priv, " : "") + (isMetered() ? "metered, " : "") + + (hasNoInternetAccess() ? "noInternet, " : "") + + (isNoInternetAccessExpected() ? "noInternetExpected, " : "") + (isPasspoint() ? "passpoint, " : "") + (isOpenNetwork() ? "open" : "secure") + " }"; } diff --git a/service/res/values/config.xml b/service/res/values/config.xml index 4d351b105..183e725e7 100644 --- a/service/res/values/config.xml +++ b/service/res/values/config.xml @@ -89,8 +89,11 @@ 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 specifying the minimum bonus for current network --> + <integer translatable="false" name="config_wifiFrameworkCurrentNetworkBonusMin">20</integer> + <!-- 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> <!-- The duration in minutes to strongly favor the last-selected network over other options. --> diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml index 7244911af..10653ff5a 100644 --- a/service/res/values/overlayable.xml +++ b/service/res/values/overlayable.xml @@ -36,7 +36,8 @@ <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_wifiFrameworkCurrentNetworkBonusMin" /> + <item type="integer" name="config_wifiFrameworkCurrentNetworkBonusPercent" /> <item type="integer" name="config_wifiFrameworkSecureNetworkBonus" /> <item type="integer" name="config_wifiFrameworkLastSelectionMinutes" /> <item type="integer" name="config_wifiFrameworkMinPacketPerSecondActiveTraffic" /> |