2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package android.net.wifi;
19 import android.os.Parcel;
20 import android.os.Parcelable;
23 * From <code>defs.h</code> in <code>wpa_supplicant</code>.
25 * These enumeration values are used to indicate the current wpa_supplicant
26 * state. This is more fine-grained than most users will be interested in.
27 * In general, it is better to use
28 * {@link android.net.NetworkInfo.State NetworkInfo.State}.
30 * Note, the order of these enum constants must match the numerical values of the
31 * state constants in <code>defs.h</code> in <code>wpa_supplicant</code>.
33 public enum SupplicantState implements Parcelable {
35 * This state indicates that client is not associated, but is likely to
36 * start looking for an access point. This state is entered when a
42 * Inactive state (wpa_supplicant disabled).
44 * This state is entered if there are no enabled networks in the
45 * configuration. wpa_supplicant is not trying to associate with a new
46 * network and external interaction (e.g., ctrl_iface call to add or
47 * enable a network) is needed to start association.
52 * Scanning for a network.
54 * This state is entered when wpa_supplicant starts scanning for a
60 * Trying to associate with a BSS/SSID.
62 * This state is entered when wpa_supplicant has found a suitable BSS
63 * to associate with and the driver is configured to try to associate
64 * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
65 * state is entered when the driver is configured to try to associate
66 * with a network using the configured SSID and security policy.
71 * Association completed.
73 * This state is entered when the driver reports that association has
74 * been successfully completed with an AP. If IEEE 802.1X is used
75 * (with or without WPA/WPA2), wpa_supplicant remains in this state
76 * until the IEEE 802.1X/EAPOL authentication has been completed.
81 * WPA 4-Way Key Handshake in progress.
83 * This state is entered when WPA/WPA2 4-Way Handshake is started. In
84 * case of WPA-PSK, this happens when receiving the first EAPOL-Key
85 * frame after association. In case of WPA-EAP, this state is entered
86 * when the IEEE 802.1X/EAPOL authentication has been completed.
91 * WPA Group Key Handshake in progress.
93 * This state is entered when 4-Way Key Handshake has been completed
94 * (i.e., when the supplicant sends out message 4/4) and when Group
95 * Key rekeying is started by the AP (i.e., when supplicant receives
101 * All authentication completed.
103 * This state is entered when the full authentication process is
104 * completed. In case of WPA2, this happens when the 4-Way Handshake is
105 * successfully completed. With WPA, this state is entered after the
106 * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
107 * completed after dynamic keys are received (or if not used, after
108 * the EAP authentication has been completed). With static WEP keys and
109 * plaintext connections, this state is entered when an association
110 * has been completed.
112 * This state indicates that the supplicant has completed its
113 * processing for the association phase and that data connection is
114 * fully configured. Note, however, that there may not be any IP
115 * address associated with the connection yet. Typically, a DHCP
116 * request needs to be sent at this point to obtain an address.
121 * An Android-added state that is reported when a client issues an
122 * explicit DISCONNECT command. In such a case, the supplicant is
123 * not only dissociated from the current access point (as for the
124 * DISCONNECTED state above), but it also does not attempt to connect
125 * to any access point until a RECONNECT or REASSOCIATE command
126 * is issued by the client.
131 * No connection to wpa_supplicant.
133 * This is an additional pseudo-state to handle the case where
134 * wpa_supplicant is not running and/or we have not been able
135 * to establish a connection to it.
140 * A pseudo-state that should normally never be seen.
145 * Returns {@code true} if the supplicant state is valid and {@code false}
147 * @param state The supplicant state
148 * @return {@code true} if the supplicant state is valid and {@code false}
151 public static boolean isValidState(SupplicantState state) {
152 return state != UNINITIALIZED && state != INVALID;
155 /** Implement the Parcelable interface {@hide} */
156 public int describeContents() {
160 /** Implement the Parcelable interface {@hide} */
161 public void writeToParcel(Parcel dest, int flags) {
162 dest.writeString(name());
165 /** Implement the Parcelable interface {@hide} */
166 public static final Creator<SupplicantState> CREATOR =
167 new Creator<SupplicantState>() {
168 public SupplicantState createFromParcel(Parcel in) {
169 return SupplicantState.valueOf(in.readString());
172 public SupplicantState[] newArray(int size) {
173 return new SupplicantState[size];