2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android
.net
.wifi
.p2p
.nsd
;
19 import android
.os
.Parcel
;
20 import android
.os
.Parcelable
;
22 import java
.util
.ArrayList
;
23 import java
.util
.List
;
26 * A class for storing service information that is advertised
27 * over a Wi-Fi peer-to-peer setup
29 * @see WifiP2pUpnpServiceInfo
30 * @see WifiP2pDnsSdServiceInfo
32 public class WifiP2pServiceInfo
implements Parcelable
{
35 * All service protocol types.
37 public static final int SERVICE_TYPE_ALL
= 0;
40 * DNS based service discovery protocol.
42 public static final int SERVICE_TYPE_BONJOUR
= 1;
47 public static final int SERVICE_TYPE_UPNP
= 2;
50 * WS-Discovery protocol
53 public static final int SERVICE_TYPE_WS_DISCOVERY
= 3;
56 * Vendor Specific protocol
58 public static final int SERVICE_TYPE_VENDOR_SPECIFIC
= 255;
61 * the list of query string for wpa_supplicant
64 * # IP Printing over TCP (PTR) (RDATA=MyPrinter._ipp._tcp.local.)
65 * {"bonjour", "045f697070c00c000c01", "094d795072696e746572c027"
67 * # IP Printing over TCP (TXT) (RDATA=txtvers=1,pdl=application/postscript)
68 * {"bonjour", "096d797072696e746572045f697070c00c001001",
69 * "09747874766572733d311a70646c3d6170706c69636174696f6e2f706f7374736372797074"}
73 * {"upnp", "10", "uuid:6859dede-8574-59ab-9332-123456789012"}
76 * {"upnp", "10", "uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice"}
79 * {"upnp", "10", "uuid:6859dede-8574-59ab-9332-123456789012::urn:schemas-upnp
80 * -org:device:InternetGatewayDevice:1"}
83 * {"upnp", "10", "uuid:6859dede-8574-59ab-9322-123456789012::urn:schemas-upnp
84 * -org:service:ContentDirectory:2"}
86 private List
<String
> mQueryList
;
89 * This is only used in subclass.
91 * @param queryList query string for wpa_supplicant
94 protected WifiP2pServiceInfo(List
<String
> queryList
) {
95 if (queryList
== null) {
96 throw new IllegalArgumentException("query list cannot be null");
98 mQueryList
= queryList
;
102 * Return the list of the query string for wpa_supplicant.
104 * @return the list of the query string for wpa_supplicant.
107 public List
<String
> getSupplicantQueryList() {
112 * Converts byte array to hex string.
115 * @return hex string.
118 static String
bin2HexStr(byte[] data
) {
119 StringBuffer sb
= new StringBuffer();
124 s
= Integer
.toHexString(b
& 0xff);
125 } catch (Exception e
) {
130 if (s
.length() == 1) {
135 return sb
.toString();
139 public boolean equals(Object o
) {
143 if (!(o
instanceof WifiP2pServiceInfo
)) {
147 WifiP2pServiceInfo servInfo
= (WifiP2pServiceInfo
)o
;
148 return mQueryList
.equals(servInfo
.mQueryList
);
152 public int hashCode() {
154 result
= 31 * result
+ (mQueryList
== null ?
0 : mQueryList
.hashCode());
158 /** Implement the Parcelable interface {@hide} */
159 public int describeContents() {
163 /** Implement the Parcelable interface {@hide} */
164 public void writeToParcel(Parcel dest
, int flags
) {
165 dest
.writeStringList(mQueryList
);
168 /** Implement the Parcelable interface {@hide} */
169 public static final Creator
<WifiP2pServiceInfo
> CREATOR
=
170 new Creator
<WifiP2pServiceInfo
>() {
171 public WifiP2pServiceInfo
createFromParcel(Parcel in
) {
173 List
<String
> data
= new ArrayList
<String
>();
174 in
.readStringList(data
);
175 return new WifiP2pServiceInfo(data
);
178 public WifiP2pServiceInfo
[] newArray(int size
) {
179 return new WifiP2pServiceInfo
[size
];