summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/DeviceConfigFacade.java15
-rw-r--r--service/java/com/android/server/wifi/WifiScoreReport.java19
-rw-r--r--tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java5
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java16
4 files changed, 47 insertions, 8 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;
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
index 43a16fe4c..a570d2948 100644
--- a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
@@ -209,6 +209,8 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
mDeviceConfigFacade.getMinConfirmationDurationSendLowScoreMs());
assertEquals(DeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS,
mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs());
+ assertEquals(DeviceConfigFacade.DEFAULT_RSSI_THRESHOLD_NOT_SEND_LOW_SCORE_TO_CS_DBM,
+ mDeviceConfigFacade.getRssiThresholdNotSendLowScoreToCsDbm());
}
/**
@@ -315,6 +317,8 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
anyInt())).thenReturn(4000);
when(DeviceConfig.getInt(anyString(), eq("min_confirmation_duration_send_high_score_ms"),
anyInt())).thenReturn(1000);
+ when(DeviceConfig.getInt(anyString(), eq("rssi_threshold_not_send_low_score_to_cs_dbm"),
+ anyInt())).thenReturn(-70);
mOnPropertiesChangedListenerCaptor.getValue().onPropertiesChanged(null);
// Verifying fields are updated to the new values
@@ -373,5 +377,6 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
assertEquals(1000, mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs());
assertEquals(4000, mDeviceConfigFacade.getMinConfirmationDurationSendLowScoreMs());
assertEquals(1000, mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs());
+ assertEquals(-70, mDeviceConfigFacade.getRssiThresholdNotSendLowScoreToCsDbm());
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
index 82dbbe941..fb2d128cc 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
@@ -208,6 +208,8 @@ public class WifiScoreReportTest extends WifiBaseTest {
DeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS);
when(mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs()).thenReturn(
DeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS);
+ when(mDeviceConfigFacade.getRssiThresholdNotSendLowScoreToCsDbm()).thenReturn(
+ DeviceConfigFacade.DEFAULT_RSSI_THRESHOLD_NOT_SEND_LOW_SCORE_TO_CS_DBM);
}
/**
@@ -870,6 +872,7 @@ public class WifiScoreReportTest extends WifiBaseTest {
mClock.mStepMillis = 0;
mClock.mWallClockMillis = 10;
+ mWifiInfo.setRssi(-65);
scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 49);
mLooper.dispatchAll();
verify(mNetworkAgent).sendNetworkScore(anyInt());
@@ -891,9 +894,11 @@ public class WifiScoreReportTest extends WifiBaseTest {
mClock.mWallClockMillis = 10;
scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 60);
+ mWifiInfo.setRssi(-70);
mLooper.dispatchAll();
verify(mNetworkAgent).sendNetworkScore(60);
mClock.mWallClockMillis = 3010;
+ mWifiInfo.setRssi(-65);
scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 59);
mLooper.dispatchAll();
verify(mNetworkAgent).sendNetworkScore(59);
@@ -904,11 +909,11 @@ public class WifiScoreReportTest extends WifiBaseTest {
}
/**
- * Verify confirmation duration is added for reporting low score when it is enabled in
- * config overlay
+ * Verify confirmation duration and RSSI check is added for reporting low score when it is
+ * enabled in config overlay
*/
@Test
- public void confirmationDurationIsAddedForSendingLowScore() throws Exception {
+ public void confirmationDurationAndRssiCheckIsAddedForSendingLowScore() throws Exception {
WifiConnectedNetworkScorerImpl scorerImpl = new WifiConnectedNetworkScorerImpl();
// Register Client for verification.
mWifiScoreReport.setWifiConnectedNetworkScorer(mAppBinder, scorerImpl);
@@ -929,11 +934,13 @@ public class WifiScoreReportTest extends WifiBaseTest {
verify(mNetworkAgent, never()).sendNetworkScore(anyInt());
mClock.mWallClockMillis = 10
+ mDeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS;
+ mWifiInfo.setRssi(-65);
scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 47);
mLooper.dispatchAll();
- verify(mNetworkAgent).sendNetworkScore(47);
+ verify(mNetworkAgent, never()).sendNetworkScore(47);
mClock.mWallClockMillis = 10
+ mDeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS + 3000;
+ mWifiInfo.setRssi(-68);
scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 46);
mLooper.dispatchAll();
verify(mNetworkAgent).sendNetworkScore(46);
@@ -958,6 +965,7 @@ public class WifiScoreReportTest extends WifiBaseTest {
mLooper.dispatchAll();
verify(mNetworkAgent, never()).sendNetworkScore(anyInt());
mClock.mWallClockMillis = 3000;
+ mWifiInfo.setRssi(-70);
scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 51);
mLooper.dispatchAll();
verify(mNetworkAgent).sendNetworkScore(51);