Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 1 | /* |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 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 | |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 19 | import android.os.Parcelable; |
| 20 | import android.os.Parcel; |
| 21 | |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 22 | /** |
Irfan Sheriff | 489a9d8 | 2011-09-06 22:17:50 -0700 | [diff] [blame] | 23 | * A class representing Wi-Fi Protected Setup |
Irfan Sheriff | 6f7d385 | 2011-09-06 21:48:04 -0700 | [diff] [blame] | 24 | * |
| 25 | * {@see WifiP2pConfig} |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 26 | */ |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 27 | public class WpsInfo implements Parcelable { |
| 28 | |
| 29 | /** Push button configuration */ |
| 30 | public static final int PBC = 0; |
| 31 | /** Display pin method configuration - pin is generated and displayed on device */ |
| 32 | public static final int DISPLAY = 1; |
| 33 | /** Keypad pin method configuration - pin is entered on device */ |
| 34 | public static final int KEYPAD = 2; |
| 35 | /** Label pin method configuration - pin is labelled on device */ |
| 36 | public static final int LABEL = 3; |
| 37 | /** Invalid configuration */ |
| 38 | public static final int INVALID = 4; |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 39 | |
Irfan Sheriff | 6f7d385 | 2011-09-06 21:48:04 -0700 | [diff] [blame] | 40 | /** Wi-Fi Protected Setup. www.wi-fi.org/wifi-protected-setup has details */ |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 41 | public int setup; |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 42 | |
Vinit Deshpande | 674ca8a | 2014-05-20 18:42:36 -0700 | [diff] [blame] | 43 | /** Passed with pin method KEYPAD */ |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 44 | public String BSSID; |
| 45 | |
Irfan Sheriff | 6f7d385 | 2011-09-06 21:48:04 -0700 | [diff] [blame] | 46 | /** Passed with pin method configuration */ |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 47 | public String pin; |
| 48 | |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 49 | public WpsInfo() { |
| 50 | setup = INVALID; |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 51 | BSSID = null; |
| 52 | pin = null; |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 55 | public String toString() { |
| 56 | StringBuffer sbuf = new StringBuffer(); |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 57 | sbuf.append(" setup: ").append(setup); |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 58 | sbuf.append('\n'); |
| 59 | sbuf.append(" BSSID: ").append(BSSID); |
| 60 | sbuf.append('\n'); |
| 61 | sbuf.append(" pin: ").append(pin); |
| 62 | sbuf.append('\n'); |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 63 | return sbuf.toString(); |
| 64 | } |
| 65 | |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 66 | /** Implement the Parcelable interface */ |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 67 | public int describeContents() { |
| 68 | return 0; |
| 69 | } |
| 70 | |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 71 | /* Copy constructor */ |
| 72 | public WpsInfo(WpsInfo source) { |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 73 | if (source != null) { |
| 74 | setup = source.setup; |
| 75 | BSSID = source.BSSID; |
| 76 | pin = source.pin; |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 80 | /** Implement the Parcelable interface */ |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 81 | public void writeToParcel(Parcel dest, int flags) { |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 82 | dest.writeInt(setup); |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 83 | dest.writeString(BSSID); |
| 84 | dest.writeString(pin); |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 85 | } |
| 86 | |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 87 | /** Implement the Parcelable interface */ |
| 88 | public static final Creator<WpsInfo> CREATOR = |
| 89 | new Creator<WpsInfo>() { |
| 90 | public WpsInfo createFromParcel(Parcel in) { |
| 91 | WpsInfo config = new WpsInfo(); |
| 92 | config.setup = in.readInt(); |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 93 | config.BSSID = in.readString(); |
| 94 | config.pin = in.readString(); |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 95 | return config; |
| 96 | } |
| 97 | |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 98 | public WpsInfo[] newArray(int size) { |
| 99 | return new WpsInfo[size]; |
Irfan Sheriff | 02fb46a | 2010-12-08 11:27:37 -0800 | [diff] [blame] | 100 | } |
| 101 | }; |
| 102 | } |