diff options
author | Mingguang Xu <mingguangxu@google.com> | 2020-09-10 07:01:47 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-09-10 07:01:47 +0000 |
commit | b2e7091ff04668b7dc0946c50d6043cf52dfcf6a (patch) | |
tree | 7ac520d95fc1125933bb26c890cbbf5eb2759952 /service | |
parent | a0ea2e4b30a1ba0e86ec3d177f638604d9a079dc (diff) | |
parent | d8f20d663f99203a51fa92dd0cba31712f68e650 (diff) |
Merge "Do not allow default network to be switched from WiFi to Cellular when RSSI is high" into rvc-qpr-dev
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/DeviceConfigFacade.java | 15 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiScoreReport.java | 19 |
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 f6eed70ee..80a561d05 100644 --- a/service/java/com/android/server/wifi/WifiScoreReport.java +++ b/service/java/com/android/server/wifi/WifiScoreReport.java @@ -206,14 +206,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; } } |