Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f518838 authored by Deepthi Gowri's avatar Deepthi Gowri Committed by Steve Kondik
Browse files

framework/base: Handle ASSOC-REJECT events

Disable current network and enable other saved networks(if any)
once number of ASSOC-REJECTs on an attempt to connect to a corresponding
network exceeds the threshold.
CRs-fixed: 484247

Change-Id: I59ca5b7bcb2cf8d205556feaac5871260a3fd8ec
parent 96db1882
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -45,6 +45,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 */
@@ -53,6 +54,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;

@@ -89,14 +93,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) {
@@ -182,6 +186,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);
@@ -226,9 +234,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;
            }
         }
    }

@@ -268,7 +284,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,
@@ -291,6 +308,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;
+2 −0
Original line number Diff line number Diff line
@@ -177,6 +177,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
+13 −1
Original line number Diff line number Diff line
@@ -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-";
@@ -152,6 +153,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>
@@ -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);
                }
+8 −0
Original line number Diff line number Diff line
@@ -2032,6 +2032,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:
@@ -2458,6 +2459,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_COUNTRY_CODE:
                case CMD_SET_FREQUENCY_BAND:
@@ -2846,6 +2848,9 @@ public class WifiStateMachine extends StateMachine {
            WifiConfiguration config;
            boolean ok;
            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;
@@ -3575,6 +3580,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