Home | History | Annotate | Download | only in display
      1 /*
      2  * Copyright (C) 2012 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.hardware.display;
     18 
     19 import android.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 /**
     23  * This class contains information regarding a wifi display session
     24  * (such as session id, source ip address, etc.). This is needed for
     25  * Wifi Display Certification process.
     26  * <p>
     27  * This object is immutable.
     28  * </p>
     29  *
     30  * @hide
     31  */
     32 public final class WifiDisplaySessionInfo implements Parcelable {
     33     private final boolean mClient;
     34     private final int mSessionId;
     35     private final String mGroupId;
     36     private final String mPassphrase;
     37     private final String mIP;
     38 
     39     public static final Creator<WifiDisplaySessionInfo> CREATOR =
     40             new Creator<WifiDisplaySessionInfo>() {
     41         @Override
     42         public WifiDisplaySessionInfo createFromParcel(Parcel in) {
     43             boolean client = (in.readInt() != 0);
     44             int session = in.readInt();
     45             String group = in.readString();
     46             String pp = in.readString();
     47             String ip = in.readString();
     48 
     49             return new WifiDisplaySessionInfo(client, session, group, pp, ip);
     50         }
     51 
     52         @Override
     53         public WifiDisplaySessionInfo[] newArray(int size) {
     54             return new WifiDisplaySessionInfo[size];
     55         }
     56     };
     57 
     58     public WifiDisplaySessionInfo() {
     59         this(true, 0, "", "", "");
     60     }
     61 
     62     public WifiDisplaySessionInfo(
     63             boolean client, int session, String group, String pp, String ip) {
     64         mClient = client;
     65         mSessionId = session;
     66         mGroupId = group;
     67         mPassphrase = pp;
     68         mIP = ip;
     69     }
     70 
     71     public boolean isClient() {
     72         return mClient;
     73     }
     74 
     75     public int getSessionId() {
     76         return mSessionId;
     77     }
     78 
     79     public String getGroupId() {
     80         return mGroupId;
     81     }
     82 
     83     public String getPassphrase() {
     84         return mPassphrase;
     85     }
     86 
     87     public String getIP() {
     88         return mIP;
     89     }
     90 
     91     @Override
     92     public void writeToParcel(Parcel dest, int flags) {
     93         dest.writeInt(mClient ? 1 : 0);
     94         dest.writeInt(mSessionId);
     95         dest.writeString(mGroupId);
     96         dest.writeString(mPassphrase);
     97         dest.writeString(mIP);
     98     }
     99 
    100     @Override
    101     public int describeContents() {
    102         return 0;
    103     }
    104 
    105     // For debugging purposes only.
    106     @Override
    107     public String toString() {
    108         return "WifiDisplaySessionInfo:"
    109                 +"\n    Client/Owner: " + (mClient ? "Client":"Owner")
    110                 +"\n    GroupId: " + mGroupId
    111                 +"\n    Passphrase: " + mPassphrase
    112                 +"\n    SessionId: " + mSessionId
    113                 +"\n    IP Address: " + mIP
    114                 ;
    115     }
    116 }
    117