diff options
author | Mingguang Xu <mingguangxu@google.com> | 2020-08-14 19:19:57 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-08-14 19:19:57 +0000 |
commit | aee8c8f54944e56a7d34855c2380cb746f70e3c3 (patch) | |
tree | 16e59958827b7e428b3c33e94b2ccb3c3a7459d5 /tests | |
parent | ae0ff85e697a2919fc743d91fc8bf7b25e1c3be8 (diff) | |
parent | 3d896dcda63181f8a2a92fb3d26b0d74dc766b10 (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 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java | 10 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java | 154 |
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 9402e9900..82dbbe941 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); } /** @@ -847,4 +856,147 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiScoreReport.setWifiConnectedNetworkScorer(mAppBinder, mWifiConnectedNetworkScorer); assertEquals(ConnectedScore.WIFI_MAX_SCORE, mWifiInfo.getScore()); } + + /** + * 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); + } } |