summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorMingguang Xu <mingguangxu@google.com>2020-09-03 10:43:08 -0700
committerMingguang Xu <mingguangxu@google.com>2020-09-09 21:25:44 -0700
commitd8f20d663f99203a51fa92dd0cba31712f68e650 (patch)
tree1be5fd184f93145fe5076a4acec2c637358ff558 /service
parentedc209e114cb84977b592bd4ef2fe8203a68951c (diff)
Do not allow default network to be switched from WiFi to Cellular when RSSI is high
Under the two conditions: When external scorer takes action; The overlay to enable time hysteresis (config_wifiMinConfirmationDurationSendNetworkScoreEnabled) is enabled, on top of the minimum confirmation duration added for sending low score to Connectivity Service, add a check on RSSI: If RSSI is higher than or equal to a configurable threshold (default -67dBm), then donot send any low score to Connectivity Service. This guarantees that default network will not be switched from WiFi to Cellular when RSSI is high (user is seeing three or four bars on WiFi icon). The reason for adding RSSI check is that users are trained to look at high RSSI (e.g., three bars) as indication of good WiFi. This will certainly reduce any false alarms (especially for some IOT APs). Bug: 167643965 Test: atest com.android.server.wifi Signed-off-by: Mingguang Xu <mingguangxu@google.com> Change-Id: I31f1802a569603bbf4c50df2fbd73d71935e0f9d
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/DeviceConfigFacade.java15
-rw-r--r--service/java/com/android/server/wifi/WifiScoreReport.java19
2 files changed, 30 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/DeviceConfigFacade.java b/service/java/com/android/server/wifi/DeviceConfigFacade.java
index 3856ff1fd..a7bcfc764 100644
--- a/service/java/com/android/server/wifi/DeviceConfigFacade.java
+++ b/service/java/com/android/server/wifi/DeviceConfigFacade.java
@@ -139,6 +139,9 @@ public class DeviceConfigFacade {
// 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;
+ // Default RSSI threshold in dBm above which low score is not sent to connectivity service
+ // when external scorer takes action.
+ static final int DEFAULT_RSSI_THRESHOLD_NOT_SEND_LOW_SCORE_TO_CS_DBM = -67;
// Cached values of fields updated via updateDeviceConfigFlags()
private boolean mIsAbnormalConnectionBugreportEnabled;
private int mAbnormalConnectionDurationMs;
@@ -189,6 +192,7 @@ public class DeviceConfigFacade {
private int mHealthMonitorFwAlertValidTimeMs;
private int mMinConfirmationDurationSendLowScoreMs;
private int mMinConfirmationDurationSendHighScoreMs;
+ private int mRssiThresholdNotSendLowScoreToCsDbm;
public DeviceConfigFacade(Context context, Handler handler, WifiMetrics wifiMetrics) {
mContext = context;
@@ -342,6 +346,9 @@ public class DeviceConfigFacade {
mMinConfirmationDurationSendHighScoreMs = DeviceConfig.getInt(NAMESPACE,
"min_confirmation_duration_send_high_score_ms",
DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS);
+ mRssiThresholdNotSendLowScoreToCsDbm = DeviceConfig.getInt(NAMESPACE,
+ "rssi_threshold_not_send_low_score_to_cs_dbm",
+ DEFAULT_RSSI_THRESHOLD_NOT_SEND_LOW_SCORE_TO_CS_DBM);
}
private Set<String> getUnmodifiableSetQuoted(String key) {
@@ -706,4 +713,12 @@ public class DeviceConfigFacade {
public int getMinConfirmationDurationSendHighScoreMs() {
return mMinConfirmationDurationSendHighScoreMs;
}
+
+ /**
+ * Gets the RSSI threshold above which low score is not sent to connectivity service when
+ * external scorer takes action.
+ */
+ public int getRssiThresholdNotSendLowScoreToCsDbm() {
+ return mRssiThresholdNotSendLowScoreToCsDbm;
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiScoreReport.java b/service/java/com/android/server/wifi/WifiScoreReport.java
index 89f0445cb..e918b73d5 100644
--- a/service/java/com/android/server/wifi/WifiScoreReport.java
+++ b/service/java/com/android/server/wifi/WifiScoreReport.java
@@ -189,14 +189,25 @@ public class WifiScoreReport {
&& mContext.getResources().getBoolean(
R.bool.config_wifiMinConfirmationDurationSendNetworkScoreEnabled)) {
long millis = mClock.getWallClockMillis();
- if (mLastScoreBreachLowTimeMillis != INVALID_WALL_CLOCK_MILLIS
- && (millis - mLastScoreBreachLowTimeMillis)
- < mDeviceConfigFacade.getMinConfirmationDurationSendLowScoreMs()) {
- return;
+ if (mLastScoreBreachLowTimeMillis != INVALID_WALL_CLOCK_MILLIS) {
+ if (mWifiInfo.getRssi()
+ >= mDeviceConfigFacade.getRssiThresholdNotSendLowScoreToCsDbm()) {
+ Log.d(TAG, "Not reporting low score because RSSI is high "
+ + mWifiInfo.getRssi());
+ return;
+ }
+ if ((millis - mLastScoreBreachLowTimeMillis)
+ < mDeviceConfigFacade.getMinConfirmationDurationSendLowScoreMs()) {
+ Log.d(TAG, "Not reporting low score because elapsed time is shorter than "
+ + "the minimum confirmation duration");
+ return;
+ }
}
if (mLastScoreBreachHighTimeMillis != INVALID_WALL_CLOCK_MILLIS
&& (millis - mLastScoreBreachHighTimeMillis)
< mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs()) {
+ Log.d(TAG, "Not reporting high score because elapsed time is shorter than "
+ + "the minimum confirmation duration");
return;
}
}