summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMingguang Xu <mingguangxu@google.com>2020-08-12 00:17:54 -0700
committerMingguang Xu <mingguangxu@google.com>2020-08-14 18:59:33 +0000
commit3d896dcda63181f8a2a92fb3d26b0d74dc766b10 (patch)
treec2448a825030fd300f63e307c94cb935f5bff163 /tests
parent8e3262babe2a9562fd68df2bc8ebab65a8a8be92 (diff)
Wifi usability: Add minimum confirmation duration for sending network score to connectivity service when score breaches
1. Add a flag in config overlay to control whether adding minimum confirmation duration is enabled or not. By default it is not enabled. 2. The minimum confirmation duration is configurable via DeviceConfigFacade. 3. The minimum confirmation duration only applies to sending network score to ConnectivityService. No confirmation duration is needed for triggering NUD check and WiFi metric collection. Bug: 163348782 Test: atest com.android.server.wifi Signed-off-by: Mingguang Xu <mingguangxu@google.com> Change-Id: I0abe68f72c64c26fc75e8bc5edc7d341eae54133 Merged-In: I0abe68f72c64c26fc75e8bc5edc7d341eae54133
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java10
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java154
2 files changed, 163 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
index bb03d42d7..43a16fe4c 100644
--- a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
@@ -205,6 +205,10 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
mDeviceConfigFacade.getStationaryScanRssiValidTimeMs());
assertEquals(DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_FW_ALERT_VALID_TIME_MS,
mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs());
+ assertEquals(DeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS,
+ mDeviceConfigFacade.getMinConfirmationDurationSendLowScoreMs());
+ assertEquals(DeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS,
+ mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs());
}
/**
@@ -307,6 +311,10 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
anyInt())).thenReturn(3000);
when(DeviceConfig.getInt(anyString(), eq("health_monitor_fw_alert_valid_time_ms"),
anyInt())).thenReturn(1000);
+ when(DeviceConfig.getInt(anyString(), eq("min_confirmation_duration_send_low_score_ms"),
+ anyInt())).thenReturn(4000);
+ when(DeviceConfig.getInt(anyString(), eq("min_confirmation_duration_send_high_score_ms"),
+ anyInt())).thenReturn(1000);
mOnPropertiesChangedListenerCaptor.getValue().onPropertiesChanged(null);
// Verifying fields are updated to the new values
@@ -363,5 +371,7 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
assertEquals(4000, mDeviceConfigFacade.getNonstationaryScanRssiValidTimeMs());
assertEquals(3000, mDeviceConfigFacade.getStationaryScanRssiValidTimeMs());
assertEquals(1000, mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs());
+ assertEquals(4000, mDeviceConfigFacade.getMinConfirmationDurationSendLowScoreMs());
+ assertEquals(1000, mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs());
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
index 674ff8c9d..7ba931523 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
@@ -101,6 +101,7 @@ public class WifiScoreReportTest extends WifiBaseTest {
@Mock WifiNative mWifiNative;
@Mock BssidBlocklistMonitor mBssidBlocklistMonitor;
@Mock Network mNetwork;
+ @Mock DeviceConfigFacade mDeviceConfigFacade;
private TestLooper mLooper;
public class WifiConnectedNetworkScorerImpl extends IWifiConnectedNetworkScorer.Stub {
@@ -174,6 +175,9 @@ public class WifiScoreReportTest extends WifiBaseTest {
when(resources.getInteger(
R.integer.config_wifiFrameworkMinPacketPerSecondHighTraffic))
.thenReturn(100);
+ when(resources.getBoolean(
+ R.bool.config_wifiMinConfirmationDurationSendNetworkScoreEnabled))
+ .thenReturn(false);
}
/**
@@ -197,8 +201,13 @@ public class WifiScoreReportTest extends WifiBaseTest {
mScoringParams = new ScoringParams();
mWifiThreadRunner = new WifiThreadRunner(new Handler(mLooper.getLooper()));
mWifiScoreReport = new WifiScoreReport(mScoringParams, mClock, mWifiMetrics, mWifiInfo,
- mWifiNative, mBssidBlocklistMonitor, mWifiThreadRunner);
+ mWifiNative, mBssidBlocklistMonitor, mWifiThreadRunner,
+ mDeviceConfigFacade, mContext);
mWifiScoreReport.setNetworkAgent(mNetworkAgent);
+ when(mDeviceConfigFacade.getMinConfirmationDurationSendLowScoreMs()).thenReturn(
+ DeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS);
+ when(mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs()).thenReturn(
+ DeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS);
}
/**
@@ -833,4 +842,147 @@ public class WifiScoreReportTest extends WifiBaseTest {
mLooper.dispatchAll();
verify(mBssidBlocklistMonitor, never()).blockBssidForDurationMs(any(), any(), anyLong());
}
+
+ /**
+ * Verify confirmation duration is not added when it is not enabled in config overlay by default
+ */
+ @Test
+ public void confirmationDurationIsNotAddedWhenItIsNotEnabledInConfigOverlay() throws Exception {
+ WifiConnectedNetworkScorerImpl scorerImpl = new WifiConnectedNetworkScorerImpl();
+ // Register Client for verification.
+ mWifiScoreReport.setWifiConnectedNetworkScorer(mAppBinder, scorerImpl);
+ when(mNetwork.getNetId()).thenReturn(TEST_NETWORK_ID);
+ mWifiScoreReport.startConnectedNetworkScorer(TEST_NETWORK_ID);
+ mClock.mStepMillis = 0;
+
+ mClock.mWallClockMillis = 10;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 49);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(anyInt());
+ }
+
+ /**
+ * Verify confirmation duration is not added when there is no score breacht
+ */
+ @Test
+ public void confirmationDurationIsNotAddedWhenThereIsNoScoreBreach() throws Exception {
+ WifiConnectedNetworkScorerImpl scorerImpl = new WifiConnectedNetworkScorerImpl();
+ // Register Client for verification.
+ mWifiScoreReport.setWifiConnectedNetworkScorer(mAppBinder, scorerImpl);
+ when(mNetwork.getNetId()).thenReturn(TEST_NETWORK_ID);
+ mWifiScoreReport.startConnectedNetworkScorer(TEST_NETWORK_ID);
+ mClock.mStepMillis = 0;
+ when(mContext.getResources().getBoolean(
+ R.bool.config_wifiMinConfirmationDurationSendNetworkScoreEnabled)).thenReturn(true);
+
+ mClock.mWallClockMillis = 10;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 60);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(60);
+ mClock.mWallClockMillis = 3010;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 59);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(59);
+ mClock.mWallClockMillis = 6010;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 58);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(58);
+ }
+
+ /**
+ * Verify confirmation duration is added for reporting low score when it is enabled in
+ * config overlay
+ */
+ @Test
+ public void confirmationDurationIsAddedForSendingLowScore() throws Exception {
+ WifiConnectedNetworkScorerImpl scorerImpl = new WifiConnectedNetworkScorerImpl();
+ // Register Client for verification.
+ mWifiScoreReport.setWifiConnectedNetworkScorer(mAppBinder, scorerImpl);
+ when(mNetwork.getNetId()).thenReturn(TEST_NETWORK_ID);
+ mWifiScoreReport.startConnectedNetworkScorer(TEST_NETWORK_ID);
+ mClock.mStepMillis = 0;
+ when(mContext.getResources().getBoolean(
+ R.bool.config_wifiMinConfirmationDurationSendNetworkScoreEnabled)).thenReturn(true);
+
+ mClock.mWallClockMillis = 10;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 49);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent, never()).sendNetworkScore(anyInt());
+ mClock.mWallClockMillis = 10
+ + mDeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS - 1;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 48);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent, never()).sendNetworkScore(anyInt());
+ mClock.mWallClockMillis = 10
+ + mDeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 47);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(47);
+ mClock.mWallClockMillis = 10
+ + mDeviceConfigFacade.DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS + 3000;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 46);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(46);
+ }
+
+ /**
+ * Verify confirmation duration is not added for reporting high score with default zero value
+ */
+ @Test
+ public void confirmationDurationIsNotAddedForSendingHighScore() throws Exception {
+ WifiConnectedNetworkScorerImpl scorerImpl = new WifiConnectedNetworkScorerImpl();
+ // Register Client for verification.
+ mWifiScoreReport.setWifiConnectedNetworkScorer(mAppBinder, scorerImpl);
+ when(mNetwork.getNetId()).thenReturn(TEST_NETWORK_ID);
+ mWifiScoreReport.startConnectedNetworkScorer(TEST_NETWORK_ID);
+ mClock.mStepMillis = 0;
+ when(mContext.getResources().getBoolean(
+ R.bool.config_wifiMinConfirmationDurationSendNetworkScoreEnabled)).thenReturn(true);
+
+ mClock.mWallClockMillis = 10;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 49);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent, never()).sendNetworkScore(anyInt());
+ mClock.mWallClockMillis = 3000;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 51);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(51);
+ mClock.mWallClockMillis = 6000;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 52);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(52);
+ }
+
+ /**
+ * Verify confirmation duration is added for reporting high score with non-zero value
+ */
+ @Test
+ public void confirmationDurationIsAddedForSendingHighScore() throws Exception {
+ WifiConnectedNetworkScorerImpl scorerImpl = new WifiConnectedNetworkScorerImpl();
+ // Register Client for verification.
+ mWifiScoreReport.setWifiConnectedNetworkScorer(mAppBinder, scorerImpl);
+ when(mNetwork.getNetId()).thenReturn(TEST_NETWORK_ID);
+ mWifiScoreReport.startConnectedNetworkScorer(TEST_NETWORK_ID);
+ mClock.mStepMillis = 0;
+ when(mContext.getResources().getBoolean(
+ R.bool.config_wifiMinConfirmationDurationSendNetworkScoreEnabled)).thenReturn(true);
+ when(mDeviceConfigFacade.getMinConfirmationDurationSendHighScoreMs()).thenReturn(4000);
+
+ mClock.mWallClockMillis = 10;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 49);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent, never()).sendNetworkScore(anyInt());
+ mClock.mWallClockMillis = 3000;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 51);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent, never()).sendNetworkScore(anyInt());
+ mClock.mWallClockMillis = 6999;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 52);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent, never()).sendNetworkScore(anyInt());
+ mClock.mWallClockMillis = 7000;
+ scorerImpl.mScoreUpdateObserver.notifyScoreUpdate(scorerImpl.mSessionId, 53);
+ mLooper.dispatchAll();
+ verify(mNetworkAgent).sendNetworkScore(53);
+ }
}