diff options
author | Sohani Rao <sohanirao@google.com> | 2017-01-23 15:46:46 -0800 |
---|---|---|
committer | Sohani Rao <sohanirao@google.com> | 2017-02-03 14:50:45 -0800 |
commit | 1241ac94aa2f5d6c5f5c3e935c7f7baa8045ee5c (patch) | |
tree | f17db1f2b7bd85538156cfcd85a79ebab44a9708 /service | |
parent | ecccdb6c28ebea5fa0453917309e1d3836eb7068 (diff) |
WifiMonitor doesn't handle incorrect password authentication failure
This change updates dispatchEvent() in WifiMonitor, that parses native
events, to handle auth failure due to incorrect password. The absence
of this check causes the SupplicantTracker to send wrong authentication
status in the broadcast intent for Supplicant state change.
WifiMonitor also sends a message to subscribed interfaces with the
authentication failure event. In case of a wrong password, the event
SSID_TEMP_DISABLE is generated subsequently. WifiStateMachine, which
recieves both events, will erroneously update the WifiConfigManager
twice for the same authentication failure. To avoid this, this CL adds
a reason code in the message which can be used to conditionally update
WifiConfigManager.
Bug: 30080982
Test: Functionality tests and unit tests
Change-Id: I3154e6b52ace0b7c2295dc796325747439c0ac43
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiMonitor.java | 26 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 5 |
2 files changed, 24 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java index 1ee04ba99..acdd06da0 100644 --- a/service/java/com/android/server/wifi/WifiMonitor.java +++ b/service/java/com/android/server/wifi/WifiMonitor.java @@ -37,8 +37,8 @@ import android.util.SparseArray; import com.android.internal.util.Protocol; import com.android.internal.util.StateMachine; import com.android.server.wifi.hotspot2.IconEvent; -import com.android.server.wifi.hotspot2.WnmData; import com.android.server.wifi.hotspot2.Utils; +import com.android.server.wifi.hotspot2.WnmData; import com.android.server.wifi.p2p.WifiP2pServiceImpl.P2pStatus; import com.android.server.wifi.util.TelephonyUtil.SimAuthRequestData; @@ -128,7 +128,6 @@ public class WifiMonitor { private static final String SIM_STR = "SIM"; - //used to debug and detect if we miss an event private static int eventLogCounter = 0; @@ -522,6 +521,15 @@ public class WifiMonitor { */ private static final int MAX_RECV_ERRORS = 10; + /** + * Authentication Failure reasonCode, used internally by WifiStateMachine + * @hide + */ + public static final int AUTHENTICATION_FAILURE_REASON_DEFAULT = 0; + public static final int AUTHENTICATION_FAILURE_REASON_TIMEOUT = 1; + public static final int AUTHENTICATION_FAILURE_REASON_WRONG_PSWD = 2; + public static final int AUTHENTICATION_FAILURE_REASON_EAP_FAILURE = 3; + // Singleton instance private static WifiMonitor sWifiMonitor = new WifiMonitor(); public static WifiMonitor getInstance() { @@ -851,9 +859,14 @@ public class WifiMonitor { handleTargetBSSIDEvent(eventStr, iface); } else if (eventStr.startsWith(ASSOCIATED_WITH_STR)) { handleAssociatedBSSIDEvent(eventStr, iface); - } else if (eventStr.startsWith(AUTH_EVENT_PREFIX_STR) && - eventStr.endsWith(AUTH_TIMEOUT_STR)) { - sendMessage(iface, AUTHENTICATION_FAILURE_EVENT); + } else if (eventStr.startsWith(AUTH_EVENT_PREFIX_STR) + && eventStr.endsWith(AUTH_TIMEOUT_STR)) { + sendMessage(iface, AUTHENTICATION_FAILURE_EVENT, eventLogCounter, + AUTHENTICATION_FAILURE_REASON_TIMEOUT); + } else if (eventStr.startsWith(WPA_EVENT_PREFIX_STR) + && eventStr.endsWith(PASSWORD_MAY_BE_INCORRECT_STR)) { + sendMessage(iface, AUTHENTICATION_FAILURE_EVENT, eventLogCounter, + AUTHENTICATION_FAILURE_REASON_WRONG_PSWD); } else { if (mVerboseLoggingEnabled) { Log.w(TAG, "couldn't identify event type - " + eventStr); @@ -995,7 +1008,8 @@ public class WifiMonitor { return true; } else if (event == EAP_FAILURE) { if (eventData.startsWith(EAP_AUTH_FAILURE_STR)) { - sendMessage(iface, AUTHENTICATION_FAILURE_EVENT, eventLogCounter); + sendMessage(iface, AUTHENTICATION_FAILURE_EVENT, eventLogCounter, + AUTHENTICATION_FAILURE_REASON_EAP_FAILURE); } } else if (event == ASSOC_REJECT) { Matcher match = mAssocRejectEventPattern.matcher(eventData); diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 85f5b86b5..c00e822a1 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4862,7 +4862,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mWifiDiagnostics.captureBugReportData( WifiDiagnostics.REPORT_REASON_AUTH_FAILURE); mSupplicantStateTracker.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT); - if (mTargetNetworkId != WifiConfiguration.INVALID_NETWORK_ID) { + // In case of wrong password, rely on SSID_TEMP_DISABLE event to update + // the WifiConfigManager + if ((message.arg2 != WifiMonitor.AUTHENTICATION_FAILURE_REASON_WRONG_PSWD) + && (mTargetNetworkId != WifiConfiguration.INVALID_NETWORK_ID)) { mWifiConfigManager.updateNetworkSelectionStatus(mTargetNetworkId, WifiConfiguration.NetworkSelectionStatus .DISABLED_AUTHENTICATION_FAILURE); |