1155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande/*
2155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Copyright (C) 2010 The Android Open Source Project
3155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *
4155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Licensed under the Apache License, Version 2.0 (the "License");
5155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * you may not use this file except in compliance with the License.
6155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * You may obtain a copy of the License at
7155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *
8155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *      http://www.apache.org/licenses/LICENSE-2.0
9155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *
10155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Unless required by applicable law or agreed to in writing, software
11155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * distributed under the License is distributed on an "AS IS" BASIS,
12155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * See the License for the specific language governing permissions and
14155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * limitations under the License.
15155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */
16155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
17155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandepackage com.android.server.wifi;
18155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
19155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.content.Context;
20155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.content.Intent;
21155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.net.wifi.SupplicantState;
22155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.net.wifi.WifiConfiguration;
23155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.net.wifi.WifiManager;
24eee1d479d8d402a2e78e2f143e957030cfc77749Vinit Deshpandeimport android.os.BatteryStats;
25155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.os.Handler;
26155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.os.Message;
27155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.os.Parcelable;
28eee1d479d8d402a2e78e2f143e957030cfc77749Vinit Deshpandeimport android.os.RemoteException;
29155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.os.UserHandle;
30155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.util.Log;
31eee1d479d8d402a2e78e2f143e957030cfc77749Vinit Deshpandeimport android.util.Slog;
32eee1d479d8d402a2e78e2f143e957030cfc77749Vinit Deshpande
33eee1d479d8d402a2e78e2f143e957030cfc77749Vinit Deshpandeimport com.android.internal.app.IBatteryStats;
34eee1d479d8d402a2e78e2f143e957030cfc77749Vinit Deshpandeimport com.android.internal.util.State;
35eee1d479d8d402a2e78e2f143e957030cfc77749Vinit Deshpandeimport com.android.internal.util.StateMachine;
36155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
37155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport java.io.FileDescriptor;
38155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport java.io.PrintWriter;
39155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
40155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande/**
41155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Tracks the state changes in supplicant and provides functionality
42155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * that is based on these state changes:
43155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * - detect a failed WPA handshake that loops indefinitely
44155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * - authentication failure handling
45155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */
46eee1d479d8d402a2e78e2f143e957030cfc77749Vinit Deshpandepublic class SupplicantStateTracker extends StateMachine {
47155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
48155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    private static final String TAG = "SupplicantStateTracker";
490888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle    private static boolean DBG = false;
50c2a0ff06d58e1cfb9b69fa5b6a8fef5929812f27Roshan Pius    private final WifiConfigManager mWifiConfigManager;
5199f90f5cb7637ece0358003d3d3355036e6d68f7Sohani Rao    private FrameworkFacade mFacade;
5251991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final IBatteryStats mBatteryStats;
53155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /* Indicates authentication failure in supplicant broadcast.
54155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * TODO: enhance auth failure reporting to include notification
55155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * for all type of failures: EAP, WPS & WPA networks */
56155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    private boolean mAuthFailureInSupplicantBroadcast = false;
57155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
58efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao    /* Authentication failure reason
59efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao     * see {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_NONE},
60efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao     *     {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_TIMEOUT},
61efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao     *     {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_WRONG_PSWD},
62efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao     *     {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_EAP_FAILURE}
63efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao     */
64efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao    private int mAuthFailureReason;
65efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao
66155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /* Maximum retries on a authentication failure notification */
67155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    private static final int MAX_RETRIES_ON_AUTHENTICATION_FAILURE = 2;
68155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
69155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /* Maximum retries on assoc rejection events */
70155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    private static final int MAX_RETRIES_ON_ASSOCIATION_REJECT = 16;
71155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
72155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /* Tracks if networks have been disabled during a connection */
73155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    private boolean mNetworksDisabledDuringConnect = false;
74155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
7551991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final Context mContext;
76155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
7751991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final State mUninitializedState = new UninitializedState();
7851991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final State mDefaultState = new DefaultState();
7951991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final State mInactiveState = new InactiveState();
8051991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final State mDisconnectState = new DisconnectedState();
8151991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final State mScanState = new ScanState();
8281cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart    private final State mConnectionActiveState = new ConnectionActiveState();
8351991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final State mHandshakeState = new HandshakeState();
8451991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final State mCompletedState = new CompletedState();
8551991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn    private final State mDormantState = new DormantState();
86155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
870888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle    void enableVerboseLogging(int verbose) {
880888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle        if (verbose > 0) {
890888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle            DBG = true;
900888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle        } else {
910888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle            DBG = false;
920888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle        }
930888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle    }
940888ce6f90bdaeee799dd8361ea4781e23a33b87vandwalle
95f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle    public String getSupplicantStateName() {
96f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle        return getCurrentState().getName();
97f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle    }
98f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle
9999f90f5cb7637ece0358003d3d3355036e6d68f7Sohani Rao    public SupplicantStateTracker(Context c, WifiConfigManager wcs,
10099f90f5cb7637ece0358003d3d3355036e6d68f7Sohani Rao            FrameworkFacade facade, Handler t) {
101155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        super(TAG, t.getLooper());
102155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
103155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        mContext = c;
104c2a0ff06d58e1cfb9b69fa5b6a8fef5929812f27Roshan Pius        mWifiConfigManager = wcs;
10599f90f5cb7637ece0358003d3d3355036e6d68f7Sohani Rao        mFacade = facade;
10699f90f5cb7637ece0358003d3d3355036e6d68f7Sohani Rao        mBatteryStats = mFacade.getBatteryService();
10781cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart        // CHECKSTYLE:OFF IndentationCheck
108155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        addState(mDefaultState);
109155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            addState(mUninitializedState, mDefaultState);
110155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            addState(mInactiveState, mDefaultState);
111155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            addState(mDisconnectState, mDefaultState);
11281cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart            addState(mConnectionActiveState, mDefaultState);
1133a07ab26624e317adfa27828f675d21183c3571dPaul Stewart                addState(mScanState, mConnectionActiveState);
11481cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart                addState(mHandshakeState, mConnectionActiveState);
11581cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart                addState(mCompletedState, mConnectionActiveState);
11681cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart                addState(mDormantState, mConnectionActiveState);
11781cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart        // CHECKSTYLE:ON IndentationCheck
118155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
119155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        setInitialState(mUninitializedState);
120155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        setLogRecSize(50);
121155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        setLogOnlyTransitions(true);
122155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        //start the state machine
123155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        start();
124155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
125155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
126155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    private void handleNetworkConnectionFailure(int netId, int disableReason) {
127f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle        if (DBG) {
128f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle            Log.d(TAG, "handleNetworkConnectionFailure netId=" + Integer.toString(netId)
129f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle                    + " reason " + Integer.toString(disableReason)
130f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle                    + " mNetworksDisabledDuringConnect=" + mNetworksDisabledDuringConnect);
131f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle        }
132f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle
133155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        /* If other networks disabled during connection, enable them */
134155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        if (mNetworksDisabledDuringConnect) {
1353bc487aa49deecbc358ee819e0dd4b2534412281Roshan Pius            mNetworksDisabledDuringConnect = false; }
1368f0f666c8bdaf508f191f8590755140b92d970eaxinhe        /* update network status */
137c2a0ff06d58e1cfb9b69fa5b6a8fef5929812f27Roshan Pius        mWifiConfigManager.updateNetworkSelectionStatus(netId, disableReason);
138155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
139155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
140155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    private void transitionOnSupplicantStateChange(StateChangeResult stateChangeResult) {
141155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        SupplicantState supState = (SupplicantState) stateChangeResult.state;
142155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
143155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        if (DBG) Log.d(TAG, "Supplicant state: " + supState.toString() + "\n");
144155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
145155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        switch (supState) {
146155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande           case DISCONNECTED:
147155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                transitionTo(mDisconnectState);
148155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
149155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case INTERFACE_DISABLED:
150155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                //we should have received a disconnection already, do nothing
151155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
152155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case SCANNING:
153155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                transitionTo(mScanState);
154155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
155155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case AUTHENTICATING:
156155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case ASSOCIATING:
157155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case ASSOCIATED:
158155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case FOUR_WAY_HANDSHAKE:
159155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case GROUP_HANDSHAKE:
160155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                transitionTo(mHandshakeState);
161155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
162155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case COMPLETED:
163155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                transitionTo(mCompletedState);
164155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
165155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case DORMANT:
166155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                transitionTo(mDormantState);
167155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
168155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case INACTIVE:
169155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                transitionTo(mInactiveState);
170155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
171155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case UNINITIALIZED:
172155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            case INVALID:
173155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                transitionTo(mUninitializedState);
174155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
175155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            default:
176155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                Log.e(TAG, "Unknown supplicant state " + supState);
177155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                break;
178155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
179155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
180155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
181155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    private void sendSupplicantStateChangedBroadcast(SupplicantState state, boolean failedAuth) {
182efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao        sendSupplicantStateChangedBroadcast(state, failedAuth, WifiManager.ERROR_AUTH_FAILURE_NONE);
183efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao    }
184efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao
185efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao    private void sendSupplicantStateChangedBroadcast(SupplicantState state, boolean failedAuth,
186efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao            int reasonCode) {
18751991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn        int supplState;
18851991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn        switch (state) {
18951991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case DISCONNECTED: supplState = BatteryStats.WIFI_SUPPL_STATE_DISCONNECTED; break;
19051991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case INTERFACE_DISABLED:
19151991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn                supplState = BatteryStats.WIFI_SUPPL_STATE_INTERFACE_DISABLED; break;
19251991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case INACTIVE: supplState = BatteryStats.WIFI_SUPPL_STATE_INACTIVE; break;
19351991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case SCANNING: supplState = BatteryStats.WIFI_SUPPL_STATE_SCANNING; break;
19451991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case AUTHENTICATING: supplState = BatteryStats.WIFI_SUPPL_STATE_AUTHENTICATING; break;
19551991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case ASSOCIATING: supplState = BatteryStats.WIFI_SUPPL_STATE_ASSOCIATING; break;
19651991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case ASSOCIATED: supplState = BatteryStats.WIFI_SUPPL_STATE_ASSOCIATED; break;
19751991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case FOUR_WAY_HANDSHAKE:
19851991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn                supplState = BatteryStats.WIFI_SUPPL_STATE_FOUR_WAY_HANDSHAKE; break;
19951991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case GROUP_HANDSHAKE: supplState = BatteryStats.WIFI_SUPPL_STATE_GROUP_HANDSHAKE; break;
20051991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case COMPLETED: supplState = BatteryStats.WIFI_SUPPL_STATE_COMPLETED; break;
20151991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case DORMANT: supplState = BatteryStats.WIFI_SUPPL_STATE_DORMANT; break;
20251991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case UNINITIALIZED: supplState = BatteryStats.WIFI_SUPPL_STATE_UNINITIALIZED; break;
20351991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            case INVALID: supplState = BatteryStats.WIFI_SUPPL_STATE_INVALID; break;
20451991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            default:
20551991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn                Slog.w(TAG, "Unknown supplicant state " + state);
20651991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn                supplState = BatteryStats.WIFI_SUPPL_STATE_INVALID;
20751991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn                break;
20851991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn        }
20951991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn        try {
21051991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            mBatteryStats.noteWifiSupplicantStateChanged(supplState, failedAuth);
21151991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn        } catch (RemoteException e) {
21251991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn            // Won't happen.
21351991e784c605a7432a90c9e9a91b080fb106197Dianne Hackborn        }
214155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        Intent intent = new Intent(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
215155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
216155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                | Intent.FLAG_RECEIVER_REPLACE_PENDING);
217155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        intent.putExtra(WifiManager.EXTRA_NEW_STATE, (Parcelable) state);
218155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        if (failedAuth) {
219155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            intent.putExtra(
220efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                    WifiManager.EXTRA_SUPPLICANT_ERROR,
221efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                    WifiManager.ERROR_AUTHENTICATING);
222efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao            intent.putExtra(
223efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                    WifiManager.EXTRA_SUPPLICANT_ERROR_REASON,
224efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                    reasonCode);
225155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
226155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
227155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
228155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
229155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /********************************************************
230155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * HSM states
231155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *******************************************************/
232155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
233155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    class DefaultState extends State {
234155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
235155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         public void enter() {
236155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             if (DBG) Log.d(TAG, getName() + "\n");
237155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         }
238155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
239155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        public boolean processMessage(Message message) {
240155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            if (DBG) Log.d(TAG, getName() + message.toString() + "\n");
241155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            switch (message.what) {
242155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                case WifiMonitor.AUTHENTICATION_FAILURE_EVENT:
243155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    mAuthFailureInSupplicantBroadcast = true;
244efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                    mAuthFailureReason = message.arg2;
245155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    break;
246155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
247155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    StateChangeResult stateChangeResult = (StateChangeResult) message.obj;
248155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    SupplicantState state = stateChangeResult.state;
249efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                    sendSupplicantStateChangedBroadcast(state, mAuthFailureInSupplicantBroadcast,
250efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                            mAuthFailureReason);
251155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    mAuthFailureInSupplicantBroadcast = false;
252efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                    mAuthFailureReason = WifiManager.ERROR_AUTH_FAILURE_NONE;
253155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    transitionOnSupplicantStateChange(stateChangeResult);
254155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    break;
255155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                case WifiStateMachine.CMD_RESET_SUPPLICANT_STATE:
256155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    transitionTo(mUninitializedState);
257155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    break;
258155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                case WifiManager.CONNECT_NETWORK:
259155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    mNetworksDisabledDuringConnect = true;
260155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    break;
261155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                case WifiMonitor.ASSOCIATION_REJECTION_EVENT:
262155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                default:
263155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    Log.e(TAG, "Ignoring " + message);
264155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    break;
265155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            }
266155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            return HANDLED;
267155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
268155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
269155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
270155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /*
271155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * This indicates that the supplicant state as seen
272155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * by the framework is not initialized yet. We are
273155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * in this state right after establishing a control
274155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * channel connection before any supplicant events
275155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * or after we have lost the control channel
276155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * connection to the supplicant
277155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     */
278155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    class UninitializedState extends State {
279155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
280155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         public void enter() {
281155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             if (DBG) Log.d(TAG, getName() + "\n");
282155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         }
283155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
284155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
285155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    class InactiveState extends State {
286155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
287155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         public void enter() {
288155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             if (DBG) Log.d(TAG, getName() + "\n");
289155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         }
290155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
291155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
292155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    class DisconnectedState extends State {
293155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
294155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         public void enter() {
295155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             if (DBG) Log.d(TAG, getName() + "\n");
296155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         }
297155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
298155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
299155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    class ScanState extends State {
300155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
301155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         public void enter() {
302155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             if (DBG) Log.d(TAG, getName() + "\n");
303155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         }
304155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
305155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
30681cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart    /* Meta-state that processes supplicant disconnections and broadcasts this event. */
30781cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart    class ConnectionActiveState extends State {
30881cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart        @Override
30981cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart        public boolean processMessage(Message message) {
31081cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart            if (message.what == WifiStateMachine.CMD_RESET_SUPPLICANT_STATE) {
31181cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart                sendSupplicantStateChangedBroadcast(SupplicantState.DISCONNECTED, false);
31281cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart            }
31381cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart
31481cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart            /* Let parent states handle the state possible transition. */
31581cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart            return NOT_HANDLED;
31681cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart        }
31781cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart    }
31881cc7a93e0f248f69e1d14487c0ea52aef789c15Paul Stewart
319155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    class HandshakeState extends State {
320155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        /**
321155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         * The max number of the WPA supplicant loop iterations before we
322155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         * decide that the loop should be terminated:
323155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         */
324155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        private static final int MAX_SUPPLICANT_LOOP_ITERATIONS = 4;
325155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        private int mLoopDetectIndex;
326155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        private int mLoopDetectCount;
327155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
328155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
329155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         public void enter() {
330155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             if (DBG) Log.d(TAG, getName() + "\n");
331155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             mLoopDetectIndex = 0;
332155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             mLoopDetectCount = 0;
333155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         }
334155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
335155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        public boolean processMessage(Message message) {
336155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            if (DBG) Log.d(TAG, getName() + message.toString() + "\n");
337155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            switch (message.what) {
338155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
339155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    StateChangeResult stateChangeResult = (StateChangeResult) message.obj;
340155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    SupplicantState state = stateChangeResult.state;
341155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    if (SupplicantState.isHandshakeState(state)) {
342155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        if (mLoopDetectIndex > state.ordinal()) {
343155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                            mLoopDetectCount++;
344155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        }
345155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        if (mLoopDetectCount > MAX_SUPPLICANT_LOOP_ITERATIONS) {
346155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                            Log.d(TAG, "Supplicant loop detected, disabling network " +
347155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                                    stateChangeResult.networkId);
348155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                            handleNetworkConnectionFailure(stateChangeResult.networkId,
3498f0f666c8bdaf508f191f8590755140b92d970eaxinhe                                    WifiConfiguration.NetworkSelectionStatus
3508f0f666c8bdaf508f191f8590755140b92d970eaxinhe                                            .DISABLED_AUTHENTICATION_FAILURE);
351155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        }
352155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        mLoopDetectIndex = state.ordinal();
353155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        sendSupplicantStateChangedBroadcast(state,
354efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                                mAuthFailureInSupplicantBroadcast, mAuthFailureReason);
355155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    } else {
356155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        //Have the DefaultState handle the transition
357155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        return NOT_HANDLED;
358155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    }
359155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    break;
360155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                default:
361155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    return NOT_HANDLED;
362155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            }
363155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            return HANDLED;
364155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
365155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
366155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
367155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    class CompletedState extends State {
368155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
369155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande         public void enter() {
370155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             if (DBG) Log.d(TAG, getName() + "\n");
371155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             /* Reset authentication failure count */
372155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             if (mNetworksDisabledDuringConnect) {
373155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                 mNetworksDisabledDuringConnect = false;
374155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande             }
375155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
376155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
377155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        public boolean processMessage(Message message) {
378155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            if (DBG) Log.d(TAG, getName() + message.toString() + "\n");
379155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            switch(message.what) {
380155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
381155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    StateChangeResult stateChangeResult = (StateChangeResult) message.obj;
382155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    SupplicantState state = stateChangeResult.state;
383efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                    sendSupplicantStateChangedBroadcast(state, mAuthFailureInSupplicantBroadcast,
384efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao                            mAuthFailureReason);
385155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    /* Ignore any connecting state in completed state. Group re-keying
386155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                     * events and other auth events that do not affect connectivity are
387155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                     * ignored
388155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                     */
389155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    if (SupplicantState.isConnecting(state)) {
390155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                        break;
391155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    }
392155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    transitionOnSupplicantStateChange(stateChangeResult);
393155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    break;
394155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                default:
395155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande                    return NOT_HANDLED;
396155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            }
397155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            return HANDLED;
398155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
399155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
400155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
401155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    //TODO: remove after getting rid of the state in supplicant
402155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    class DormantState extends State {
403155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        @Override
404155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        public void enter() {
405155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            if (DBG) Log.d(TAG, getName() + "\n");
406155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
407155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
408155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
409155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    @Override
410155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
411155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        super.dump(fd, pw, args);
412155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        pw.println("mAuthFailureInSupplicantBroadcast " + mAuthFailureInSupplicantBroadcast);
413efab6719309021b890dc39b1a7434ea6b7f7bb64Sohani Rao        pw.println("mAuthFailureReason " + mAuthFailureReason);
414155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        pw.println("mNetworksDisabledDuringConnect " + mNetworksDisabledDuringConnect);
415155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        pw.println();
416155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
417155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande}
418