1/* 2 * Copyright (C) 2010 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 17package android.net.wifi; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21 22/** 23 * A class representing the result of a WPS request 24 * @hide 25 */ 26public class WpsResult implements Parcelable { 27 28 public enum Status { 29 SUCCESS, 30 FAILURE, 31 IN_PROGRESS, 32 } 33 34 public Status status; 35 36 public String pin; 37 38 public WpsResult() { 39 status = Status.FAILURE; 40 pin = null; 41 } 42 43 public WpsResult(Status s) { 44 status = s; 45 pin = null; 46 } 47 48 public String toString() { 49 StringBuffer sbuf = new StringBuffer(); 50 sbuf.append(" status: ").append(status.toString()); 51 sbuf.append('\n'); 52 sbuf.append(" pin: ").append(pin); 53 sbuf.append("\n"); 54 return sbuf.toString(); 55 } 56 57 /** Implement the Parcelable interface {@hide} */ 58 public int describeContents() { 59 return 0; 60 } 61 62 /** copy constructor {@hide} */ 63 public WpsResult(WpsResult source) { 64 if (source != null) { 65 status = source.status; 66 pin = source.pin; 67 } 68 } 69 70 /** Implement the Parcelable interface {@hide} */ 71 public void writeToParcel(Parcel dest, int flags) { 72 dest.writeString(status.name()); 73 dest.writeString(pin); 74 } 75 76 /** Implement the Parcelable interface {@hide} */ 77 public static final Creator<WpsResult> CREATOR = 78 new Creator<WpsResult>() { 79 public WpsResult createFromParcel(Parcel in) { 80 WpsResult result = new WpsResult(); 81 result.status = Status.valueOf(in.readString()); 82 result.pin = in.readString(); 83 return result; 84 } 85 86 public WpsResult[] newArray(int size) { 87 return new WpsResult[size]; 88 } 89 }; 90} 91