summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2020-04-20 18:55:01 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-04-20 18:55:01 +0000
commit7695970aba595d090054bab94f6158194591aa46 (patch)
tree4be617664ab30ce76c731521d0a92fe56b9c28a3 /service
parent289fe1a669d71c911a2c6f877df00238eb9c75d4 (diff)
parent9d1fa2cdb82d7435d25d88854726528962ca79c9 (diff)
Estimate the probability of getting internet am: 9d1fa2cdb8
Change-Id: I78a1a2fab0bba033b6927266a6b8dbbea490be9c
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiCandidates.java19
-rw-r--r--[-rwxr-xr-x]service/java/com/android/server/wifi/WifiNetworkScoreCache.java0
-rw-r--r--service/java/com/android/server/wifi/WifiScoreCard.java53
3 files changed, 61 insertions, 11 deletions
diff --git a/service/java/com/android/server/wifi/WifiCandidates.java b/service/java/com/android/server/wifi/WifiCandidates.java
index 24f814023..0513e5c1e 100644
--- a/service/java/com/android/server/wifi/WifiCandidates.java
+++ b/service/java/com/android/server/wifi/WifiCandidates.java
@@ -141,10 +141,14 @@ public class WifiCandidates {
*/
int getFrequency();
/**
- * Gets the predicted throughput in Mbps
+ * Gets the predicted throughput in Mbps.
*/
int getPredictedThroughputMbps();
/**
+ * Estimated probability of getting internet access (percent 0-100).
+ */
+ int getEstimatedPercentInternetAvailability();
+ /**
* Gets statistics from the scorecard.
*/
@Nullable WifiScoreCardProto.Signal getEventStatistics(WifiScoreCardProto.Event event);
@@ -171,6 +175,7 @@ public class WifiCandidates {
private final boolean mTrusted;
private final boolean mCarrierOrPrivileged;
private final int mPredictedThroughputMbps;
+ private final int mEstimatedPercentInternetAvailability;
CandidateImpl(Key key, WifiConfiguration config,
WifiScoreCard.PerBssid perBssid,
@@ -200,6 +205,8 @@ public class WifiCandidates {
this.mTrusted = config.trusted;
this.mCarrierOrPrivileged = isCarrierOrPrivileged;
this.mPredictedThroughputMbps = predictedThroughputMbps;
+ this.mEstimatedPercentInternetAvailability = perBssid == null ? 50 :
+ perBssid.estimatePercentInternetAvailability();
}
@Override
@@ -287,6 +294,11 @@ public class WifiCandidates {
return mPredictedThroughputMbps;
}
+ @Override
+ public int getEstimatedPercentInternetAvailability() {
+ return mEstimatedPercentInternetAvailability;
+ }
+
/**
* Accesses statistical information from the score card
*/
@@ -309,12 +321,13 @@ public class WifiCandidates {
+ ", ";
}
return "Candidate { "
- + "networkId = " + getNetworkConfigId() + ", "
+ + "config = " + getNetworkConfigId() + ", "
+ "bssid = " + key.bssid + ", "
- + "frequency = " + getFrequency() + ", "
+ + "freq = " + getFrequency() + ", "
+ "rssi = " + getScanRssi() + ", "
+ "Mbps = " + getPredictedThroughputMbps() + ", "
+ "nominator = " + getNominatorId() + ", "
+ + "pInternet = " + getEstimatedPercentInternetAvailability() + ", "
+ lastSelectionWeightString
+ (isCurrentBssid() ? "connected, " : "")
+ (isCurrentNetwork() ? "current, " : "")
diff --git a/service/java/com/android/server/wifi/WifiNetworkScoreCache.java b/service/java/com/android/server/wifi/WifiNetworkScoreCache.java
index 6bb3708ac..6bb3708ac 100755..100644
--- a/service/java/com/android/server/wifi/WifiNetworkScoreCache.java
+++ b/service/java/com/android/server/wifi/WifiNetworkScoreCache.java
diff --git a/service/java/com/android/server/wifi/WifiScoreCard.java b/service/java/com/android/server/wifi/WifiScoreCard.java
index fdf7a678b..071b9634d 100644
--- a/service/java/com/android/server/wifi/WifiScoreCard.java
+++ b/service/java/com/android/server/wifi/WifiScoreCard.java
@@ -205,7 +205,7 @@ public class WifiScoreCard {
*
* We want to gather statistics only on the first success.
*/
- private boolean mValidated = false;
+ private boolean mValidatedThisConnectionAtLeastOnce = false;
/**
* A note to ourself that we are attempting a network switch
@@ -279,7 +279,7 @@ public class WifiScoreCard {
}
mTsRoam = TS_NONE;
mPolled = false;
- mValidated = false;
+ mValidatedThisConnectionAtLeastOnce = false;
mNonlocalDisconnection = false;
}
@@ -363,9 +363,9 @@ public class WifiScoreCard {
* @param wifiInfo object holding relevant values
*/
public void noteValidationSuccess(@NonNull ExtendedWifiInfo wifiInfo) {
- if (mValidated) return; // Only once per connection
+ if (mValidatedThisConnectionAtLeastOnce) return; // Only once per connection
updatePerBssid(Event.VALIDATION_SUCCESS, wifiInfo);
- mValidated = true;
+ mValidatedThisConnectionAtLeastOnce = true;
doWrites();
}
@@ -375,7 +375,7 @@ public class WifiScoreCard {
* @param wifiInfo object holding relevant values
*/
public void noteValidationFailure(@NonNull ExtendedWifiInfo wifiInfo) {
- mValidated = false;
+ // VALIDATION_FAILURE is not currently recorded.
}
/**
@@ -448,10 +448,11 @@ public class WifiScoreCard {
* @param wifiInfo object holding relevant values
*/
public void noteIpReachabilityLost(@NonNull ExtendedWifiInfo wifiInfo) {
- updatePerBssid(Event.IP_REACHABILITY_LOST, wifiInfo);
if (mTsRoam > TS_NONE) {
mTsConnectionAttemptStart = mTsRoam; // just to update elapsed
updatePerBssid(Event.ROAM_FAILURE, wifiInfo);
+ } else {
+ updatePerBssid(Event.IP_REACHABILITY_LOST, wifiInfo);
}
// No need to call resetConnectionStateInternal() because
// resetConnectionState() will be called after WifiNative.disconnect() in ClientModeImpl
@@ -466,7 +467,7 @@ public class WifiScoreCard {
*
* @param wifiInfo object holding relevant values
*/
- public void noteRoam(@NonNull ExtendedWifiInfo wifiInfo) {
+ private void noteRoam(@NonNull ExtendedWifiInfo wifiInfo) {
updatePerBssid(Event.LAST_POLL_BEFORE_ROAM, wifiInfo);
mTsRoam = mClock.getElapsedSinceBootMillis();
}
@@ -479,6 +480,10 @@ public class WifiScoreCard {
*/
public void noteSupplicantStateChanging(@NonNull ExtendedWifiInfo wifiInfo,
SupplicantState state) {
+ if (state == SupplicantState.COMPLETED && wifiInfo.getSupplicantState() == state) {
+ // Our signal that a firmware roam has occurred
+ noteRoam(wifiInfo);
+ }
logd("Changing state to " + state + " " + wifiInfo);
}
@@ -788,6 +793,38 @@ public class WifiScoreCard {
}
merge(ap);
}
+
+ /**
+ * Estimates the probability of getting internet access, based on the
+ * device experience.
+ *
+ * @return a probability, expressed as a percentage in the range 0 to 100
+ */
+ public int estimatePercentInternetAvailability() {
+ // Initialize counts accoring to Laplace's rule of succession
+ int trials = 2;
+ int successes = 1;
+ // Aggregate over all of the frequencies
+ for (PerSignal s : mSignalForEventAndFrequency.values()) {
+ switch (s.event) {
+ case IP_CONFIGURATION_SUCCESS:
+ if (s.elapsedMs != null) {
+ trials += s.elapsedMs.count;
+ }
+ break;
+ case VALIDATION_SUCCESS:
+ if (s.elapsedMs != null) {
+ successes += s.elapsedMs.count;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ // Note that because of roaming it is possible to count successes
+ // without corresponding trials.
+ return Math.min(Math.max(Math.round(successes * 100.0f / trials), 0), 100);
+ }
}
/**
@@ -1712,7 +1749,7 @@ public class WifiScoreCard {
Preconditions.checkArgument(frequency == signal.getFrequency());
rssi.merge(signal.getRssi());
linkspeed.merge(signal.getLinkspeed());
- if (signal.hasElapsedMs()) {
+ if (elapsedMs != null && signal.hasElapsedMs()) {
elapsedMs.merge(signal.getElapsedMs());
}
return this;