summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorMingguang Xu <mingguangxu@google.com>2020-08-14 19:19:57 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-08-14 19:19:57 +0000
commitaee8c8f54944e56a7d34855c2380cb746f70e3c3 (patch)
tree16e59958827b7e428b3c33e94b2ccb3c3a7459d5 /service
parentae0ff85e697a2919fc743d91fc8bf7b25e1c3be8 (diff)
parent3d896dcda63181f8a2a92fb3d26b0d74dc766b10 (diff)
Wifi usability: Add minimum confirmation duration for sending network score to connectivity service when score breaches am: 3d896dcda6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/wifi/+/12376244 Change-Id: Iac559752f0c0590541c09807569f7186caa3aeea
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java3
-rw-r--r--service/java/com/android/server/wifi/DeviceConfigFacade.java35
-rw-r--r--service/java/com/android/server/wifi/WifiScoreReport.java63
-rw-r--r--service/res/values/config.xml3
-rw-r--r--service/res/values/overlayable.xml1
5 files changed, 90 insertions, 15 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 2a487e312..866782ad3 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -811,7 +811,8 @@ public class ClientModeImpl extends StateMachine {
mWifiScoreReport = new WifiScoreReport(mWifiInjector.getScoringParams(), mClock,
mWifiMetrics, mWifiInfo, mWifiNative, mBssidBlocklistMonitor,
- mWifiInjector.getWifiThreadRunner());
+ mWifiInjector.getWifiThreadRunner(), mWifiInjector.getDeviceConfigFacade(),
+ mContext);
mNetworkCapabilitiesFilter = new NetworkCapabilities.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
diff --git a/service/java/com/android/server/wifi/DeviceConfigFacade.java b/service/java/com/android/server/wifi/DeviceConfigFacade.java
index 0b707701f..3856ff1fd 100644
--- a/service/java/com/android/server/wifi/DeviceConfigFacade.java
+++ b/service/java/com/android/server/wifi/DeviceConfigFacade.java
@@ -129,6 +129,16 @@ public class DeviceConfigFacade {
// Default health monitor firmware alert valid time.
// -1 disables firmware alert time check
static final int DEFAULT_HEALTH_MONITOR_FW_ALERT_VALID_TIME_MS = -1;
+ // Default minimum confirmation duration for sending network score to connectivity service
+ // when score breaches low. The actual confirmation duration is longer in general and it
+ // depends on the score evaluation period normally controlled by
+ // 'com.android.wifi.resources.R' config_wifiPollRssiIntervalMilliseconds.
+ static final int DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS = 5000;
+ // Default minimum confirmation duration for sending network score to connectivity service
+ // when score breaches high. The actual confirmation duration is longer in general and it
+ // depends on the score evaluation period normally controlled by
+ // 'com.android.wifi.resources.R' config_wifiPollRssiIntervalMilliseconds.
+ static final int DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS = 0;
// Cached values of fields updated via updateDeviceConfigFlags()
private boolean mIsAbnormalConnectionBugreportEnabled;
private int mAbnormalConnectionDurationMs;
@@ -177,6 +187,8 @@ public class DeviceConfigFacade {
private int mNonstationaryScanRssiValidTimeMs;
private int mStationaryScanRssiValidTimeMs;
private int mHealthMonitorFwAlertValidTimeMs;
+ private int mMinConfirmationDurationSendLowScoreMs;
+ private int mMinConfirmationDurationSendHighScoreMs;
public DeviceConfigFacade(Context context, Handler handler, WifiMetrics wifiMetrics) {
mContext = context;
@@ -324,7 +336,12 @@ public class DeviceConfigFacade {
"health_monitor_fw_alert_valid_time_ms",
DEFAULT_HEALTH_MONITOR_FW_ALERT_VALID_TIME_MS);
mWifiMetrics.setHealthMonitorRssiPollValidTimeMs(mHealthMonitorRssiPollValidTimeMs);
-
+ mMinConfirmationDurationSendLowScoreMs = DeviceConfig.getInt(NAMESPACE,
+ "min_confirmation_duration_send_low_score_ms",
+ DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS);
+ mMinConfirmationDurationSendHighScoreMs = DeviceConfig.getInt(NAMESPACE,
+ "min_confirmation_duration_send_high_score_ms",
+ DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS);
}
private Set<String> getUnmodifiableSetQuoted(String key) {
@@ -673,4 +690,20 @@ public class DeviceConfigFacade {
public int getHealthMonitorFwAlertValidTimeMs() {
return mHealthMonitorFwAlertValidTimeMs;
}
+
+ /**
+ * Gets the minimum confirmation duration for sending network score to connectivity service
+ * when score breaches low.
+ */
+ public int getMinConfirmationDurationSendLowScoreMs() {
+ return mMinConfirmationDurationSendLowScoreMs;
+ }
+
+ /**
+ * Gets the minimum confirmation duration for sending network score to connectivity service
+ * when score breaches high.
+ */
+ public int getMinConfirmationDurationSendHighScoreMs() {
+ return mMinConfirmationDurationSendHighScoreMs;
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiScoreReport.java b/service/java/com/android/server/wifi/WifiScoreReport.java
index 5a1e9d378..89f0445cb 100644
--- a/service/java/com/android/server/wifi/WifiScoreReport.java
+++ b/service/java/com/android/server/wifi/WifiScoreReport.java
@@ -16,6 +16,7 @@
package com.android.server.wifi;
+import android.content.Context;
import android.net.Network;
import android.net.NetworkAgent;
import android.net.wifi.IScoreUpdateObserver;
@@ -26,6 +27,8 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
+import com.android.wifi.resources.R;
+
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
@@ -62,7 +65,9 @@ public class WifiScoreReport {
private int mSessionNumber = 0; // not to be confused with sessionid, this just counts resets
private String mInterfaceName;
private final BssidBlocklistMonitor mBssidBlocklistMonitor;
- private long mLastScoreBreachLowTimeMillis = -1;
+ private final Context mContext;
+ private long mLastScoreBreachLowTimeMillis = INVALID_WALL_CLOCK_MILLIS;
+ private long mLastScoreBreachHighTimeMillis = INVALID_WALL_CLOCK_MILLIS;
ConnectedScore mAggressiveConnectedScore;
VelocityBasedConnectedScore mVelocityBasedConnectedScore;
@@ -72,6 +77,7 @@ public class WifiScoreReport {
WifiInfo mWifiInfo;
WifiNative mWifiNative;
WifiThreadRunner mWifiThreadRunner;
+ DeviceConfigFacade mDeviceConfigFacade;
/**
* Callback proxy. See {@link android.net.wifi.WifiManager.ScoreUpdateObserver}.
@@ -89,10 +95,6 @@ public class WifiScoreReport {
+ " score=" + score);
return;
}
- if (mNetworkAgent != null) {
- mNetworkAgent.sendNetworkScore(score);
- }
-
long millis = mClock.getWallClockMillis();
if (score < ConnectedScore.WIFI_TRANSITION_SCORE) {
if (mScore >= ConnectedScore.WIFI_TRANSITION_SCORE) {
@@ -101,7 +103,14 @@ public class WifiScoreReport {
} else {
mLastScoreBreachLowTimeMillis = INVALID_WALL_CLOCK_MILLIS;
}
-
+ if (score > ConnectedScore.WIFI_TRANSITION_SCORE) {
+ if (mScore <= ConnectedScore.WIFI_TRANSITION_SCORE) {
+ mLastScoreBreachHighTimeMillis = millis;
+ }
+ } else {
+ mLastScoreBreachHighTimeMillis = INVALID_WALL_CLOCK_MILLIS;
+ }
+ reportNetworkScoreToConnectivityServiceIfNecessary(score);
mScore = score;
updateWifiMetrics(millis, -1, mScore);
});
@@ -167,6 +176,34 @@ public class WifiScoreReport {
}
/**
+ * Report network score to connectivity service.
+ */
+ private void reportNetworkScoreToConnectivityServiceIfNecessary(int score) {
+ if (mNetworkAgent == null) {
+ return;
+ }
+ if (mWifiConnectedNetworkScorerHolder == null && score == mWifiInfo.getScore()) {
+ return;
+ }
+ if (mWifiConnectedNetworkScorerHolder != null
+ && mContext.getResources().getBoolean(
+ R.bool.config_wifiMinConfirmationDurationSendNetworkScoreEnabled)) {
+ long millis = mClock.getWallClockMillis();
+ if (mLastScoreBreachLowTimeMillis != INVALID_WALL_CLOCK_MILLIS
+ && (millis - mLastScoreBreachLowTimeMillis)
+ < mDeviceConfigFacade.getMinConfirmationDurationSendLowScoreMs()) {
+ return;
+ }
+ if (mLastScoreBreachHighTimeMillis != INVALID_WALL_CLOCK_MILLIS
+ && (millis - mLastScoreBreachHighTimeMillis)
+ < mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs()) {
+ return;
+ }
+ }
+ mNetworkAgent.sendNetworkScore(score);
+ }
+
+ /**
* Container for storing info about external scorer and tracking its death.
*/
private final class WifiConnectedNetworkScorerHolder implements IBinder.DeathRecipient {
@@ -251,7 +288,8 @@ public class WifiScoreReport {
WifiScoreReport(ScoringParams scoringParams, Clock clock, WifiMetrics wifiMetrics,
WifiInfo wifiInfo, WifiNative wifiNative, BssidBlocklistMonitor bssidBlocklistMonitor,
- WifiThreadRunner wifiThreadRunner) {
+ WifiThreadRunner wifiThreadRunner, DeviceConfigFacade deviceConfigFacade,
+ Context context) {
mScoringParams = scoringParams;
mClock = clock;
mAggressiveConnectedScore = new AggressiveConnectedScore(scoringParams, clock);
@@ -261,6 +299,8 @@ public class WifiScoreReport {
mWifiNative = wifiNative;
mBssidBlocklistMonitor = bssidBlocklistMonitor;
mWifiThreadRunner = wifiThreadRunner;
+ mDeviceConfigFacade = deviceConfigFacade;
+ mContext = context;
}
/**
@@ -276,6 +316,7 @@ public class WifiScoreReport {
}
mLastDownwardBreachTimeMillis = 0;
mLastScoreBreachLowTimeMillis = INVALID_WALL_CLOCK_MILLIS;
+ mLastScoreBreachHighTimeMillis = INVALID_WALL_CLOCK_MILLIS;
if (mVerboseLoggingEnabled) Log.d(TAG, "reset");
}
@@ -357,12 +398,7 @@ public class WifiScoreReport {
}
//report score
- if (score != mWifiInfo.getScore()) {
- if (mNetworkAgent != null) {
- mNetworkAgent.sendNetworkScore(score);
- }
- }
-
+ reportNetworkScoreToConnectivityServiceIfNecessary(score);
updateWifiMetrics(millis, s2, score);
mScore = score;
}
@@ -612,6 +648,7 @@ public class WifiScoreReport {
mWifiInfo.setScore(ConnectedScore.WIFI_MAX_SCORE);
mWifiConnectedNetworkScorerHolder.startSession(sessionId);
mLastScoreBreachLowTimeMillis = INVALID_WALL_CLOCK_MILLIS;
+ mLastScoreBreachHighTimeMillis = INVALID_WALL_CLOCK_MILLIS;
}
/**
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index 742cf681f..1220c260a 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -454,4 +454,7 @@
<!-- integer indicating additional disconnect delay (in ms) after IMS onLost() indication is received -->
<integer translatable="false" name="config_wifiDelayDisconnectOnImsLostMs">0</integer>
+
+ <!-- Enable adding minimum confirmation duration when sending network score to connectivity service. -->
+ <bool translatable="false" name="config_wifiMinConfirmationDurationSendNetworkScoreEnabled">false</bool>
</resources>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 8b592623f..56c94246d 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -143,6 +143,7 @@
<item type="integer" name="config_wifiMovingPnoScanIntervalMillis" />
<item type="integer" name="config_wifiStationaryPnoScanIntervalMillis" />
<item type="integer" name="config_wifiDelayDisconnectOnImsLostMs" />
+ <item type="bool" name="config_wifiMinConfirmationDurationSendNetworkScoreEnabled" />
<!-- Params from config.xml that can be overlayed -->
<!-- Params from strings.xml that can be overlayed -->