blob: 21fe22e3e7b001d4f1ebfa902c5134a4276a617e [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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
Amin Shaikhf9d47b72016-12-09 17:11:50 -080019import android.annotation.SystemApi;
Mathew Inwood53f089f2018-08-08 14:44:44 +010020import android.annotation.UnsupportedAppUsage;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.os.Parcel;
Jeff Davidsone4ce6192014-08-08 16:48:13 -070022import android.os.Parcelable;
Mitchell Wills9eeba372016-01-27 22:58:16 -080023
24import java.util.ArrayList;
Roshan Pius4f176152017-10-27 15:12:51 -070025import java.util.Arrays;
Mitchell Wills9eeba372016-01-27 22:58:16 -080026import java.util.List;
Roshan Pius4f176152017-10-27 15:12:51 -070027import java.util.Objects;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028
29/**
30 * Describes information about a detected access point. In addition
31 * to the attributes described here, the supplicant keeps track of
32 * {@code quality}, {@code noise}, and {@code maxbitrate} attributes,
33 * but does not currently report them to external clients.
34 */
35public class ScanResult implements Parcelable {
vandwalle4eeecb22014-07-25 17:10:56 -070036 /**
37 * The network name.
38 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039 public String SSID;
Irfan Sheriffb6deeed2012-09-05 10:46:24 -070040
vandwalle4eeecb22014-07-25 17:10:56 -070041 /**
42 * Ascii encoded SSID. This will replace SSID when we deprecate it. @hide
43 */
Mathew Inwood53f089f2018-08-08 14:44:44 +010044 @UnsupportedAppUsage
Irfan Sheriffb6deeed2012-09-05 10:46:24 -070045 public WifiSsid wifiSsid;
46
vandwalle4eeecb22014-07-25 17:10:56 -070047 /**
48 * The address of the access point.
49 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050 public String BSSID;
Vinit Deshpandea772f0c2016-01-27 19:05:24 -080051
52 /**
53 * The HESSID from the beacon.
54 * @hide
55 */
Mathew Inwood53f089f2018-08-08 14:44:44 +010056 @UnsupportedAppUsage
Vinit Deshpandea772f0c2016-01-27 19:05:24 -080057 public long hessid;
58
59 /**
60 * The ANQP Domain ID from the Hotspot 2.0 Indication element, if present.
61 * @hide
62 */
Mathew Inwood53f089f2018-08-08 14:44:44 +010063 @UnsupportedAppUsage
Vinit Deshpandea772f0c2016-01-27 19:05:24 -080064 public int anqpDomainId;
65
Samuel Tan40b56172016-03-23 14:21:28 -070066 /*
67 * This field is equivalent to the |flags|, rather than the |capabilities| field
68 * of the per-BSS scan results returned by WPA supplicant. See the definition of
69 * |struct wpa_bss| in wpa_supplicant/bss.h for more details.
70 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071 /**
72 * Describes the authentication, key management, and encryption schemes
73 * supported by the access point.
74 */
75 public String capabilities;
Ningyuan Wangd150b2b2016-11-01 15:36:10 -070076
77 /**
78 * @hide
79 * No security protocol.
80 */
81 public static final int PROTOCOL_NONE = 0;
82 /**
83 * @hide
84 * Security protocol type: WPA version 1.
85 */
86 public static final int PROTOCOL_WPA = 1;
87 /**
88 * @hide
Hai Shalom6adbc582018-10-16 14:30:14 -070089 * Security protocol type: RSN, for WPA version 2, and version 3.
Ningyuan Wangd150b2b2016-11-01 15:36:10 -070090 */
Hai Shalom6adbc582018-10-16 14:30:14 -070091 public static final int PROTOCOL_RSN = 2;
Ningyuan Wangd150b2b2016-11-01 15:36:10 -070092 /**
93 * @hide
94 * Security protocol type:
95 * OSU Server-only authenticated layer 2 Encryption Network.
96 * Used for Hotspot 2.0.
97 */
98 public static final int PROTOCOL_OSEN = 3;
99
100 /**
101 * @hide
102 * No security key management scheme.
103 */
104 public static final int KEY_MGMT_NONE = 0;
105 /**
106 * @hide
107 * Security key management scheme: PSK.
108 */
109 public static final int KEY_MGMT_PSK = 1;
110 /**
111 * @hide
112 * Security key management scheme: EAP.
113 */
114 public static final int KEY_MGMT_EAP = 2;
115 /**
116 * @hide
117 * Security key management scheme: FT_PSK.
118 */
119 public static final int KEY_MGMT_FT_PSK = 3;
120 /**
121 * @hide
122 * Security key management scheme: FT_EAP.
123 */
124 public static final int KEY_MGMT_FT_EAP = 4;
125 /**
126 * @hide
127 * Security key management scheme: PSK_SHA256
128 */
129 public static final int KEY_MGMT_PSK_SHA256 = 5;
130 /**
131 * @hide
132 * Security key management scheme: EAP_SHA256.
133 */
134 public static final int KEY_MGMT_EAP_SHA256 = 6;
135 /**
136 * @hide
137 * Security key management scheme: OSEN.
138 * Used for Hotspot 2.0.
139 */
140 public static final int KEY_MGMT_OSEN = 7;
Hai Shalom6adbc582018-10-16 14:30:14 -0700141 /**
142 * @hide
143 * Security key management scheme: SAE.
144 */
145 public static final int KEY_MGMT_SAE = 8;
146 /**
147 * @hide
148 * Security key management scheme: OWE.
149 */
150 public static final int KEY_MGMT_OWE = 9;
151 /**
152 * @hide
153 * Security key management scheme: SUITE_B_192.
154 */
155 public static final int KEY_MGMT_EAP_SUITE_B_192 = 10;
Ningyuan Wangd150b2b2016-11-01 15:36:10 -0700156 /**
157 * @hide
158 * No cipher suite.
159 */
160 public static final int CIPHER_NONE = 0;
161 /**
162 * @hide
163 * No group addressed, only used for group data cipher.
164 */
165 public static final int CIPHER_NO_GROUP_ADDRESSED = 1;
166 /**
167 * @hide
168 * Cipher suite: TKIP
169 */
170 public static final int CIPHER_TKIP = 2;
171 /**
172 * @hide
173 * Cipher suite: CCMP
174 */
175 public static final int CIPHER_CCMP = 3;
Hai Shalom6adbc582018-10-16 14:30:14 -0700176 /**
177 * @hide
178 * Cipher suite: GCMP
179 */
180 public static final int CIPHER_GCMP_256 = 4;
Ningyuan Wangd150b2b2016-11-01 15:36:10 -0700181
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800182 /**
Jeff Davidsone4ce6192014-08-08 16:48:13 -0700183 * The detected signal level in dBm, also known as the RSSI.
184 *
185 * <p>Use {@link android.net.wifi.WifiManager#calculateSignalLevel} to convert this number into
186 * an absolute signal level which can be displayed to a user.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 */
188 public int level;
189 /**
xinhe6e584242015-03-02 14:04:35 -0800190 * The primary 20 MHz frequency (in MHz) of the channel over which the client is communicating
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800191 * with the access point.
192 */
193 public int frequency;
194
xinhe6e584242015-03-02 14:04:35 -0800195 /**
196 * AP Channel bandwidth is 20 MHZ
197 */
198 public static final int CHANNEL_WIDTH_20MHZ = 0;
199 /**
200 * AP Channel bandwidth is 40 MHZ
201 */
202 public static final int CHANNEL_WIDTH_40MHZ = 1;
203 /**
204 * AP Channel bandwidth is 80 MHZ
205 */
206 public static final int CHANNEL_WIDTH_80MHZ = 2;
207 /**
208 * AP Channel bandwidth is 160 MHZ
209 */
210 public static final int CHANNEL_WIDTH_160MHZ = 3;
211 /**
212 * AP Channel bandwidth is 160 MHZ, but 80MHZ + 80MHZ
213 */
214 public static final int CHANNEL_WIDTH_80MHZ_PLUS_MHZ = 4;
215
216 /**
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700217 * AP Channel bandwidth; one of {@link #CHANNEL_WIDTH_20MHZ}, {@link #CHANNEL_WIDTH_40MHZ},
218 * {@link #CHANNEL_WIDTH_80MHZ}, {@link #CHANNEL_WIDTH_160MHZ}
219 * or {@link #CHANNEL_WIDTH_80MHZ_PLUS_MHZ}.
xinhe6e584242015-03-02 14:04:35 -0800220 */
221 public int channelWidth;
222
223 /**
224 * Not used if the AP bandwidth is 20 MHz
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700225 * If the AP use 40, 80 or 160 MHz, this is the center frequency (in MHz)
226 * if the AP use 80 + 80 MHz, this is the center frequency of the first segment (in MHz)
xinhe6e584242015-03-02 14:04:35 -0800227 */
228 public int centerFreq0;
229
230 /**
231 * Only used if the AP bandwidth is 80 + 80 MHz
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700232 * if the AP use 80 + 80 MHz, this is the center frequency of the second segment (in MHz)
xinhe6e584242015-03-02 14:04:35 -0800233 */
234 public int centerFreq1;
235
236 /**
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700237 * @deprecated use is80211mcResponder() instead
238 * @hide
xinhe6e584242015-03-02 14:04:35 -0800239 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100240 @UnsupportedAppUsage
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700241 public boolean is80211McRTTResponder;
xinhe6e584242015-03-02 14:04:35 -0800242
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800243 /**
Vinit Deshpande02b115b2014-09-19 14:23:25 -0700244 * timestamp in microseconds (since boot) when
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700245 * this result was last seen.
246 */
Robert Greenwalt0451d592013-08-01 18:24:13 -0700247 public long timestamp;
248
249 /**
vandwalle7c3606c2014-03-31 19:12:07 -0700250 * Timestamp representing date when this result was last seen, in milliseconds from 1970
251 * {@hide}
252 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100253 @UnsupportedAppUsage
vandwalle7c3606c2014-03-31 19:12:07 -0700254 public long seen;
255
vandwalle4eeecb22014-07-25 17:10:56 -0700256 /**
Roshan Pius4f176152017-10-27 15:12:51 -0700257 * On devices with multiple hardware radio chains, this class provides metadata about
258 * each radio chain that was used to receive this scan result (probe response or beacon).
259 * {@hide}
260 */
261 public static class RadioChainInfo {
262 /** Vendor defined id for a radio chain. */
263 public int id;
264 /** Detected signal level in dBm (also known as the RSSI) on this radio chain. */
265 public int level;
266
267 @Override
268 public String toString() {
269 return "RadioChainInfo: id=" + id + ", level=" + level;
270 }
271
272 @Override
273 public boolean equals(Object otherObj) {
274 if (this == otherObj) {
275 return true;
276 }
277 if (!(otherObj instanceof RadioChainInfo)) {
278 return false;
279 }
280 RadioChainInfo other = (RadioChainInfo) otherObj;
281 return id == other.id && level == other.level;
282 }
283
284 @Override
285 public int hashCode() {
286 return Objects.hash(id, level);
287 }
288 };
289
290 /**
291 * Information about the list of the radio chains used to receive this scan result
292 * (probe response or beacon).
293 *
294 * For Example: On devices with 2 hardware radio chains, this list could hold 1 or 2
295 * entries based on whether this scan result was received using one or both the chains.
296 * {@hide}
297 */
298 public RadioChainInfo[] radioChainInfos;
299
300 /**
Amin Shaikhf9d47b72016-12-09 17:11:50 -0800301 * Status indicating the scan result does not correspond to a user's saved configuration
vandwalle4eeecb22014-07-25 17:10:56 -0700302 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -0600303 * @removed
vandwalle4eeecb22014-07-25 17:10:56 -0700304 */
Amin Shaikhf9d47b72016-12-09 17:11:50 -0800305 @SystemApi
vandwalle4eeecb22014-07-25 17:10:56 -0700306 public boolean untrusted;
307
308 /**
vandwalle4eeecb22014-07-25 17:10:56 -0700309 * Number of time autojoin used it
310 * @hide
311 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100312 @UnsupportedAppUsage
vandwalle4eeecb22014-07-25 17:10:56 -0700313 public int numUsage;
314
315 /**
Robert Greenwalt0451d592013-08-01 18:24:13 -0700316 * The approximate distance to the AP in centimeter, if available. Else
317 * {@link UNSPECIFIED}.
318 * {@hide}
319 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100320 @UnsupportedAppUsage
Robert Greenwalt0451d592013-08-01 18:24:13 -0700321 public int distanceCm;
322
323 /**
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700324 * The standard deviation of the distance to the access point, if available.
Robert Greenwalt0451d592013-08-01 18:24:13 -0700325 * Else {@link UNSPECIFIED}.
326 * {@hide}
327 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100328 @UnsupportedAppUsage
Robert Greenwalt0451d592013-08-01 18:24:13 -0700329 public int distanceSdCm;
330
Vinit Deshpande7226c8f2015-06-30 13:43:02 -0700331 /** {@hide} */
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700332 public static final long FLAG_PASSPOINT_NETWORK = 0x0000000000000001;
Vinit Deshpande7226c8f2015-06-30 13:43:02 -0700333
334 /** {@hide} */
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700335 public static final long FLAG_80211mc_RESPONDER = 0x0000000000000002;
Vinit Deshpande2522c832015-03-12 17:04:35 -0700336
Samuel Tan40b56172016-03-23 14:21:28 -0700337 /*
338 * These flags are specific to the ScanResult class, and are not related to the |flags|
339 * field of the per-BSS scan results from WPA supplicant.
340 */
Vinit Deshpande2522c832015-03-12 17:04:35 -0700341 /**
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700342 * Defines flags; such as {@link #FLAG_PASSPOINT_NETWORK}.
Vinit Deshpande7226c8f2015-06-30 13:43:02 -0700343 * {@hide}
Vinit Deshpande2522c832015-03-12 17:04:35 -0700344 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100345 @UnsupportedAppUsage
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700346 public long flags;
Vinit Deshpande2522c832015-03-12 17:04:35 -0700347
348 /**
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700349 * sets a flag in {@link #flags} field
350 * @param flag flag to set
351 * @hide
Vinit Deshpande2522c832015-03-12 17:04:35 -0700352 */
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700353 public void setFlag(long flag) {
354 flags |= flag;
355 }
356
357 /**
358 * clears a flag in {@link #flags} field
359 * @param flag flag to set
360 * @hide
361 */
362 public void clearFlag(long flag) {
363 flags &= ~flag;
364 }
365
366 public boolean is80211mcResponder() {
367 return (flags & FLAG_80211mc_RESPONDER) != 0;
368 }
369
370 public boolean isPasspointNetwork() {
371 return (flags & FLAG_PASSPOINT_NETWORK) != 0;
372 }
373
374 /**
375 * Indicates venue name (such as 'San Francisco Airport') published by access point; only
Peter Qiu6bbc8952017-03-21 18:42:55 -0700376 * available on Passpoint network and if published by access point.
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700377 */
378 public CharSequence venueName;
379
380 /**
Peter Qiu6bbc8952017-03-21 18:42:55 -0700381 * Indicates Passpoint operator name published by access point.
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700382 */
383 public CharSequence operatorFriendlyName;
Vinit Deshpande7dd2f6b2015-01-02 11:36:27 -0800384
385 /**
Robert Greenwalt0451d592013-08-01 18:24:13 -0700386 * {@hide}
387 */
388 public final static int UNSPECIFIED = -1;
vandwalle111fa022014-06-10 20:47:58 -0700389 /**
390 * @hide
vandwalle111fa022014-06-10 20:47:58 -0700391 */
392 public boolean is24GHz() {
vandwalle4eeecb22014-07-25 17:10:56 -0700393 return ScanResult.is24GHz(frequency);
vandwalle111fa022014-06-10 20:47:58 -0700394 }
395
396 /**
397 * @hide
398 * TODO: makes real freq boundaries
399 */
vandwalle4eeecb22014-07-25 17:10:56 -0700400 public static boolean is24GHz(int freq) {
401 return freq > 2400 && freq < 2500;
402 }
403
404 /**
405 * @hide
406 */
vandwalle111fa022014-06-10 20:47:58 -0700407 public boolean is5GHz() {
vandwalleec5a9012014-07-28 20:48:33 -0700408 return ScanResult.is5GHz(frequency);
vandwalle4eeecb22014-07-25 17:10:56 -0700409 }
410
411 /**
412 * @hide
413 * TODO: makes real freq boundaries
414 */
415 public static boolean is5GHz(int freq) {
416 return freq > 4900 && freq < 5900;
vandwalle111fa022014-06-10 20:47:58 -0700417 }
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700418
Pierre Vandwallefc197d32015-04-14 15:33:22 -0700419 /**
420 * @hide
Mitchell Wills9eeba372016-01-27 22:58:16 -0800421 * anqp lines from supplicant BSS response
422 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100423 @UnsupportedAppUsage
Mitchell Wills9eeba372016-01-27 22:58:16 -0800424 public List<String> anqpLines;
425
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700426 /** information elements from beacon
Vinit Deshpande55027bb2014-05-29 15:58:48 -0700427 * @hide
428 */
429 public static class InformationElement {
Mathew Inwood53f089f2018-08-08 14:44:44 +0100430 @UnsupportedAppUsage
Mitchell Wills21c748d2015-07-28 09:56:53 -0700431 public static final int EID_SSID = 0;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100432 @UnsupportedAppUsage
Glen Kuhnebff37ec2016-03-01 14:32:28 -0800433 public static final int EID_SUPPORTED_RATES = 1;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100434 @UnsupportedAppUsage
Glen Kuhneb6cd6fa2016-02-10 15:08:33 -0800435 public static final int EID_TIM = 5;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100436 @UnsupportedAppUsage
Mitchell Wills21c748d2015-07-28 09:56:53 -0700437 public static final int EID_BSS_LOAD = 11;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100438 @UnsupportedAppUsage
Glen Kuhnebff37ec2016-03-01 14:32:28 -0800439 public static final int EID_ERP = 42;
Etan Cohen67f5ffb2018-04-26 17:49:20 -0700440 public static final int EID_HT_CAPABILITIES = 45;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100441 @UnsupportedAppUsage
Randy Panc0e86b22016-02-04 14:54:03 -0800442 public static final int EID_RSN = 48;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100443 @UnsupportedAppUsage
Glen Kuhnebff37ec2016-03-01 14:32:28 -0800444 public static final int EID_EXTENDED_SUPPORTED_RATES = 50;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100445 @UnsupportedAppUsage
Mitchell Wills21c748d2015-07-28 09:56:53 -0700446 public static final int EID_HT_OPERATION = 61;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100447 @UnsupportedAppUsage
Mitchell Wills21c748d2015-07-28 09:56:53 -0700448 public static final int EID_INTERWORKING = 107;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100449 @UnsupportedAppUsage
Mitchell Wills21c748d2015-07-28 09:56:53 -0700450 public static final int EID_ROAMING_CONSORTIUM = 111;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100451 @UnsupportedAppUsage
Mitchell Wills21c748d2015-07-28 09:56:53 -0700452 public static final int EID_EXTENDED_CAPS = 127;
Etan Cohen67f5ffb2018-04-26 17:49:20 -0700453 public static final int EID_VHT_CAPABILITIES = 191;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100454 @UnsupportedAppUsage
Mitchell Wills21c748d2015-07-28 09:56:53 -0700455 public static final int EID_VHT_OPERATION = 192;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100456 @UnsupportedAppUsage
Mitchell Wills21c748d2015-07-28 09:56:53 -0700457 public static final int EID_VSA = 221;
458
Mathew Inwood53f089f2018-08-08 14:44:44 +0100459 @UnsupportedAppUsage
Vinit Deshpande55027bb2014-05-29 15:58:48 -0700460 public int id;
Mathew Inwood53f089f2018-08-08 14:44:44 +0100461 @UnsupportedAppUsage
Vinit Deshpande55027bb2014-05-29 15:58:48 -0700462 public byte[] bytes;
Vinit Deshpandeea676a02014-07-29 15:52:20 -0700463
464 public InformationElement() {
465 }
466
467 public InformationElement(InformationElement rhs) {
468 this.id = rhs.id;
469 this.bytes = rhs.bytes.clone();
470 }
Vinit Deshpande55027bb2014-05-29 15:58:48 -0700471 }
472
473 /** information elements found in the beacon
474 * @hide
475 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100476 @UnsupportedAppUsage
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800477 public InformationElement[] informationElements;
478
479 /** ANQP response elements.
480 * @hide
481 */
482 public AnqpInformationElement[] anqpElements;
Vinit Deshpande55027bb2014-05-29 15:58:48 -0700483
Peter Qiud3ad1542017-07-20 14:43:52 -0700484 /**
485 * Flag indicating if this AP is a carrier AP. The determination is based
486 * on the AP's SSID and if AP is using EAP security.
487 *
488 * @hide
489 */
490 public boolean isCarrierAp;
491
492 /**
493 * The EAP type {@link WifiEnterpriseConfig.Eap} associated with this AP if it is a carrier AP.
494 *
495 * @hide
496 */
497 public int carrierApEapType;
498
499 /**
500 * The name of the carrier that's associated with this AP if it is a carrier AP.
501 *
502 * @hide
503 */
504 public String carrierName;
505
Irfan Sheriffb6deeed2012-09-05 10:46:24 -0700506 /** {@hide} */
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800507 public ScanResult(WifiSsid wifiSsid, String BSSID, long hessid, int anqpDomainId,
508 byte[] osuProviders, String caps, int level, int frequency, long tsf) {
Irfan Sheriffb6deeed2012-09-05 10:46:24 -0700509 this.wifiSsid = wifiSsid;
510 this.SSID = (wifiSsid != null) ? wifiSsid.toString() : WifiSsid.NONE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800511 this.BSSID = BSSID;
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800512 this.hessid = hessid;
513 this.anqpDomainId = anqpDomainId;
514 if (osuProviders != null) {
515 this.anqpElements = new AnqpInformationElement[1];
516 this.anqpElements[0] =
517 new AnqpInformationElement(AnqpInformationElement.HOTSPOT20_VENDOR_ID,
518 AnqpInformationElement.HS_OSU_PROVIDERS, osuProviders);
519 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800520 this.capabilities = caps;
521 this.level = level;
522 this.frequency = frequency;
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700523 this.timestamp = tsf;
Robert Greenwalt0451d592013-08-01 18:24:13 -0700524 this.distanceCm = UNSPECIFIED;
525 this.distanceSdCm = UNSPECIFIED;
xinhe6e584242015-03-02 14:04:35 -0800526 this.channelWidth = UNSPECIFIED;
527 this.centerFreq0 = UNSPECIFIED;
528 this.centerFreq1 = UNSPECIFIED;
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700529 this.flags = 0;
Peter Qiud3ad1542017-07-20 14:43:52 -0700530 this.isCarrierAp = false;
531 this.carrierApEapType = UNSPECIFIED;
532 this.carrierName = null;
Roshan Pius4f176152017-10-27 15:12:51 -0700533 this.radioChainInfos = null;
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700534 }
535
Robert Greenwalt0451d592013-08-01 18:24:13 -0700536 /** {@hide} */
537 public ScanResult(WifiSsid wifiSsid, String BSSID, String caps, int level, int frequency,
538 long tsf, int distCm, int distSdCm) {
539 this.wifiSsid = wifiSsid;
540 this.SSID = (wifiSsid != null) ? wifiSsid.toString() : WifiSsid.NONE;
541 this.BSSID = BSSID;
542 this.capabilities = caps;
543 this.level = level;
544 this.frequency = frequency;
545 this.timestamp = tsf;
546 this.distanceCm = distCm;
547 this.distanceSdCm = distSdCm;
xinhe6e584242015-03-02 14:04:35 -0800548 this.channelWidth = UNSPECIFIED;
549 this.centerFreq0 = UNSPECIFIED;
550 this.centerFreq1 = UNSPECIFIED;
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700551 this.flags = 0;
Peter Qiud3ad1542017-07-20 14:43:52 -0700552 this.isCarrierAp = false;
553 this.carrierApEapType = UNSPECIFIED;
554 this.carrierName = null;
Roshan Pius4f176152017-10-27 15:12:51 -0700555 this.radioChainInfos = null;
xinhe6e584242015-03-02 14:04:35 -0800556 }
557
558 /** {@hide} */
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800559 public ScanResult(String Ssid, String BSSID, long hessid, int anqpDomainId, String caps,
560 int level, int frequency,
xinhe6e584242015-03-02 14:04:35 -0800561 long tsf, int distCm, int distSdCm, int channelWidth, int centerFreq0, int centerFreq1,
562 boolean is80211McRTTResponder) {
xinhef2c01042015-07-31 12:50:55 -0700563 this.SSID = Ssid;
xinhe6e584242015-03-02 14:04:35 -0800564 this.BSSID = BSSID;
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800565 this.hessid = hessid;
566 this.anqpDomainId = anqpDomainId;
xinhe6e584242015-03-02 14:04:35 -0800567 this.capabilities = caps;
568 this.level = level;
569 this.frequency = frequency;
570 this.timestamp = tsf;
571 this.distanceCm = distCm;
572 this.distanceSdCm = distSdCm;
573 this.channelWidth = channelWidth;
574 this.centerFreq0 = centerFreq0;
575 this.centerFreq1 = centerFreq1;
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700576 if (is80211McRTTResponder) {
577 this.flags = FLAG_80211mc_RESPONDER;
578 } else {
579 this.flags = 0;
580 }
Peter Qiud3ad1542017-07-20 14:43:52 -0700581 this.isCarrierAp = false;
582 this.carrierApEapType = UNSPECIFIED;
583 this.carrierName = null;
Roshan Pius4f176152017-10-27 15:12:51 -0700584 this.radioChainInfos = null;
Robert Greenwalt0451d592013-08-01 18:24:13 -0700585 }
Irfan Sheriffb6deeed2012-09-05 10:46:24 -0700586
xinhef2c01042015-07-31 12:50:55 -0700587 /** {@hide} */
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800588 public ScanResult(WifiSsid wifiSsid, String Ssid, String BSSID, long hessid, int anqpDomainId,
589 String caps, int level,
xinhef2c01042015-07-31 12:50:55 -0700590 int frequency, long tsf, int distCm, int distSdCm, int channelWidth,
591 int centerFreq0, int centerFreq1, boolean is80211McRTTResponder) {
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800592 this(Ssid, BSSID, hessid, anqpDomainId, caps, level, frequency, tsf, distCm,
593 distSdCm, channelWidth, centerFreq0, centerFreq1, is80211McRTTResponder);
xinhef2c01042015-07-31 12:50:55 -0700594 this.wifiSsid = wifiSsid;
595 }
596
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700597 /** copy constructor {@hide} */
598 public ScanResult(ScanResult source) {
599 if (source != null) {
Irfan Sheriffb6deeed2012-09-05 10:46:24 -0700600 wifiSsid = source.wifiSsid;
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700601 SSID = source.SSID;
602 BSSID = source.BSSID;
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800603 hessid = source.hessid;
604 anqpDomainId = source.anqpDomainId;
605 informationElements = source.informationElements;
606 anqpElements = source.anqpElements;
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700607 capabilities = source.capabilities;
608 level = source.level;
609 frequency = source.frequency;
xinhe6e584242015-03-02 14:04:35 -0800610 channelWidth = source.channelWidth;
611 centerFreq0 = source.centerFreq0;
612 centerFreq1 = source.centerFreq1;
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700613 timestamp = source.timestamp;
Robert Greenwalt0451d592013-08-01 18:24:13 -0700614 distanceCm = source.distanceCm;
615 distanceSdCm = source.distanceSdCm;
vandwalle7c3606c2014-03-31 19:12:07 -0700616 seen = source.seen;
vandwalle4eeecb22014-07-25 17:10:56 -0700617 untrusted = source.untrusted;
vandwalle4eeecb22014-07-25 17:10:56 -0700618 numUsage = source.numUsage;
Vinit Deshpande2522c832015-03-12 17:04:35 -0700619 venueName = source.venueName;
620 operatorFriendlyName = source.operatorFriendlyName;
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700621 flags = source.flags;
Peter Qiud3ad1542017-07-20 14:43:52 -0700622 isCarrierAp = source.isCarrierAp;
623 carrierApEapType = source.carrierApEapType;
624 carrierName = source.carrierName;
Roshan Pius4f176152017-10-27 15:12:51 -0700625 radioChainInfos = source.radioChainInfos;
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700626 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800627 }
628
Vinit Deshapnde011e1b32014-05-07 21:09:11 -0700629 /** empty scan result
630 *
631 * {@hide}
632 * */
633 public ScanResult() {
634 }
635
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800636 @Override
637 public String toString() {
638 StringBuffer sb = new StringBuffer();
639 String none = "<none>";
640
641 sb.append("SSID: ").
Irfan Sheriffb6deeed2012-09-05 10:46:24 -0700642 append(wifiSsid == null ? WifiSsid.NONE : wifiSsid).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800643 append(", BSSID: ").
644 append(BSSID == null ? none : BSSID).
645 append(", capabilities: ").
646 append(capabilities == null ? none : capabilities).
647 append(", level: ").
648 append(level).
649 append(", frequency: ").
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700650 append(frequency).
651 append(", timestamp: ").
652 append(timestamp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800653
Robert Greenwalt0451d592013-08-01 18:24:13 -0700654 sb.append(", distance: ").append((distanceCm != UNSPECIFIED ? distanceCm : "?")).
655 append("(cm)");
656 sb.append(", distanceSd: ").append((distanceSdCm != UNSPECIFIED ? distanceSdCm : "?")).
657 append("(cm)");
658
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700659 sb.append(", passpoint: ");
660 sb.append(((flags & FLAG_PASSPOINT_NETWORK) != 0) ? "yes" : "no");
xinhe6e584242015-03-02 14:04:35 -0800661 sb.append(", ChannelBandwidth: ").append(channelWidth);
662 sb.append(", centerFreq0: ").append(centerFreq0);
663 sb.append(", centerFreq1: ").append(centerFreq1);
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700664 sb.append(", 80211mcResponder: ");
665 sb.append(((flags & FLAG_80211mc_RESPONDER) != 0) ? "is supported" : "is not supported");
Peter Qiud3ad1542017-07-20 14:43:52 -0700666 sb.append(", Carrier AP: ").append(isCarrierAp ? "yes" : "no");
667 sb.append(", Carrier AP EAP Type: ").append(carrierApEapType);
668 sb.append(", Carrier name: ").append(carrierName);
Roshan Pius4f176152017-10-27 15:12:51 -0700669 sb.append(", Radio Chain Infos: ").append(Arrays.toString(radioChainInfos));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800670 return sb.toString();
671 }
672
673 /** Implement the Parcelable interface {@hide} */
674 public int describeContents() {
675 return 0;
676 }
677
678 /** Implement the Parcelable interface {@hide} */
679 public void writeToParcel(Parcel dest, int flags) {
Irfan Sheriffb6deeed2012-09-05 10:46:24 -0700680 if (wifiSsid != null) {
681 dest.writeInt(1);
682 wifiSsid.writeToParcel(dest, flags);
683 } else {
684 dest.writeInt(0);
685 }
xinhef2c01042015-07-31 12:50:55 -0700686 dest.writeString(SSID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800687 dest.writeString(BSSID);
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800688 dest.writeLong(hessid);
689 dest.writeInt(anqpDomainId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800690 dest.writeString(capabilities);
691 dest.writeInt(level);
692 dest.writeInt(frequency);
Iliyan Malchev06c43d52012-08-20 12:52:35 -0700693 dest.writeLong(timestamp);
Robert Greenwalt0451d592013-08-01 18:24:13 -0700694 dest.writeInt(distanceCm);
695 dest.writeInt(distanceSdCm);
xinhe6e584242015-03-02 14:04:35 -0800696 dest.writeInt(channelWidth);
697 dest.writeInt(centerFreq0);
698 dest.writeInt(centerFreq1);
vandwalle5fb7bf52014-05-21 15:20:59 -0700699 dest.writeLong(seen);
vandwalle4eeecb22014-07-25 17:10:56 -0700700 dest.writeInt(untrusted ? 1 : 0);
vandwalle4eeecb22014-07-25 17:10:56 -0700701 dest.writeInt(numUsage);
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700702 dest.writeString((venueName != null) ? venueName.toString() : "");
703 dest.writeString((operatorFriendlyName != null) ? operatorFriendlyName.toString() : "");
704 dest.writeLong(this.flags);
Vinit Deshpande2522c832015-03-12 17:04:35 -0700705
Vinit Deshpande55027bb2014-05-29 15:58:48 -0700706 if (informationElements != null) {
707 dest.writeInt(informationElements.length);
708 for (int i = 0; i < informationElements.length; i++) {
709 dest.writeInt(informationElements[i].id);
710 dest.writeInt(informationElements[i].bytes.length);
711 dest.writeByteArray(informationElements[i].bytes);
712 }
713 } else {
714 dest.writeInt(0);
715 }
Mitchell Wills9eeba372016-01-27 22:58:16 -0800716
717 if (anqpLines != null) {
718 dest.writeInt(anqpLines.size());
719 for (int i = 0; i < anqpLines.size(); i++) {
720 dest.writeString(anqpLines.get(i));
721 }
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800722 }
Jan Nordqvist7a504412016-02-03 14:26:21 -0800723 else {
724 dest.writeInt(0);
725 }
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800726 if (anqpElements != null) {
727 dest.writeInt(anqpElements.length);
728 for (AnqpInformationElement element : anqpElements) {
729 dest.writeInt(element.getVendorId());
730 dest.writeInt(element.getElementId());
731 dest.writeInt(element.getPayload().length);
732 dest.writeByteArray(element.getPayload());
733 }
Mitchell Wills9eeba372016-01-27 22:58:16 -0800734 } else {
735 dest.writeInt(0);
736 }
Peter Qiud3ad1542017-07-20 14:43:52 -0700737 dest.writeInt(isCarrierAp ? 1 : 0);
738 dest.writeInt(carrierApEapType);
739 dest.writeString(carrierName);
Roshan Pius4f176152017-10-27 15:12:51 -0700740
741 if (radioChainInfos != null) {
742 dest.writeInt(radioChainInfos.length);
743 for (int i = 0; i < radioChainInfos.length; i++) {
744 dest.writeInt(radioChainInfos[i].id);
745 dest.writeInt(radioChainInfos[i].level);
746 }
747 } else {
748 dest.writeInt(0);
749 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800750 }
751
752 /** Implement the Parcelable interface {@hide} */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100753 @UnsupportedAppUsage
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700754 public static final @android.annotation.NonNull Creator<ScanResult> CREATOR =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800755 new Creator<ScanResult>() {
756 public ScanResult createFromParcel(Parcel in) {
Irfan Sheriffb6deeed2012-09-05 10:46:24 -0700757 WifiSsid wifiSsid = null;
758 if (in.readInt() == 1) {
759 wifiSsid = WifiSsid.CREATOR.createFromParcel(in);
760 }
Yuhao Zhenga4864472014-04-10 11:45:42 -0700761 ScanResult sr = new ScanResult(
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800762 wifiSsid,
763 in.readString(), /* SSID */
764 in.readString(), /* BSSID */
765 in.readLong(), /* HESSID */
766 in.readInt(), /* ANQP Domain ID */
767 in.readString(), /* capabilities */
768 in.readInt(), /* level */
769 in.readInt(), /* frequency */
770 in.readLong(), /* timestamp */
771 in.readInt(), /* distanceCm */
772 in.readInt(), /* distanceSdCm */
773 in.readInt(), /* channelWidth */
774 in.readInt(), /* centerFreq0 */
775 in.readInt(), /* centerFreq1 */
776 false /* rtt responder,
777 fixed with flags below */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800778 );
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700779
vandwalle5fb7bf52014-05-21 15:20:59 -0700780 sr.seen = in.readLong();
vandwalle4eeecb22014-07-25 17:10:56 -0700781 sr.untrusted = in.readInt() != 0;
vandwalleb1dce022014-08-27 01:00:11 -0700782 sr.numUsage = in.readInt();
Vinit Deshpande2522c832015-03-12 17:04:35 -0700783 sr.venueName = in.readString();
784 sr.operatorFriendlyName = in.readString();
Vinit Deshpandea0d929e2015-06-12 15:18:44 -0700785 sr.flags = in.readLong();
Vinit Deshpande55027bb2014-05-29 15:58:48 -0700786 int n = in.readInt();
787 if (n != 0) {
788 sr.informationElements = new InformationElement[n];
789 for (int i = 0; i < n; i++) {
790 sr.informationElements[i] = new InformationElement();
791 sr.informationElements[i].id = in.readInt();
792 int len = in.readInt();
793 sr.informationElements[i].bytes = new byte[len];
794 in.readByteArray(sr.informationElements[i].bytes);
795 }
796 }
Mitchell Wills9eeba372016-01-27 22:58:16 -0800797
798 n = in.readInt();
799 if (n != 0) {
800 sr.anqpLines = new ArrayList<String>();
801 for (int i = 0; i < n; i++) {
802 sr.anqpLines.add(in.readString());
803 }
804 }
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800805 n = in.readInt();
806 if (n != 0) {
807 sr.anqpElements = new AnqpInformationElement[n];
808 for (int i = 0; i < n; i++) {
809 int vendorId = in.readInt();
810 int elementId = in.readInt();
811 int len = in.readInt();
812 byte[] payload = new byte[len];
813 in.readByteArray(payload);
Jan Nordqvist7a504412016-02-03 14:26:21 -0800814 sr.anqpElements[i] =
Vinit Deshpandea772f0c2016-01-27 19:05:24 -0800815 new AnqpInformationElement(vendorId, elementId, payload);
816 }
817 }
Peter Qiud3ad1542017-07-20 14:43:52 -0700818 sr.isCarrierAp = in.readInt() != 0;
819 sr.carrierApEapType = in.readInt();
820 sr.carrierName = in.readString();
Roshan Pius4f176152017-10-27 15:12:51 -0700821 n = in.readInt();
822 if (n != 0) {
823 sr.radioChainInfos = new RadioChainInfo[n];
824 for (int i = 0; i < n; i++) {
825 sr.radioChainInfos[i] = new RadioChainInfo();
826 sr.radioChainInfos[i].id = in.readInt();
827 sr.radioChainInfos[i].level = in.readInt();
828 }
829 }
Yuhao Zhenga4864472014-04-10 11:45:42 -0700830 return sr;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800831 }
832
833 public ScanResult[] newArray(int size) {
834 return new ScanResult[size];
835 }
836 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800837}