diff options
author | Dmitry Shmidt <dimitrysh%android.com@gtempaccount.com> | 2013-05-10 22:35:23 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-05-10 22:35:23 +0000 |
commit | 00ee47ead451ee2584c23f15a3760ae041e82e56 (patch) | |
tree | e6598937e0be0883c3235917582dde4392ad3fa8 /wifi | |
parent | 408ad99dd307ae93abec76821d343b8e080c99c9 (diff) | |
parent | c1b631e757999232674e53e9a1bc21abed6b1862 (diff) | |
download | frameworks_base-00ee47ead451ee2584c23f15a3760ae041e82e56.zip frameworks_base-00ee47ead451ee2584c23f15a3760ae041e82e56.tar.gz frameworks_base-00ee47ead451ee2584c23f15a3760ae041e82e56.tar.bz2 |
Merge "framework/base: Handle ASSOC-REJECT events"
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/SupplicantStateTracker.java | 26 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfiguration.java | 2 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiMonitor.java | 14 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 8 |
4 files changed, 45 insertions, 5 deletions
diff --git a/wifi/java/android/net/wifi/SupplicantStateTracker.java b/wifi/java/android/net/wifi/SupplicantStateTracker.java index d1e9b67..055bfb4 100644 --- a/wifi/java/android/net/wifi/SupplicantStateTracker.java +++ b/wifi/java/android/net/wifi/SupplicantStateTracker.java @@ -42,6 +42,7 @@ class SupplicantStateTracker extends StateMachine { private WifiStateMachine mWifiStateMachine; private WifiConfigStore mWifiConfigStore; private int mAuthenticationFailuresCount = 0; + private int mAssociationRejectCount = 0; /* Indicates authentication failure in supplicant broadcast. * TODO: enhance auth failure reporting to include notification * for all type of failures: EAP, WPS & WPA networks */ @@ -50,6 +51,9 @@ class SupplicantStateTracker extends StateMachine { /* Maximum retries on a authentication failure notification */ private static final int MAX_RETRIES_ON_AUTHENTICATION_FAILURE = 2; + /* Maximum retries on assoc rejection events */ + private static final int MAX_RETRIES_ON_ASSOCIATION_REJECT = 4; + /* Tracks if networks have been disabled during a connection */ private boolean mNetworksDisabledDuringConnect = false; @@ -85,14 +89,14 @@ class SupplicantStateTracker extends StateMachine { start(); } - private void handleNetworkConnectionFailure(int netId) { + private void handleNetworkConnectionFailure(int netId, int disableReason) { /* If other networks disabled during connection, enable them */ if (mNetworksDisabledDuringConnect) { mWifiConfigStore.enableAllNetworks(); mNetworksDisabledDuringConnect = false; } /* Disable failed network */ - mWifiConfigStore.disableNetwork(netId, WifiConfiguration.DISABLED_AUTH_FAILURE); + mWifiConfigStore.disableNetwork(netId, disableReason); } private void transitionOnSupplicantStateChange(StateChangeResult stateChangeResult) { @@ -178,6 +182,10 @@ class SupplicantStateTracker extends StateMachine { break; case WifiManager.CONNECT_NETWORK: mNetworksDisabledDuringConnect = true; + mAssociationRejectCount = 0; + break; + case WifiMonitor.ASSOCIATION_REJECTION_EVENT: + mAssociationRejectCount++; break; default: Log.e(TAG, "Ignoring " + message); @@ -222,9 +230,17 @@ class SupplicantStateTracker extends StateMachine { if (mAuthenticationFailuresCount >= MAX_RETRIES_ON_AUTHENTICATION_FAILURE) { Log.d(TAG, "Failed to authenticate, disabling network " + stateChangeResult.networkId); - handleNetworkConnectionFailure(stateChangeResult.networkId); + handleNetworkConnectionFailure(stateChangeResult.networkId, + WifiConfiguration.DISABLED_AUTH_FAILURE); mAuthenticationFailuresCount = 0; } + else if (mAssociationRejectCount >= MAX_RETRIES_ON_ASSOCIATION_REJECT) { + Log.d(TAG, "Association getting rejected, disabling network " + + stateChangeResult.networkId); + handleNetworkConnectionFailure(stateChangeResult.networkId, + WifiConfiguration.DISABLED_ASSOCIATION_REJECT); + mAssociationRejectCount = 0; + } } } @@ -264,7 +280,8 @@ class SupplicantStateTracker extends StateMachine { if (mLoopDetectCount > MAX_SUPPLICANT_LOOP_ITERATIONS) { Log.d(TAG, "Supplicant loop detected, disabling network " + stateChangeResult.networkId); - handleNetworkConnectionFailure(stateChangeResult.networkId); + handleNetworkConnectionFailure(stateChangeResult.networkId, + WifiConfiguration.DISABLED_AUTH_FAILURE); } mLoopDetectIndex = state.ordinal(); sendSupplicantStateChangedBroadcast(state, @@ -287,6 +304,7 @@ class SupplicantStateTracker extends StateMachine { if (DBG) Log.d(TAG, getName() + "\n"); /* Reset authentication failure count */ mAuthenticationFailuresCount = 0; + mAssociationRejectCount = 0; if (mNetworksDisabledDuringConnect) { mWifiConfigStore.enableAllNetworks(); mNetworksDisabledDuringConnect = false; diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index bf82792..f1542e9 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -173,6 +173,8 @@ public class WifiConfiguration implements Parcelable { public static final int DISABLED_DHCP_FAILURE = 2; /** @hide */ public static final int DISABLED_AUTH_FAILURE = 3; + /** @hide */ + public static final int DISABLED_ASSOCIATION_REJECT = 4; /** * The ID number that the supplicant uses to identify this diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java index 0b0d738..fe3c709 100644 --- a/wifi/java/android/net/wifi/WifiMonitor.java +++ b/wifi/java/android/net/wifi/WifiMonitor.java @@ -56,7 +56,8 @@ public class WifiMonitor { private static final int TERMINATING = 6; private static final int DRIVER_STATE = 7; private static final int EAP_FAILURE = 8; - private static final int UNKNOWN = 9; + private static final int ASSOC_REJECT = 9; + private static final int UNKNOWN = 10; /** All events coming from the supplicant start with this prefix */ private static final String EVENT_PREFIX_STR = "CTRL-EVENT-"; @@ -153,6 +154,11 @@ public class WifiMonitor { private static final String EAP_AUTH_FAILURE_STR = "EAP authentication failed"; /** + * This indicates an assoc reject event + */ + private static final String ASSOC_REJECT_STR = "ASSOC-REJECT"; + + /** * Regex pattern for extracting an Ethernet-style MAC address from a string. * Matches a strings like the following:<pre> * CTRL-EVENT-CONNECTED - Connection to 00:1e:58:ec:d5:6d completed (reauth) [id=1 id_str=]</pre> @@ -328,6 +334,8 @@ public class WifiMonitor { public static final int AP_STA_DISCONNECTED_EVENT = BASE + 41; public static final int AP_STA_CONNECTED_EVENT = BASE + 42; + /* Indicates assoc reject event */ + public static final int ASSOCIATION_REJECTION_EVENT = BASE + 43; /** * This indicates the supplicant connection for the monitor is closed */ @@ -429,6 +437,8 @@ public class WifiMonitor { event = DRIVER_STATE; else if (eventName.equals(EAP_FAILURE_STR)) event = EAP_FAILURE; + else if (eventName.equals(ASSOC_REJECT_STR)) + event = ASSOC_REJECT; else event = UNKNOWN; @@ -473,6 +483,8 @@ public class WifiMonitor { if (eventData.startsWith(EAP_AUTH_FAILURE_STR)) { mStateMachine.sendMessage(AUTHENTICATION_FAILURE_EVENT); } + } else if (event == ASSOC_REJECT) { + mStateMachine.sendMessage(ASSOCIATION_REJECTION_EVENT); } else { handleEvent(event, eventData); } diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 2ab59e3..880040b 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -1962,6 +1962,7 @@ public class WifiStateMachine extends StateMachine { case WifiMonitor.SCAN_RESULTS_EVENT: case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: case WifiMonitor.AUTHENTICATION_FAILURE_EVENT: + case WifiMonitor.ASSOCIATION_REJECTION_EVENT: case WifiMonitor.WPS_OVERLAP_EVENT: case CMD_BLACKLIST_NETWORK: case CMD_CLEAR_BLACKLIST: @@ -2698,6 +2699,7 @@ public class WifiStateMachine extends StateMachine { case WifiMonitor.NETWORK_CONNECTION_EVENT: case WifiMonitor.NETWORK_DISCONNECTION_EVENT: case WifiMonitor.AUTHENTICATION_FAILURE_EVENT: + case WifiMonitor.ASSOCIATION_REJECTION_EVENT: case WifiMonitor.WPS_OVERLAP_EVENT: case CMD_SET_SCAN_TYPE: case CMD_SET_COUNTRY_CODE: @@ -3092,6 +3094,9 @@ public class WifiStateMachine extends StateMachine { if (DBG) log(getName() + message.toString() + "\n"); StateChangeResult stateChangeResult; switch(message.what) { + case WifiMonitor.ASSOCIATION_REJECTION_EVENT: + mSupplicantStateTracker.sendMessage(WifiMonitor.ASSOCIATION_REJECTION_EVENT); + break; case WifiMonitor.AUTHENTICATION_FAILURE_EVENT: mSupplicantStateTracker.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT); break; @@ -3786,6 +3791,9 @@ public class WifiStateMachine extends StateMachine { if (DBG) log("Network connection lost"); handleNetworkDisconnect(); break; + case WifiMonitor.ASSOCIATION_REJECTION_EVENT: + if (DBG) log("Ignore Assoc reject event during WPS Connection"); + break; case WifiMonitor.AUTHENTICATION_FAILURE_EVENT: // Disregard auth failure events during WPS connection. The // EAP sequence is retried several times, and there might be |