summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2020-06-18 23:43:47 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-18 23:43:47 +0000
commitd5bccec8ab7c8e60291e68f282088351af841233 (patch)
tree338f5a9bd04922a0104e91ad7a18075dc885c05c /tests
parentc5084bbfcbad824a3c789c99caa42dcb891190e8 (diff)
parent6d8147c663bfbe7507287054b0483feaf30d7c05 (diff)
Merge "Check deauth reason and FW alert for abnormal disconnection" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java39
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java14
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java51
4 files changed, 93 insertions, 14 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
index ce3eed098..bb03d42d7 100644
--- a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
@@ -84,6 +84,12 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
return def;
}
});
+ when(DeviceConfig.getLong(anyString(), anyString(), anyLong()))
+ .then(new AnswerWithArguments() {
+ public long answer(String namespace, String field, long def) {
+ return def;
+ }
+ });
when(DeviceConfig.getString(anyString(), anyString(), anyString()))
.then(new AnswerWithArguments() {
public String answer(String namespace, String field, String def) {
@@ -187,6 +193,18 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
mDeviceConfigFacade.getTxLinkSpeedLowThresholdMbps());
assertEquals(DeviceConfigFacade.DEFAULT_RX_LINK_SPEED_LOW_THRESHOLD_MBPS,
mDeviceConfigFacade.getRxLinkSpeedLowThresholdMbps());
+ assertEquals(DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_RSSI_POLL_VALID_TIME_MS,
+ mDeviceConfigFacade.getHealthMonitorRssiPollValidTimeMs());
+ assertEquals(DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_SHORT_CONNECTION_DURATION_THR_MS,
+ mDeviceConfigFacade.getHealthMonitorShortConnectionDurationThrMs());
+ assertEquals(DeviceConfigFacade.DEFAULT_ABNORMAL_DISCONNECTION_REASON_CODE_MASK,
+ mDeviceConfigFacade.getAbnormalDisconnectionReasonCodeMask());
+ assertEquals(DeviceConfigFacade.DEFAULT_NONSTATIONARY_SCAN_RSSI_VALID_TIME_MS,
+ mDeviceConfigFacade.getNonstationaryScanRssiValidTimeMs());
+ assertEquals(DeviceConfigFacade.DEFAULT_STATIONARY_SCAN_RSSI_VALID_TIME_MS,
+ mDeviceConfigFacade.getStationaryScanRssiValidTimeMs());
+ assertEquals(DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_FW_ALERT_VALID_TIME_MS,
+ mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs());
}
/**
@@ -277,7 +295,18 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
anyInt())).thenReturn(9);
when(DeviceConfig.getInt(anyString(), eq("rx_link_speed_low_threshold_mbps"),
anyInt())).thenReturn(10);
-
+ when(DeviceConfig.getInt(anyString(), eq("health_monitor_short_connection_duration_thr_ms"),
+ anyInt())).thenReturn(30_000);
+ when(DeviceConfig.getLong(anyString(), eq("abnormal_disconnection_reason_code_mask"),
+ anyLong())).thenReturn(0xffff_fff3_0000_ffffL);
+ when(DeviceConfig.getInt(anyString(), eq("health_monitor_rssi_poll_valid_time_ms"),
+ anyInt())).thenReturn(2000);
+ when(DeviceConfig.getInt(anyString(), eq("nonstationary_scan_rssi_valid_time_ms"),
+ anyInt())).thenReturn(4000);
+ when(DeviceConfig.getInt(anyString(), eq("stationary_scan_rssi_valid_time_ms"),
+ anyInt())).thenReturn(3000);
+ when(DeviceConfig.getInt(anyString(), eq("health_monitor_fw_alert_valid_time_ms"),
+ anyInt())).thenReturn(1000);
mOnPropertiesChangedListenerCaptor.getValue().onPropertiesChanged(null);
// Verifying fields are updated to the new values
@@ -326,5 +355,13 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
assertEquals(50000, mDeviceConfigFacade.getOverlappingConnectionDurationThresholdMs());
assertEquals(9, mDeviceConfigFacade.getTxLinkSpeedLowThresholdMbps());
assertEquals(10, mDeviceConfigFacade.getRxLinkSpeedLowThresholdMbps());
+ assertEquals(30_000,
+ mDeviceConfigFacade.getHealthMonitorShortConnectionDurationThrMs());
+ assertEquals(0xffff_fff3_0000_ffffL,
+ mDeviceConfigFacade.getAbnormalDisconnectionReasonCodeMask());
+ assertEquals(2000, mDeviceConfigFacade.getHealthMonitorRssiPollValidTimeMs());
+ assertEquals(4000, mDeviceConfigFacade.getNonstationaryScanRssiValidTimeMs());
+ assertEquals(3000, mDeviceConfigFacade.getStationaryScanRssiValidTimeMs());
+ assertEquals(1000, mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs());
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
index c89fe675a..e72f80887 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
@@ -73,6 +73,7 @@ public class WifiDiagnosticsTest extends WifiBaseTest {
@Mock WifiMetrics mWifiMetrics;
@Mock Clock mClock;
@Mock BugreportManager mBugreportManager;
+ @Mock WifiScoreCard mWifiScoreCard;
private long mBootTimeMs = 0L;
MockResources mResources;
WifiDiagnostics mWifiDiagnostics;
@@ -136,6 +137,7 @@ public class WifiDiagnosticsTest extends WifiBaseTest {
when(mWifiInjector.getJavaRuntime()).thenReturn(mJavaRuntime);
when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics);
when(mWifiInjector.getDeviceConfigFacade()).thenReturn(mDeviceConfigFacade);
+ when(mWifiInjector.getWifiScoreCard()).thenReturn(mWifiScoreCard);
when(mDeviceConfigFacade.getBugReportMinWindowMs()).thenReturn(BUG_REPORT_MIN_WINDOW_MS);
// needed to for the loop in WifiDiagnostics.readLogcatStreamLinesWithTimeout().
doAnswer(new AnswerWithArguments() {
@@ -744,6 +746,7 @@ public class WifiDiagnosticsTest extends WifiBaseTest {
assertArrayEquals(ALERT_DATA, alertReport.alertData);
verify(mWifiMetrics).logFirmwareAlert(ALERT_REASON_CODE);
+ verify(mWifiScoreCard).noteFirmwareAlert(ALERT_REASON_CODE);
}
/** Verifies that we skip the firmware and driver dumps if verbose is not enabled. */
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java
index 12796510e..21a00f9a1 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java
@@ -200,6 +200,18 @@ public class WifiHealthMonitorTest extends WifiBaseTest {
DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_RATIO_THR_NUMERATOR);
when(mDeviceConfigFacade.getHealthMonitorMinNumConnectionAttempt()).thenReturn(
DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT);
+ when(mDeviceConfigFacade.getHealthMonitorShortConnectionDurationThrMs()).thenReturn(
+ DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_SHORT_CONNECTION_DURATION_THR_MS);
+ when(mDeviceConfigFacade.getAbnormalDisconnectionReasonCodeMask()).thenReturn(
+ DeviceConfigFacade.DEFAULT_ABNORMAL_DISCONNECTION_REASON_CODE_MASK);
+ when(mDeviceConfigFacade.getHealthMonitorRssiPollValidTimeMs()).thenReturn(
+ DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_RSSI_POLL_VALID_TIME_MS);
+ when(mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs()).thenReturn(
+ DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_FW_ALERT_VALID_TIME_MS);
+ when(mDeviceConfigFacade.getNonstationaryScanRssiValidTimeMs()).thenReturn(
+ DeviceConfigFacade.DEFAULT_NONSTATIONARY_SCAN_RSSI_VALID_TIME_MS);
+ when(mDeviceConfigFacade.getStationaryScanRssiValidTimeMs()).thenReturn(
+ DeviceConfigFacade.DEFAULT_STATIONARY_SCAN_RSSI_VALID_TIME_MS);
mWifiHealthMonitor = new WifiHealthMonitor(mContext, mWifiInjector, mClock,
mWifiConfigManager, mWifiScoreCard, new Handler(mLooper.getLooper()), mWifiNative,
"some seed", mDeviceConfigFacade);
@@ -294,7 +306,7 @@ public class WifiHealthMonitorTest extends WifiBaseTest {
millisecondsPass(1000);
mWifiScoreCard.noteSignalPoll(mWifiInfo);
millisecondsPass(2000);
- int disconnectionReason = 3;
+ int disconnectionReason = 0;
mWifiScoreCard.noteNonlocalDisconnect(disconnectionReason);
millisecondsPass(10);
mWifiScoreCard.resetConnectionState();
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
index 1ad767c6e..e5739a1c8 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
@@ -104,7 +104,6 @@ public class WifiScoreCardTest extends WifiBaseTest {
void millisecondsPass(long ms) {
mMilliSecondsSinceBoot += ms;
when(mClock.getElapsedSinceBootMillis()).thenReturn(mMilliSecondsSinceBoot);
- when(mClock.getWallClockMillis()).thenReturn(mMilliSecondsSinceBoot + 1_500_000_000_000L);
}
void secondsPass(long s) {
@@ -158,6 +157,13 @@ public class WifiScoreCardTest extends WifiBaseTest {
DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_RATIO_THR_NUMERATOR);
when(mDeviceConfigFacade.getHealthMonitorMinNumConnectionAttempt()).thenReturn(
DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT);
+ when(mDeviceConfigFacade.getHealthMonitorShortConnectionDurationThrMs()).thenReturn(
+ DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_SHORT_CONNECTION_DURATION_THR_MS);
+ when(mDeviceConfigFacade.getAbnormalDisconnectionReasonCodeMask()).thenReturn(
+ DeviceConfigFacade.DEFAULT_ABNORMAL_DISCONNECTION_REASON_CODE_MASK);
+ when(mDeviceConfigFacade.getHealthMonitorRssiPollValidTimeMs()).thenReturn(3000);
+ // Disable FW alert time check by default
+ when(mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs()).thenReturn(-1);
when(mDeviceConfigFacade.getBugReportThresholdExtraRatio()).thenReturn(1);
mWifiScoreCard.enableVerboseLogging(true);
}
@@ -916,7 +922,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
// Disconnect from SSID_1
millisecondsPass(100);
- int disconnectionReason = 3;
+ int disconnectionReason = 4;
mWifiScoreCard.noteNonlocalDisconnect(disconnectionReason);
millisecondsPass(100);
mWifiScoreCard.resetConnectionState();
@@ -954,7 +960,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
checkShortConnectionExample(dailyStats, 0);
}
- private void makeShortConnectionExample() {
+ private void makeShortConnectionExample(boolean addFwAlert) {
mWifiScoreCard.noteConnectionAttempt(mWifiInfo, -53, mWifiInfo.getSSID());
millisecondsPass(5000);
mWifiInfo.setTxLinkSpeedMbps(100);
@@ -964,8 +970,11 @@ public class WifiScoreCardTest extends WifiBaseTest {
millisecondsPass(1000);
mWifiScoreCard.noteSignalPoll(mWifiInfo);
millisecondsPass(2000);
- int disconnectionReason = 3;
+ int disconnectionReason = 34;
mWifiScoreCard.noteNonlocalDisconnect(disconnectionReason);
+ if (addFwAlert) {
+ mWifiScoreCard.noteFirmwareAlert(6);
+ }
millisecondsPass(1000);
mWifiScoreCard.resetConnectionState();
}
@@ -1007,12 +1016,13 @@ public class WifiScoreCardTest extends WifiBaseTest {
}
/**
- * Check network stats after RSSI poll and disconnection.
+ * Check network stats after RSSI poll and disconnection, pass FW alert check
*/
@Test
- public void testNetworkRssiPollShortNonlocalDisconnection() throws Exception {
+ public void testNetworkRssiPollShortNonlocalDisconnectionPassFwAlertCheck() throws Exception {
+ when(mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs()).thenReturn(2000);
// 1st connection session
- makeShortConnectionExample();
+ makeShortConnectionExample(/*addFwAlert*/true);
// 2nd connection session
makeNormalConnectionExample();
@@ -1029,6 +1039,23 @@ public class WifiScoreCardTest extends WifiBaseTest {
}
/**
+ * Check network stats after RSSI poll and disconnection, fail FW alert check
+ */
+ @Test
+ public void testNetworkRssiPollShortNonlocalDisconnectionFailFwAlertCheck() throws Exception {
+ when(mDeviceConfigFacade.getHealthMonitorFwAlertValidTimeMs()).thenReturn(2000);
+ // 1st connection session
+ makeShortConnectionExample(/*addFwAlert*/false);
+ // 2nd connection session
+ makeNormalConnectionExample();
+
+ PerNetwork perNetwork = mWifiScoreCard.fetchByNetwork(mWifiInfo.getSSID());
+ NetworkConnectionStats dailyStats = perNetwork.getRecentStats();
+ assertEquals(0, dailyStats.getCount(CNT_SHORT_CONNECTION_NONLOCAL));
+ assertEquals(0, dailyStats.getCount(CNT_DISCONNECTION_NONLOCAL));
+ }
+
+ /**
* Check network stats after short connection with an old RSSI polling
*/
@Test
@@ -1130,7 +1157,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
@Test
public void testUpdateAfterDailyDetection() throws Exception {
for (int i = 0; i < DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT; i++) {
- makeShortConnectionExample();
+ makeShortConnectionExample(/*addFwAlert*/false);
}
PerNetwork perNetwork = mWifiScoreCard.fetchByNetwork(mWifiInfo.getSSID());
@@ -1145,7 +1172,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
@Test
public void testUpdateAfterSwBuildChange() throws Exception {
for (int i = 0; i < DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT; i++) {
- makeShortConnectionExample();
+ makeShortConnectionExample(/*addFwAlert*/false);
}
PerNetwork perNetwork = mWifiScoreCard.fetchByNetwork(mWifiInfo.getSSID());
perNetwork.updateAfterDailyDetection();
@@ -1165,7 +1192,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
private void makeRecentStatsWithShortConnection() {
for (int i = 0; i < DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT; i++) {
- makeShortConnectionExample();
+ makeShortConnectionExample(/*addFwAlert*/false);
}
}
@@ -1196,7 +1223,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
@Test
public void testDailyDetectionWithInsufficientRecentStats() throws Exception {
PerNetwork perNetwork = mWifiScoreCard.lookupNetwork(mWifiInfo.getSSID());
- makeShortConnectionExample();
+ makeShortConnectionExample(/*addFwAlert*/false);
FailureStats statsDec = new FailureStats();
FailureStats statsInc = new FailureStats();
@@ -1269,7 +1296,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
makeRecentStatsWithGoodConnection();
// Add a small number of failures for each failure type after the SW build change
for (int i = 0; i < mDeviceConfigFacade.getAuthFailureCountMin() - 1; i++) {
- makeShortConnectionExample();
+ makeShortConnectionExample(/*addFwAlert*/false);
makeAssocTimeOutExample();
makeAuthFailureExample();
}