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 /** 23 * A class representing Wi-Fi Protected Setup 24 * 25 * {@see WifiP2pConfig} 26 */ 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; 39 40 /** Wi-Fi Protected Setup. www.wi-fi.org/wifi-protected-setup has details */ 41 public int setup; 42 43 /** Passed with pin method KEYPAD */ 44 public String BSSID; 45 46 /** Passed with pin method configuration */ 47 public String pin; 48 WpsInfo()49 public WpsInfo() { 50 setup = INVALID; 51 BSSID = null; 52 pin = null; 53 } 54 toString()55 public String toString() { 56 StringBuffer sbuf = new StringBuffer(); 57 sbuf.append(" setup: ").append(setup); 58 sbuf.append('\n'); 59 sbuf.append(" BSSID: ").append(BSSID); 60 sbuf.append('\n'); 61 sbuf.append(" pin: ").append(pin); 62 sbuf.append('\n'); 63 return sbuf.toString(); 64 } 65 66 /** Implement the Parcelable interface */ describeContents()67 public int describeContents() { 68 return 0; 69 } 70 71 /* Copy constructor */ WpsInfo(WpsInfo source)72 public WpsInfo(WpsInfo source) { 73 if (source != null) { 74 setup = source.setup; 75 BSSID = source.BSSID; 76 pin = source.pin; 77 } 78 } 79 80 /** Implement the Parcelable interface */ writeToParcel(Parcel dest, int flags)81 public void writeToParcel(Parcel dest, int flags) { 82 dest.writeInt(setup); 83 dest.writeString(BSSID); 84 dest.writeString(pin); 85 } 86 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(); 93 config.BSSID = in.readString(); 94 config.pin = in.readString(); 95 return config; 96 } 97 98 public WpsInfo[] newArray(int size) { 99 return new WpsInfo[size]; 100 } 101 }; 102 } 103