From 9f67db616a8317ca00941658d2679b78293f0d44 Mon Sep 17 00:00:00 2001 From: xshu Date: Wed, 27 Nov 2019 13:52:48 -0800 Subject: Don't trigger watchdog for network related failures APs are using REASON_CODE_AP_UNABLE_TO_HANDLE_NEW_STA to redirect devices. EAP failure happens when there is a problem with the device's credential. In the above cases, we should just block the AP instead of trying to rely on the Watchdog restart. Bug: 139287182 Test: atest FrameworksWifiTests Change-Id: I15bc1a7917779584c369baa9728d1a26cff54095 --- .../com/android/server/wifi/ClientModeImpl.java | 13 +++++++---- .../android/server/wifi/ClientModeImplTest.java | 27 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index cc859ebe1..7338e8a86 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -3514,10 +3514,12 @@ public class ClientModeImpl extends StateMachine { : WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_REJECTION, WifiMetricsProto.ConnectionEvent.HLF_NONE, level2FailureReason); - mWifiInjector.getWifiLastResortWatchdog() - .noteConnectionFailureAndTriggerIfNeeded( - getTargetSsid(), bssid, - WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION); + if (reasonCode != REASON_CODE_AP_UNABLE_TO_HANDLE_NEW_STA) { + mWifiInjector.getWifiLastResortWatchdog() + .noteConnectionFailureAndTriggerIfNeeded( + getTargetSsid(), bssid, + WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION); + } break; case WifiMonitor.AUTHENTICATION_FAILURE_EVENT: mWifiDiagnostics.captureBugReportData( @@ -3574,7 +3576,8 @@ public class ClientModeImpl extends StateMachine { WifiMetrics.ConnectionEvent.FAILURE_AUTHENTICATION_FAILURE, WifiMetricsProto.ConnectionEvent.HLF_NONE, level2FailureReason); - if (reasonCode != WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD) { + if (reasonCode != WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD && reasonCode + != WifiManager.ERROR_AUTH_FAILURE_EAP_FAILURE) { mWifiInjector.getWifiLastResortWatchdog() .noteConnectionFailureAndTriggerIfNeeded( getTargetSsid(), diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 7946ecbc0..33d1d4bf5 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -2984,8 +2984,8 @@ public class ClientModeImplTest extends WifiBaseTest { } /** - * Verifies that WifiLastResortWatchdog and BssidBlocklistMonitor is notified of - * association rejection of type REASON_CODE_AP_UNABLE_TO_HANDLE_NEW_STA. + * Verifies that the BssidBlocklistMonitor is notified, but the WifiLastResortWatchdog is + * not notified of association rejections of type REASON_CODE_AP_UNABLE_TO_HANDLE_NEW_STA. * @throws Exception */ @Test @@ -2996,7 +2996,7 @@ public class ClientModeImplTest extends WifiBaseTest { mCmi.sendMessage(WifiMonitor.ASSOCIATION_REJECTION_EVENT, 0, ClientModeImpl.REASON_CODE_AP_UNABLE_TO_HANDLE_NEW_STA, sBSSID); mLooper.dispatchAll(); - verify(mWifiLastResortWatchdog).noteConnectionFailureAndTriggerIfNeeded( + verify(mWifiLastResortWatchdog, never()).noteConnectionFailureAndTriggerIfNeeded( anyString(), anyString(), anyInt()); verify(mBssidBlocklistMonitor).handleBssidConnectionFailure(sBSSID, sSSID, BssidBlocklistMonitor.REASON_AP_UNABLE_TO_HANDLE_NEW_STA); @@ -3040,6 +3040,27 @@ public class ClientModeImplTest extends WifiBaseTest { BssidBlocklistMonitor.REASON_WRONG_PASSWORD); } + /** + * Verifies that WifiLastResortWatchdog is not notified of authentication failures of type + * ERROR_AUTH_FAILURE_EAP_FAILURE. + * @throws Exception + */ + @Test + public void testEapFailureIsIgnoredByWatchdog() throws Exception { + // Setup CONNECT_MODE & a WifiConfiguration + initializeAndAddNetworkAndVerifySuccess(); + mCmi.sendMessage(ClientModeImpl.CMD_START_CONNECT, 0, 0, sBSSID); + mCmi.sendMessage(WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT, 0, 0, + new StateChangeResult(0, sWifiSsid, sBSSID, SupplicantState.COMPLETED)); + mCmi.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT, + WifiManager.ERROR_AUTH_FAILURE_EAP_FAILURE); + mLooper.dispatchAll(); + verify(mWifiLastResortWatchdog, never()).noteConnectionFailureAndTriggerIfNeeded( + anyString(), anyString(), anyInt()); + verify(mBssidBlocklistMonitor).handleBssidConnectionFailure(sBSSID, sSSID, + BssidBlocklistMonitor.REASON_EAP_FAILURE); + } + /** * Verifies that WifiLastResortWatchdog is notified of other types of authentication failures. * @throws Exception -- cgit v1.2.3