diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-04-01 07:51:37 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-01 07:51:37 +0000 |
commit | 48a31819c11d3ee7508f3fb364617925684c362b (patch) | |
tree | 8d66b0107ce10b6d3c29286d32c2a3dcf0e09245 /tests | |
parent | 3ec62aa514eaa71e23bd181261514775603de9cd (diff) | |
parent | ae5308b028fe16a583b845e66f660ba754ab75c8 (diff) |
Merge "Take bugReport when it hits abnormal connection/disconnection" into rvc-dev
Diffstat (limited to 'tests')
4 files changed, 51 insertions, 19 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 0679b8c4f..1930cd15a 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -551,7 +551,12 @@ public class ClientModeImplTest extends WifiBaseTest { mConnectedNetwork = spy(WifiConfigurationTestUtil.createOpenNetwork()); when(mNullAsyncChannel.sendMessageSynchronously(any())).thenReturn(null); when(mWifiScoreCard.getL2KeyAndGroupHint(any())).thenReturn(new Pair<>(null, null)); - when(mDeviceConfigFacade.isAbnormalEapAuthFailureBugreportEnabled()).thenReturn(true); + when(mDeviceConfigFacade.isAbnormalDisconnectionBugreportEnabled()).thenReturn(true); + when(mDeviceConfigFacade.isAbnormalConnectionFailureBugreportEnabled()).thenReturn(true); + when(mWifiScoreCard.detectAbnormalConnectionFailure(anyString())) + .thenReturn(WifiHealthMonitor.REASON_NO_FAILURE); + when(mWifiScoreCard.detectAbnormalDisconnection()) + .thenReturn(WifiHealthMonitor.REASON_NO_FAILURE); when(mThroughputPredictor.predictMaxTxThroughput(any())).thenReturn(90); when(mThroughputPredictor.predictMaxRxThroughput(any())).thenReturn(80); } @@ -1724,8 +1729,6 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWifiConfigManager).updateNetworkSelectionStatus(anyInt(), eq(WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD)); - verify(mWifiScoreCard, never()).detectAbnormalAuthFailure(any()); - assertEquals("DisconnectedState", getCurrentState().getName()); } @@ -1757,6 +1760,8 @@ public class ClientModeImplTest extends WifiBaseTest { .startMocking(); when(SubscriptionManager.getDefaultDataSubscriptionId()).thenReturn(DATA_SUBID); when(SubscriptionManager.isValidSubscriptionId(anyInt())).thenReturn(true); + when(mWifiScoreCard.detectAbnormalConnectionFailure(anyString())) + .thenReturn(WifiHealthMonitor.REASON_AUTH_FAILURE); mCmi.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT, WifiManager.ERROR_AUTH_FAILURE_EAP_FAILURE, @@ -1767,8 +1772,9 @@ public class ClientModeImplTest extends WifiBaseTest { WifiNative.EAP_SIM_VENDOR_SPECIFIC_CERT_EXPIRED, config); verify(mDataTelephonyManager).resetCarrierKeysForImsiEncryption(); mockSession.finishMocking(); - verify(mWifiScoreCard).detectAbnormalAuthFailure(anyString()); - verify(mDeviceConfigFacade).isAbnormalEapAuthFailureBugreportEnabled(); + verify(mDeviceConfigFacade).isAbnormalConnectionFailureBugreportEnabled(); + verify(mWifiScoreCard).detectAbnormalConnectionFailure(anyString()); + verify(mWifiDiagnostics).takeBugReport(anyString(), anyString()); } /** @@ -1799,8 +1805,6 @@ public class ClientModeImplTest extends WifiBaseTest { mLooper.dispatchAll(); verify(mDataTelephonyManager, never()).resetCarrierKeysForImsiEncryption(); - verify(mWifiScoreCard).detectAbnormalAuthFailure(null); - verify(mDeviceConfigFacade).isAbnormalEapAuthFailureBugreportEnabled(); } /** @@ -1828,8 +1832,6 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWifiConfigManager).updateNetworkSelectionStatus(anyInt(), eq(WifiConfiguration.NetworkSelectionStatus .DISABLED_AUTHENTICATION_NO_SUBSCRIPTION)); - verify(mWifiScoreCard, never()).detectAbnormalAuthFailure(null); - verify(mDeviceConfigFacade, never()).isAbnormalEapAuthFailureBugreportEnabled(); } @Test @@ -1851,6 +1853,7 @@ public class ClientModeImplTest extends WifiBaseTest { mLooper.dispatchAll(); assertEquals("DisconnectedState", getCurrentState().getName()); + verify(mWifiDiagnostics, never()).takeBugReport(anyString(), anyString()); } @@ -1865,6 +1868,8 @@ public class ClientModeImplTest extends WifiBaseTest { @Test public void disconnect() throws Exception { + when(mWifiScoreCard.detectAbnormalDisconnection()) + .thenReturn(WifiHealthMonitor.REASON_SHORT_CONNECTION_NONLOCAL); InOrder inOrderWifiLockManager = inOrder(mWifiLockManager); connect(); inOrderWifiLockManager.verify(mWifiLockManager).updateWifiClientConnected(true); @@ -1879,6 +1884,8 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWifiNetworkSuggestionsManager).handleDisconnect(any(), any()); assertEquals("DisconnectedState", getCurrentState().getName()); inOrderWifiLockManager.verify(mWifiLockManager).updateWifiClientConnected(false); + verify(mWifiScoreCard).detectAbnormalDisconnection(); + verify(mWifiDiagnostics).takeBugReport(anyString(), anyString()); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java index d6a05c7a3..b7136d986 100644 --- a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java @@ -170,9 +170,12 @@ public class DeviceConfigFacadeTest extends WifiBaseTest { mDeviceConfigFacade.getAggressiveMacRandomizationSsidAllowlist()); assertEquals(Collections.emptySet(), mDeviceConfigFacade.getAggressiveMacRandomizationSsidBlocklist()); - assertEquals(false, mDeviceConfigFacade.isAbnormalEapAuthFailureBugreportEnabled()); + assertEquals(false, mDeviceConfigFacade.isAbnormalConnectionFailureBugreportEnabled()); + assertEquals(false, mDeviceConfigFacade.isAbnormalDisconnectionBugreportEnabled()); assertEquals(DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT, mDeviceConfigFacade.getHealthMonitorMinNumConnectionAttempt()); + assertEquals(DeviceConfigFacade.DEFAULT_BUG_REPORT_MIN_WINDOW_MS, + mDeviceConfigFacade.getBugReportMinWindowMs()); } /** @@ -242,10 +245,15 @@ public class DeviceConfigFacadeTest extends WifiBaseTest { anyString())).thenReturn(testSsidList); when(DeviceConfig.getString(anyString(), eq("aggressive_randomization_ssid_blocklist"), anyString())).thenReturn(testSsidList); - when(DeviceConfig.getBoolean(anyString(), eq("abnormal_eap_auth_failure_bugreport_enabled"), + when(DeviceConfig.getBoolean(anyString(), + eq("abnormal_connection_failure_bugreport_enabled"), + anyBoolean())).thenReturn(true); + when(DeviceConfig.getBoolean(anyString(), eq("abnormal_disconnection_bugreport_enabled"), anyBoolean())).thenReturn(true); when(DeviceConfig.getInt(anyString(), eq("health_monitor_min_num_connection_attempt"), anyInt())).thenReturn(20); + when(DeviceConfig.getInt(anyString(), eq("bug_report_min_window_ms"), + anyInt())).thenReturn(1000); mOnPropertiesChangedListenerCaptor.getValue().onPropertiesChanged(null); @@ -285,7 +293,9 @@ public class DeviceConfigFacadeTest extends WifiBaseTest { mDeviceConfigFacade.getAggressiveMacRandomizationSsidAllowlist()); assertEquals(testSsidSet, mDeviceConfigFacade.getAggressiveMacRandomizationSsidBlocklist()); - assertEquals(true, mDeviceConfigFacade.isAbnormalEapAuthFailureBugreportEnabled()); + assertEquals(true, mDeviceConfigFacade.isAbnormalConnectionFailureBugreportEnabled()); + assertEquals(true, mDeviceConfigFacade.isAbnormalDisconnectionBugreportEnabled()); assertEquals(20, mDeviceConfigFacade.getHealthMonitorMinNumConnectionAttempt()); + assertEquals(1000, mDeviceConfigFacade.getBugReportMinWindowMs()); } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java index acfc78d7e..6b235b9f7 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java @@ -64,6 +64,7 @@ public class WifiDiagnosticsTest extends WifiBaseTest { @Mock BuildProperties mBuildProperties; @Mock Context mContext; @Mock WifiInjector mWifiInjector; + @Mock DeviceConfigFacade mDeviceConfigFacade; @Spy FakeWifiLog mLog; @Mock LastMileLogger mLastMileLogger; @Mock Runtime mJavaRuntime; @@ -86,6 +87,7 @@ public class WifiDiagnosticsTest extends WifiBaseTest { private static final int[] FATAL_FW_ALERT_LIST = {256, 257, 258}; /** Mock a non fatal firmware alert */ private static final int NON_FATAL_FW_ALERT = 0; + private static final int BUG_REPORT_MIN_WINDOW_MS = 3600_000; private WifiNative.RingBufferStatus mFakeRbs; /** @@ -131,7 +133,8 @@ public class WifiDiagnosticsTest extends WifiBaseTest { when(mWifiInjector.makeLog(anyString())).thenReturn(mLog); when(mWifiInjector.getJavaRuntime()).thenReturn(mJavaRuntime); when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics); - + when(mWifiInjector.getDeviceConfigFacade()).thenReturn(mDeviceConfigFacade); + when(mDeviceConfigFacade.getBugReportMinWindowMs()).thenReturn(BUG_REPORT_MIN_WINDOW_MS); mWifiDiagnostics = new WifiDiagnostics( mContext, mWifiInjector, mWifiNative, mBuildProperties, mLastMileLogger, mClock); mWifiNative.enableVerboseLogging(0); @@ -888,7 +891,7 @@ public class WifiDiagnosticsTest extends WifiBaseTest { mWifiDiagnostics.takeBugReport("", ""); verify(mBugreportManager, times(1)).requestBugreport(any(), any(), any()); // 2nd attempt should fail - when(mClock.getWallClockMillis()).thenReturn(1000_000L); + when(mClock.getWallClockMillis()).thenReturn(BUG_REPORT_MIN_WINDOW_MS - 20L); mWifiDiagnostics.takeBugReport("", ""); verify(mBugreportManager, times(1)).requestBugreport(any(), any(), any()); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java index e98b03acf..d6dc020b9 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java @@ -154,6 +154,7 @@ 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.getBugReportThresholdExtraRatio()).thenReturn(1); mWifiScoreCard.enableVerboseLogging(true); } @@ -1106,6 +1107,8 @@ public class WifiScoreCardTest extends WifiBaseTest { perNetwork.updateAfterDailyDetection(); checkShortConnectionExample(perNetwork.getRecentStats(), 1); checkShortConnectionExample(perNetwork.getStatsPrevBuild(), 0); + assertEquals(WifiHealthMonitor.REASON_NO_FAILURE, + mWifiScoreCard.detectAbnormalConnectionFailure(mWifiInfo.getSSID())); } /** @@ -1131,11 +1134,13 @@ public class WifiScoreCardTest extends WifiBaseTest { // Add >2x failures after the SW build change int numBadConnectionDays = 4; for (int i = 0; i < numBadConnectionDays; i++) { - makeRecentStatsWithShortConnection(); makeRecentStatsWithAssocTimeOut(); makeRecentStatsWithAuthFailure(); + makeRecentStatsWithShortConnection(); } + assertEquals(WifiHealthMonitor.REASON_SHORT_CONNECTION_NONLOCAL, + mWifiScoreCard.detectAbnormalDisconnection()); FailureStats statsDec = new FailureStats(); FailureStats statsInc = new FailureStats(); FailureStats statsHigh = new FailureStats(); @@ -1175,6 +1180,8 @@ public class WifiScoreCardTest extends WifiBaseTest { checkStatsDeltaExample(statsDec, 0); checkStatsDeltaExample(statsInc, 0); checkStatsDeltaExample(statsHigh, 0); + assertEquals(WifiHealthMonitor.REASON_NO_FAILURE, + mWifiScoreCard.detectAbnormalConnectionFailure(mWifiInfo.getSSID())); } /** @@ -1197,10 +1204,12 @@ public class WifiScoreCardTest extends WifiBaseTest { for (int i = 0; i < numGoodConnectionDays; i++) { makeRecentStatsWithGoodConnection(); } - makeRecentStatsWithShortConnection(); makeRecentStatsWithAssocTimeOut(); makeRecentStatsWithAuthFailure(); + makeRecentStatsWithShortConnection(); + assertEquals(WifiHealthMonitor.REASON_NO_FAILURE, + mWifiScoreCard.detectAbnormalConnectionFailure(mWifiInfo.getSSID())); FailureStats statsDec = new FailureStats(); FailureStats statsInc = new FailureStats(); FailureStats statsHigh = new FailureStats(); @@ -1215,9 +1224,11 @@ public class WifiScoreCardTest extends WifiBaseTest { PerNetwork perNetwork = mWifiScoreCard.lookupNetwork(mWifiInfo.getSSID()); makeRecentStatsWithShortConnection(); // Day 1 - makeRecentStatsWithAssocTimeOut(); makeRecentStatsWithAuthFailure(); + makeRecentStatsWithAssocTimeOut(); + assertEquals(WifiHealthMonitor.REASON_ASSOC_TIMEOUT, + mWifiScoreCard.detectAbnormalConnectionFailure(mWifiInfo.getSSID())); FailureStats statsDec = new FailureStats(); FailureStats statsInc = new FailureStats(); FailureStats statsHigh = new FailureStats(); @@ -1226,12 +1237,13 @@ public class WifiScoreCardTest extends WifiBaseTest { checkStatsDeltaExample(statsDec, 0); checkStatsDeltaExample(statsInc, 0); checkStatsDeltaExample(statsHigh, 1); - assertEquals(false, mWifiScoreCard.detectAbnormalAuthFailure(mWifiInfo.getSSID())); } @Test public void testHighAuthFailureRate() throws Exception { + makeRecentStatsWithGoodConnection(); makeRecentStatsWithAuthFailure(); - assertEquals(true, mWifiScoreCard.detectAbnormalAuthFailure(mWifiInfo.getSSID())); + assertEquals(WifiHealthMonitor.REASON_AUTH_FAILURE, + mWifiScoreCard.detectAbnormalConnectionFailure(mWifiInfo.getSSID())); } } |