• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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.Parcelable;
20 import android.os.Parcel;
21 
22 import java.util.BitSet;
23 
24 /**
25  * A class representing Wi-Fi Protected Setup
26  *
27  * {@see WifiP2pConfig}
28  */
29 public class WpsInfo implements Parcelable {
30 
31     /** Push button configuration */
32     public static final int PBC     = 0;
33     /** Display pin method configuration - pin is generated and displayed on device */
34     public static final int DISPLAY = 1;
35     /** Keypad pin method configuration - pin is entered on device */
36     public static final int KEYPAD  = 2;
37     /** Label pin method configuration - pin is labelled on device */
38     public static final int LABEL   = 3;
39     /** Invalid configuration */
40     public static final int INVALID = 4;
41 
42     /** Wi-Fi Protected Setup. www.wi-fi.org/wifi-protected-setup has details */
43     public int setup;
44 
45     /** @hide */
46     public String BSSID;
47 
48     /** Passed with pin method configuration */
49     public String pin;
50 
WpsInfo()51     public WpsInfo() {
52         setup = INVALID;
53         BSSID = null;
54         pin = null;
55     }
56 
toString()57     public String toString() {
58         StringBuffer sbuf = new StringBuffer();
59         sbuf.append(" setup: ").append(setup);
60         sbuf.append('\n');
61         sbuf.append(" BSSID: ").append(BSSID);
62         sbuf.append('\n');
63         sbuf.append(" pin: ").append(pin);
64         sbuf.append('\n');
65         return sbuf.toString();
66     }
67 
68     /** Implement the Parcelable interface */
describeContents()69     public int describeContents() {
70         return 0;
71     }
72 
73     /* Copy constructor */
WpsInfo(WpsInfo source)74     public WpsInfo(WpsInfo source) {
75         if (source != null) {
76             setup = source.setup;
77             BSSID = source.BSSID;
78             pin = source.pin;
79         }
80     }
81 
82     /** Implement the Parcelable interface */
writeToParcel(Parcel dest, int flags)83     public void writeToParcel(Parcel dest, int flags) {
84         dest.writeInt(setup);
85         dest.writeString(BSSID);
86         dest.writeString(pin);
87     }
88 
89     /** Implement the Parcelable interface */
90     public static final Creator<WpsInfo> CREATOR =
91         new Creator<WpsInfo>() {
92             public WpsInfo createFromParcel(Parcel in) {
93                 WpsInfo config = new WpsInfo();
94                 config.setup = in.readInt();
95                 config.BSSID = in.readString();
96                 config.pin = in.readString();
97                 return config;
98             }
99 
100             public WpsInfo[] newArray(int size) {
101                 return new WpsInfo[size];
102             }
103         };
104 }
105