OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / frameworks / base / wifi / java / android / net / wifi / SupplicantState.java
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package android.net.wifi;
18
19 import android.os.Parcel;
20 import android.os.Parcelable;
21
22 /**
23  * From <code>defs.h</code> in <code>wpa_supplicant</code>.
24  * <p/>
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}.
29  * <p/>
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>.
32  */
33 public enum SupplicantState implements Parcelable {
34     /**
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
37      * connection is lost.
38      */
39     DISCONNECTED,
40
41     /**
42      * Inactive state (wpa_supplicant disabled).
43      * <p/>
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.
48      */
49     INACTIVE,
50
51     /**
52      * Scanning for a network.
53      * <p/>
54      * This state is entered when wpa_supplicant starts scanning for a
55      * network.
56      */
57     SCANNING,
58
59     /**
60      * Trying to associate with a BSS/SSID.
61      * <p/>
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.
67      */
68     ASSOCIATING,
69
70     /**
71      * Association completed.
72      * <p/>
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.
77      */
78     ASSOCIATED,
79
80     /**
81      * WPA 4-Way Key Handshake in progress.
82      * <p/>
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.
87      */
88     FOUR_WAY_HANDSHAKE,
89
90     /**
91      * WPA Group Key Handshake in progress.
92      * <p/>
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
96      * message 1/2).
97      */
98     GROUP_HANDSHAKE,
99
100     /**
101      * All authentication completed.
102      * <p/>
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.
111      * <p/>
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.
117      */
118     COMPLETED,
119
120     /**
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.
127      */
128     DORMANT,
129
130     /**
131      * No connection to wpa_supplicant.
132      * <p/>
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.
136      */
137     UNINITIALIZED,
138
139     /**
140      * A pseudo-state that should normally never be seen.
141      */
142     INVALID;
143
144     /**
145      * Returns {@code true} if the supplicant state is valid and {@code false}
146      * otherwise.
147      * @param state The supplicant state
148      * @return {@code true} if the supplicant state is valid and {@code false}
149      * otherwise.
150      */
151     public static boolean isValidState(SupplicantState state) {
152         return state != UNINITIALIZED && state != INVALID;
153     }
154
155     /** Implement the Parcelable interface {@hide} */
156     public int describeContents() {
157         return 0;
158     }
159
160     /** Implement the Parcelable interface {@hide} */
161     public void writeToParcel(Parcel dest, int flags) {
162         dest.writeString(name());
163     }
164
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());
170             }
171
172             public SupplicantState[] newArray(int size) {
173                 return new SupplicantState[size];
174             }
175         };
176
177 }