19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/*
29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License.
69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at
79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and
149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License.
159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.net.wifi;
189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.Parcel;
20e4ce619880e831992b005c17dfabb7800994d0c7Jeff Davidsonimport android.os.Parcelable;
219eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills
229eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Willsimport java.util.ArrayList;
239eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Willsimport java.util.List;
249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/**
269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Describes information about a detected access point. In addition
279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to the attributes described here, the supplicant keeps track of
289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@code quality}, {@code noise}, and {@code maxbitrate} attributes,
299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * but does not currently report them to external clients.
309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class ScanResult implements Parcelable {
324eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
334eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * The network name.
344eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public String SSID;
36b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff
374eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
384eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * Ascii encoded SSID. This will replace SSID when we deprecate it. @hide
394eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
40b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff    public WifiSsid wifiSsid;
41b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff
424eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
434eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * The address of the access point.
444eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public String BSSID;
46a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande
47a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    /**
48a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande     * The HESSID from the beacon.
49a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande     * @hide
50a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande     */
51a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    public long hessid;
52a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande
53a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    /**
54a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande     * The ANQP Domain ID from the Hotspot 2.0 Indication element, if present.
55a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande     * @hide
56a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande     */
57a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    public int anqpDomainId;
58a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande
5940b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan    /*
6040b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan     * This field is equivalent to the |flags|, rather than the |capabilities| field
6140b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan     * of the per-BSS scan results returned by WPA supplicant. See the definition of
6240b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan     * |struct wpa_bss| in wpa_supplicant/bss.h for more details.
6340b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan     */
649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Describes the authentication, key management, and encryption schemes
669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * supported by the access point.
679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public String capabilities;
699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
70e4ce619880e831992b005c17dfabb7800994d0c7Jeff Davidson     * The detected signal level in dBm, also known as the RSSI.
71e4ce619880e831992b005c17dfabb7800994d0c7Jeff Davidson     *
72e4ce619880e831992b005c17dfabb7800994d0c7Jeff Davidson     * <p>Use {@link android.net.wifi.WifiManager#calculateSignalLevel} to convert this number into
73e4ce619880e831992b005c17dfabb7800994d0c7Jeff Davidson     * an absolute signal level which can be displayed to a user.
749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public int level;
769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
776e58424f5b052531a724a54629f00915ad3edadaxinhe     * The primary 20 MHz frequency (in MHz) of the channel over which the client is communicating
789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * with the access point.
799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public int frequency;
819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
826e58424f5b052531a724a54629f00915ad3edadaxinhe   /**
836e58424f5b052531a724a54629f00915ad3edadaxinhe    * AP Channel bandwidth is 20 MHZ
846e58424f5b052531a724a54629f00915ad3edadaxinhe    */
856e58424f5b052531a724a54629f00915ad3edadaxinhe    public static final int CHANNEL_WIDTH_20MHZ = 0;
866e58424f5b052531a724a54629f00915ad3edadaxinhe   /**
876e58424f5b052531a724a54629f00915ad3edadaxinhe    * AP Channel bandwidth is 40 MHZ
886e58424f5b052531a724a54629f00915ad3edadaxinhe    */
896e58424f5b052531a724a54629f00915ad3edadaxinhe    public static final int CHANNEL_WIDTH_40MHZ = 1;
906e58424f5b052531a724a54629f00915ad3edadaxinhe   /**
916e58424f5b052531a724a54629f00915ad3edadaxinhe    * AP Channel bandwidth is 80 MHZ
926e58424f5b052531a724a54629f00915ad3edadaxinhe    */
936e58424f5b052531a724a54629f00915ad3edadaxinhe    public static final int CHANNEL_WIDTH_80MHZ = 2;
946e58424f5b052531a724a54629f00915ad3edadaxinhe   /**
956e58424f5b052531a724a54629f00915ad3edadaxinhe    * AP Channel bandwidth is 160 MHZ
966e58424f5b052531a724a54629f00915ad3edadaxinhe    */
976e58424f5b052531a724a54629f00915ad3edadaxinhe    public static final int CHANNEL_WIDTH_160MHZ = 3;
986e58424f5b052531a724a54629f00915ad3edadaxinhe   /**
996e58424f5b052531a724a54629f00915ad3edadaxinhe    * AP Channel bandwidth is 160 MHZ, but 80MHZ + 80MHZ
1006e58424f5b052531a724a54629f00915ad3edadaxinhe    */
1016e58424f5b052531a724a54629f00915ad3edadaxinhe    public static final int CHANNEL_WIDTH_80MHZ_PLUS_MHZ = 4;
1026e58424f5b052531a724a54629f00915ad3edadaxinhe
1036e58424f5b052531a724a54629f00915ad3edadaxinhe   /**
104a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    * AP Channel bandwidth; one of {@link #CHANNEL_WIDTH_20MHZ}, {@link #CHANNEL_WIDTH_40MHZ},
105a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    * {@link #CHANNEL_WIDTH_80MHZ}, {@link #CHANNEL_WIDTH_160MHZ}
106a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    * or {@link #CHANNEL_WIDTH_80MHZ_PLUS_MHZ}.
1076e58424f5b052531a724a54629f00915ad3edadaxinhe    */
1086e58424f5b052531a724a54629f00915ad3edadaxinhe    public int channelWidth;
1096e58424f5b052531a724a54629f00915ad3edadaxinhe
1106e58424f5b052531a724a54629f00915ad3edadaxinhe    /**
1116e58424f5b052531a724a54629f00915ad3edadaxinhe     * Not used if the AP bandwidth is 20 MHz
112a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * If the AP use 40, 80 or 160 MHz, this is the center frequency (in MHz)
113a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * if the AP use 80 + 80 MHz, this is the center frequency of the first segment (in MHz)
1146e58424f5b052531a724a54629f00915ad3edadaxinhe     */
1156e58424f5b052531a724a54629f00915ad3edadaxinhe    public int centerFreq0;
1166e58424f5b052531a724a54629f00915ad3edadaxinhe
1176e58424f5b052531a724a54629f00915ad3edadaxinhe    /**
1186e58424f5b052531a724a54629f00915ad3edadaxinhe     * Only used if the AP bandwidth is 80 + 80 MHz
119a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * if the AP use 80 + 80 MHz, this is the center frequency of the second segment (in MHz)
1206e58424f5b052531a724a54629f00915ad3edadaxinhe     */
1216e58424f5b052531a724a54629f00915ad3edadaxinhe    public int centerFreq1;
1226e58424f5b052531a724a54629f00915ad3edadaxinhe
1236e58424f5b052531a724a54629f00915ad3edadaxinhe    /**
124a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * @deprecated use is80211mcResponder() instead
125a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * @hide
1266e58424f5b052531a724a54629f00915ad3edadaxinhe     */
127a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public boolean is80211McRTTResponder;
1286e58424f5b052531a724a54629f00915ad3edadaxinhe
1299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
13002b115b2d8a889bcc04594802ffcbc880644012cVinit Deshpande     * timestamp in microseconds (since boot) when
13106c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev     * this result was last seen.
13206c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev     */
1330451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public long timestamp;
1340451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
1350451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /**
1367c3606c103e95d3991267cca2592402a68779cafvandwalle     * Timestamp representing date when this result was last seen, in milliseconds from 1970
1377c3606c103e95d3991267cca2592402a68779cafvandwalle     * {@hide}
1387c3606c103e95d3991267cca2592402a68779cafvandwalle     */
1397c3606c103e95d3991267cca2592402a68779cafvandwalle    public long seen;
1407c3606c103e95d3991267cca2592402a68779cafvandwalle
1414eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
14263edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle     * If the scan result is a valid autojoin candidate
14363edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle     * {@hide}
14463edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle     */
14563edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle    public int isAutoJoinCandidate;
14663edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle
14763edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle    /**
1484eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * @hide
1494eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * Update RSSI of the scan result
150a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * @param previousRssi
1514eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * @param previousSeen
1524eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * @param maxAge
1534eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
1544eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    public void averageRssi(int previousRssi, long previousSeen, int maxAge) {
1554eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle
1564eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        if (seen == 0) {
1574eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle            seen = System.currentTimeMillis();
1584eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        }
1594eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        long age = seen - previousSeen;
1604eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle
1614eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        if (previousSeen > 0 && age > 0 && age < maxAge/2) {
1624eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle            // Average the RSSI with previously seen instances of this scan result
1634eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle            double alpha = 0.5 - (double) age / (double) maxAge;
1644eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle            level = (int) ((double) level * (1 - alpha) + (double) previousRssi * alpha);
1654eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        }
1664eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    }
1674eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle
168612519db40db1bad7597ab207f14c9b5b5524a93vandwalle    /**
169176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle     * num IP configuration failures
170176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle     * @hide
171176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle     */
172176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle    public int numIpConfigFailures;
173176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle
174176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle    /**
175612519db40db1bad7597ab207f14c9b5b5524a93vandwalle     * @hide
176612519db40db1bad7597ab207f14c9b5b5524a93vandwalle     * Last time we blacklisted the ScanResult
177612519db40db1bad7597ab207f14c9b5b5524a93vandwalle     */
178612519db40db1bad7597ab207f14c9b5b5524a93vandwalle    public long blackListTimestamp;
179612519db40db1bad7597ab207f14c9b5b5524a93vandwalle
1807c3606c103e95d3991267cca2592402a68779cafvandwalle    /**
1814eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * Status: indicating the scan result is not a result
1824eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * that is part of user's saved configurations
1834eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * @hide
1844eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
1854eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    public boolean untrusted;
1864eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle
1874eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
1884eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * Number of time we connected to it
1894eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * @hide
1904eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
1914eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    public int numConnection;
1924eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle
1934eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
1944eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * Number of time autojoin used it
1954eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * @hide
1964eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
1974eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    public int numUsage;
1984eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle
1994eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
2000451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     * The approximate distance to the AP in centimeter, if available.  Else
2010451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     * {@link UNSPECIFIED}.
2020451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     * {@hide}
2030451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     */
2040451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int distanceCm;
2050451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
2060451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /**
207a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * The standard deviation of the distance to the access point, if available.
2080451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     * Else {@link UNSPECIFIED}.
2090451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     * {@hide}
2100451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     */
2110451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int distanceSdCm;
2120451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
2137226c8f95b5971af2710c8d2f8a8b6f2210e2420Vinit Deshpande    /** {@hide} */
214a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public static final long FLAG_PASSPOINT_NETWORK               = 0x0000000000000001;
2157226c8f95b5971af2710c8d2f8a8b6f2210e2420Vinit Deshpande
2167226c8f95b5971af2710c8d2f8a8b6f2210e2420Vinit Deshpande    /** {@hide} */
217a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public static final long FLAG_80211mc_RESPONDER               = 0x0000000000000002;
218a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande
21940b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan    /*
22040b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan     * These flags are specific to the ScanResult class, and are not related to the |flags|
22140b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan     * field of the per-BSS scan results from WPA supplicant.
22240b5617e15e7f02de8346d99abe2a90edf0d17a0Samuel Tan     */
2230451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /**
224a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * Defines flags; such as {@link #FLAG_PASSPOINT_NETWORK}.
2257226c8f95b5971af2710c8d2f8a8b6f2210e2420Vinit Deshpande     * {@hide}
2262522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande     */
227a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public long flags;
2282522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande
2292522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande    /**
230a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * sets a flag in {@link #flags} field
231a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * @param flag flag to set
232a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * @hide
2332522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande     */
234a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public void setFlag(long flag) {
235a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        flags |= flag;
236a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    }
2372522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande
2382522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande    /**
239a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * clears a flag in {@link #flags} field
240a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * @param flag flag to set
241a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * @hide
2427dd2f6b57b5ef1f14eb55b7801a3d31729ad7a0aVinit Deshpande     */
243a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public void clearFlag(long flag) {
244a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        flags &= ~flag;
245a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    }
246a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande
247a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public boolean is80211mcResponder() {
248a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        return (flags & FLAG_80211mc_RESPONDER) != 0;
249a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    }
250a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande
251a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public boolean isPasspointNetwork() {
252a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        return (flags & FLAG_PASSPOINT_NETWORK) != 0;
253a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    }
254a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande
255a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    /**
256a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * Indicates venue name (such as 'San Francisco Airport') published by access point; only
257a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * available on passpoint network and if published by access point.
258a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     */
259a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public CharSequence venueName;
260a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande
261a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    /**
262a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     * Indicates passpoint operator name published by access point.
263a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande     */
264a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    public CharSequence operatorFriendlyName;
2657dd2f6b57b5ef1f14eb55b7801a3d31729ad7a0aVinit Deshpande
2667dd2f6b57b5ef1f14eb55b7801a3d31729ad7a0aVinit Deshpande    /**
2670451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     * {@hide}
2680451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     */
2690451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int UNSPECIFIED = -1;
270111fa0274d1d6620f9634783585387f3b773949evandwalle    /**
271111fa0274d1d6620f9634783585387f3b773949evandwalle     * @hide
272111fa0274d1d6620f9634783585387f3b773949evandwalle     */
273111fa0274d1d6620f9634783585387f3b773949evandwalle    public boolean is24GHz() {
2744eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        return ScanResult.is24GHz(frequency);
275111fa0274d1d6620f9634783585387f3b773949evandwalle    }
276111fa0274d1d6620f9634783585387f3b773949evandwalle
277111fa0274d1d6620f9634783585387f3b773949evandwalle    /**
278111fa0274d1d6620f9634783585387f3b773949evandwalle     * @hide
279111fa0274d1d6620f9634783585387f3b773949evandwalle     * TODO: makes real freq boundaries
280111fa0274d1d6620f9634783585387f3b773949evandwalle     */
2814eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    public static boolean is24GHz(int freq) {
2824eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        return freq > 2400 && freq < 2500;
2834eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    }
2844eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle
2854eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
2864eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * @hide
2874eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
288111fa0274d1d6620f9634783585387f3b773949evandwalle    public boolean is5GHz() {
289ec5a901ea88109f2bd5ac0a635b48176135ed32fvandwalle        return ScanResult.is5GHz(frequency);
2904eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    }
2914eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle
2924eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    /**
2934eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * @hide
2944eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     * TODO: makes real freq boundaries
2954eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle     */
2964eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle    public static boolean is5GHz(int freq) {
2974eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        return freq > 4900 && freq < 5900;
298111fa0274d1d6620f9634783585387f3b773949evandwalle    }
29906c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev
300fc197d392300116b47c87dcc87453c3465ca6ce2Pierre Vandwalle    /**
301fc197d392300116b47c87dcc87453c3465ca6ce2Pierre Vandwalle     *  @hide
3029eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills     * anqp lines from supplicant BSS response
3039eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills     */
3049eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills    public List<String> anqpLines;
3059eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills
3069eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills    /**
3079eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills     *  @hide
308fc197d392300116b47c87dcc87453c3465ca6ce2Pierre Vandwalle     * storing the raw bytes of full result IEs
309fc197d392300116b47c87dcc87453c3465ca6ce2Pierre Vandwalle     **/
310fc197d392300116b47c87dcc87453c3465ca6ce2Pierre Vandwalle    public byte[] bytes;
311fc197d392300116b47c87dcc87453c3465ca6ce2Pierre Vandwalle
312a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande    /** information elements from beacon
31355027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande     * @hide
31455027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande     */
31555027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande    public static class InformationElement {
31621c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills        public static final int EID_SSID = 0;
317bff37ecdaa7c31b1c750ea78b3206bf5d8949eefGlen Kuhne        public static final int EID_SUPPORTED_RATES = 1;
318b6cd6fa5a7314047409823ba48ff9e124ff53a70Glen Kuhne        public static final int EID_TIM = 5;
31921c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills        public static final int EID_BSS_LOAD = 11;
320bff37ecdaa7c31b1c750ea78b3206bf5d8949eefGlen Kuhne        public static final int EID_ERP = 42;
321c0e86b2e90d46cfa51519e8e3d91aad18ffcdb09Randy Pan        public static final int EID_RSN = 48;
322bff37ecdaa7c31b1c750ea78b3206bf5d8949eefGlen Kuhne        public static final int EID_EXTENDED_SUPPORTED_RATES = 50;
32321c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills        public static final int EID_HT_OPERATION = 61;
32421c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills        public static final int EID_INTERWORKING = 107;
32521c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills        public static final int EID_ROAMING_CONSORTIUM = 111;
32621c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills        public static final int EID_EXTENDED_CAPS = 127;
32721c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills        public static final int EID_VHT_OPERATION = 192;
32821c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills        public static final int EID_VSA = 221;
32921c748d091f014a6733fa4c17df36ea4dc40564fMitchell Wills
33055027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande        public int id;
33155027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande        public byte[] bytes;
332ea676a0e51504aa53dff9cbe64085658987703b2Vinit Deshpande
333ea676a0e51504aa53dff9cbe64085658987703b2Vinit Deshpande        public InformationElement() {
334ea676a0e51504aa53dff9cbe64085658987703b2Vinit Deshpande        }
335ea676a0e51504aa53dff9cbe64085658987703b2Vinit Deshpande
336ea676a0e51504aa53dff9cbe64085658987703b2Vinit Deshpande        public InformationElement(InformationElement rhs) {
337ea676a0e51504aa53dff9cbe64085658987703b2Vinit Deshpande            this.id = rhs.id;
338ea676a0e51504aa53dff9cbe64085658987703b2Vinit Deshpande            this.bytes = rhs.bytes.clone();
339ea676a0e51504aa53dff9cbe64085658987703b2Vinit Deshpande        }
34055027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande    }
34155027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande
34255027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande    /** information elements found in the beacon
34355027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande     * @hide
34455027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande     */
345a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    public InformationElement[] informationElements;
346a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande
347a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    /** ANQP response elements.
348a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande     * @hide
349a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande     */
350a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    public AnqpInformationElement[] anqpElements;
35155027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande
352b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff    /** {@hide} */
353a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    public ScanResult(WifiSsid wifiSsid, String BSSID, long hessid, int anqpDomainId,
354a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            byte[] osuProviders, String caps, int level, int frequency, long tsf) {
355b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff        this.wifiSsid = wifiSsid;
356b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff        this.SSID = (wifiSsid != null) ? wifiSsid.toString() : WifiSsid.NONE;
3579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        this.BSSID = BSSID;
358a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        this.hessid = hessid;
359a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        this.anqpDomainId = anqpDomainId;
360a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        if (osuProviders != null) {
361a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            this.anqpElements = new AnqpInformationElement[1];
362a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            this.anqpElements[0] =
363a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                    new AnqpInformationElement(AnqpInformationElement.HOTSPOT20_VENDOR_ID,
364a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                            AnqpInformationElement.HS_OSU_PROVIDERS, osuProviders);
365a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        }
3669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        this.capabilities = caps;
3679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        this.level = level;
3689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        this.frequency = frequency;
36906c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev        this.timestamp = tsf;
3700451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.distanceCm = UNSPECIFIED;
3710451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.distanceSdCm = UNSPECIFIED;
3726e58424f5b052531a724a54629f00915ad3edadaxinhe        this.channelWidth = UNSPECIFIED;
3736e58424f5b052531a724a54629f00915ad3edadaxinhe        this.centerFreq0 = UNSPECIFIED;
3746e58424f5b052531a724a54629f00915ad3edadaxinhe        this.centerFreq1 = UNSPECIFIED;
375a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        this.flags = 0;
37606c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev    }
37706c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev
3780451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** {@hide} */
3790451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public ScanResult(WifiSsid wifiSsid, String BSSID, String caps, int level, int frequency,
3800451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            long tsf, int distCm, int distSdCm) {
3810451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.wifiSsid = wifiSsid;
3820451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.SSID = (wifiSsid != null) ? wifiSsid.toString() : WifiSsid.NONE;
3830451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.BSSID = BSSID;
3840451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.capabilities = caps;
3850451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.level = level;
3860451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.frequency = frequency;
3870451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.timestamp = tsf;
3880451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.distanceCm = distCm;
3890451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        this.distanceSdCm = distSdCm;
3906e58424f5b052531a724a54629f00915ad3edadaxinhe        this.channelWidth = UNSPECIFIED;
3916e58424f5b052531a724a54629f00915ad3edadaxinhe        this.centerFreq0 = UNSPECIFIED;
3926e58424f5b052531a724a54629f00915ad3edadaxinhe        this.centerFreq1 = UNSPECIFIED;
393a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        this.flags = 0;
3946e58424f5b052531a724a54629f00915ad3edadaxinhe    }
3956e58424f5b052531a724a54629f00915ad3edadaxinhe
3966e58424f5b052531a724a54629f00915ad3edadaxinhe    /** {@hide} */
397a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    public ScanResult(String Ssid, String BSSID, long hessid, int anqpDomainId, String caps,
398a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            int level, int frequency,
3996e58424f5b052531a724a54629f00915ad3edadaxinhe            long tsf, int distCm, int distSdCm, int channelWidth, int centerFreq0, int centerFreq1,
4006e58424f5b052531a724a54629f00915ad3edadaxinhe            boolean is80211McRTTResponder) {
401f2c01041fe1a5e8b51970774c4ac6f04eb5967f0xinhe        this.SSID = Ssid;
4026e58424f5b052531a724a54629f00915ad3edadaxinhe        this.BSSID = BSSID;
403a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        this.hessid = hessid;
404a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        this.anqpDomainId = anqpDomainId;
4056e58424f5b052531a724a54629f00915ad3edadaxinhe        this.capabilities = caps;
4066e58424f5b052531a724a54629f00915ad3edadaxinhe        this.level = level;
4076e58424f5b052531a724a54629f00915ad3edadaxinhe        this.frequency = frequency;
4086e58424f5b052531a724a54629f00915ad3edadaxinhe        this.timestamp = tsf;
4096e58424f5b052531a724a54629f00915ad3edadaxinhe        this.distanceCm = distCm;
4106e58424f5b052531a724a54629f00915ad3edadaxinhe        this.distanceSdCm = distSdCm;
4116e58424f5b052531a724a54629f00915ad3edadaxinhe        this.channelWidth = channelWidth;
4126e58424f5b052531a724a54629f00915ad3edadaxinhe        this.centerFreq0 = centerFreq0;
4136e58424f5b052531a724a54629f00915ad3edadaxinhe        this.centerFreq1 = centerFreq1;
414a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        if (is80211McRTTResponder) {
415a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande            this.flags = FLAG_80211mc_RESPONDER;
416a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        } else {
417a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande            this.flags = 0;
418a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        }
4190451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
420b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff
421f2c01041fe1a5e8b51970774c4ac6f04eb5967f0xinhe    /** {@hide} */
422a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande    public ScanResult(WifiSsid wifiSsid, String Ssid, String BSSID, long hessid, int anqpDomainId,
423a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                  String caps, int level,
424f2c01041fe1a5e8b51970774c4ac6f04eb5967f0xinhe                  int frequency, long tsf, int distCm, int distSdCm, int channelWidth,
425f2c01041fe1a5e8b51970774c4ac6f04eb5967f0xinhe                  int centerFreq0, int centerFreq1, boolean is80211McRTTResponder) {
426a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        this(Ssid, BSSID, hessid, anqpDomainId, caps, level, frequency, tsf, distCm,
427a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                distSdCm, channelWidth, centerFreq0, centerFreq1, is80211McRTTResponder);
428f2c01041fe1a5e8b51970774c4ac6f04eb5967f0xinhe        this.wifiSsid = wifiSsid;
429f2c01041fe1a5e8b51970774c4ac6f04eb5967f0xinhe    }
430f2c01041fe1a5e8b51970774c4ac6f04eb5967f0xinhe
43106c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev    /** copy constructor {@hide} */
43206c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev    public ScanResult(ScanResult source) {
43306c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev        if (source != null) {
434b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff            wifiSsid = source.wifiSsid;
43506c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            SSID = source.SSID;
43606c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            BSSID = source.BSSID;
437a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            hessid = source.hessid;
438a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            anqpDomainId = source.anqpDomainId;
439a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            informationElements = source.informationElements;
440a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            anqpElements = source.anqpElements;
44106c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            capabilities = source.capabilities;
44206c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            level = source.level;
44306c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            frequency = source.frequency;
4446e58424f5b052531a724a54629f00915ad3edadaxinhe            channelWidth = source.channelWidth;
4456e58424f5b052531a724a54629f00915ad3edadaxinhe            centerFreq0 = source.centerFreq0;
4466e58424f5b052531a724a54629f00915ad3edadaxinhe            centerFreq1 = source.centerFreq1;
44706c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            timestamp = source.timestamp;
4480451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            distanceCm = source.distanceCm;
4490451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            distanceSdCm = source.distanceSdCm;
4507c3606c103e95d3991267cca2592402a68779cafvandwalle            seen = source.seen;
4514eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle            untrusted = source.untrusted;
4524eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle            numConnection = source.numConnection;
4534eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle            numUsage = source.numUsage;
454176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle            numIpConfigFailures = source.numIpConfigFailures;
45563edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle            isAutoJoinCandidate = source.isAutoJoinCandidate;
4562522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande            venueName = source.venueName;
4572522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande            operatorFriendlyName = source.operatorFriendlyName;
458a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande            flags = source.flags;
45906c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev        }
4609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
462011e1b35a64180d6f0234af8a3c2b70777eb9f39Vinit Deshapnde    /** empty scan result
463011e1b35a64180d6f0234af8a3c2b70777eb9f39Vinit Deshapnde     *
464011e1b35a64180d6f0234af8a3c2b70777eb9f39Vinit Deshapnde     * {@hide}
465011e1b35a64180d6f0234af8a3c2b70777eb9f39Vinit Deshapnde     * */
466011e1b35a64180d6f0234af8a3c2b70777eb9f39Vinit Deshapnde    public ScanResult() {
467011e1b35a64180d6f0234af8a3c2b70777eb9f39Vinit Deshapnde    }
468011e1b35a64180d6f0234af8a3c2b70777eb9f39Vinit Deshapnde
4699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    @Override
4709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public String toString() {
4719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        StringBuffer sb = new StringBuffer();
4729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        String none = "<none>";
4739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        sb.append("SSID: ").
475b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff            append(wifiSsid == null ? WifiSsid.NONE : wifiSsid).
4769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            append(", BSSID: ").
4779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            append(BSSID == null ? none : BSSID).
4789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            append(", capabilities: ").
4799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            append(capabilities == null ? none : capabilities).
4809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            append(", level: ").
4819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            append(level).
4829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            append(", frequency: ").
48306c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            append(frequency).
48406c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            append(", timestamp: ").
48506c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev            append(timestamp);
4869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4870451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        sb.append(", distance: ").append((distanceCm != UNSPECIFIED ? distanceCm : "?")).
4880451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append("(cm)");
4890451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        sb.append(", distanceSd: ").append((distanceSdCm != UNSPECIFIED ? distanceSdCm : "?")).
4900451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append("(cm)");
4910451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
492a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        sb.append(", passpoint: ");
493a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        sb.append(((flags & FLAG_PASSPOINT_NETWORK) != 0) ? "yes" : "no");
4946e58424f5b052531a724a54629f00915ad3edadaxinhe        sb.append(", ChannelBandwidth: ").append(channelWidth);
4956e58424f5b052531a724a54629f00915ad3edadaxinhe        sb.append(", centerFreq0: ").append(centerFreq0);
4966e58424f5b052531a724a54629f00915ad3edadaxinhe        sb.append(", centerFreq1: ").append(centerFreq1);
497a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        sb.append(", 80211mcResponder: ");
498a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        sb.append(((flags & FLAG_80211mc_RESPONDER) != 0) ? "is supported" : "is not supported");
4999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return sb.toString();
5009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
5019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
5029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /** Implement the Parcelable interface {@hide} */
5039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public int describeContents() {
5049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return 0;
5059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
5069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
5079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /** Implement the Parcelable interface {@hide} */
5089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void writeToParcel(Parcel dest, int flags) {
509b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff        if (wifiSsid != null) {
510b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff            dest.writeInt(1);
511b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff            wifiSsid.writeToParcel(dest, flags);
512b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff        } else {
513b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff            dest.writeInt(0);
514b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff        }
515f2c01041fe1a5e8b51970774c4ac6f04eb5967f0xinhe        dest.writeString(SSID);
5169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        dest.writeString(BSSID);
517a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        dest.writeLong(hessid);
518a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        dest.writeInt(anqpDomainId);
5199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        dest.writeString(capabilities);
5209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        dest.writeInt(level);
5219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        dest.writeInt(frequency);
52206c43d575c88976f8709ff3fc0bad7117bde23e7Iliyan Malchev        dest.writeLong(timestamp);
5230451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(distanceCm);
5240451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(distanceSdCm);
5256e58424f5b052531a724a54629f00915ad3edadaxinhe        dest.writeInt(channelWidth);
5266e58424f5b052531a724a54629f00915ad3edadaxinhe        dest.writeInt(centerFreq0);
5276e58424f5b052531a724a54629f00915ad3edadaxinhe        dest.writeInt(centerFreq1);
5285fb7bf5fdb93831684b00eb637ec15b5cf0d1e2dvandwalle        dest.writeLong(seen);
5294eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        dest.writeInt(untrusted ? 1 : 0);
5304eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        dest.writeInt(numConnection);
5314eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle        dest.writeInt(numUsage);
532176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle        dest.writeInt(numIpConfigFailures);
53363edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle        dest.writeInt(isAutoJoinCandidate);
534a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        dest.writeString((venueName != null) ? venueName.toString() : "");
535a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        dest.writeString((operatorFriendlyName != null) ? operatorFriendlyName.toString() : "");
536a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande        dest.writeLong(this.flags);
5372522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande
53855027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande        if (informationElements != null) {
53955027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande            dest.writeInt(informationElements.length);
54055027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande            for (int i = 0; i < informationElements.length; i++) {
54155027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                dest.writeInt(informationElements[i].id);
54255027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                dest.writeInt(informationElements[i].bytes.length);
54355027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                dest.writeByteArray(informationElements[i].bytes);
54455027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande            }
54555027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande        } else {
54655027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande            dest.writeInt(0);
54755027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande        }
5489eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills
5499eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills        if (anqpLines != null) {
5509eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills            dest.writeInt(anqpLines.size());
5519eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills            for (int i = 0; i < anqpLines.size(); i++) {
5529eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills                dest.writeString(anqpLines.get(i));
5539eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills            }
554a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        }
5557a504417f23a1388d2a9bf53f0871d274e70c6b2Jan Nordqvist        else {
5567a504417f23a1388d2a9bf53f0871d274e70c6b2Jan Nordqvist            dest.writeInt(0);
5577a504417f23a1388d2a9bf53f0871d274e70c6b2Jan Nordqvist        }
558a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande        if (anqpElements != null) {
559a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            dest.writeInt(anqpElements.length);
560a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            for (AnqpInformationElement element : anqpElements) {
561a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                dest.writeInt(element.getVendorId());
562a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                dest.writeInt(element.getElementId());
563a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                dest.writeInt(element.getPayload().length);
564a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                dest.writeByteArray(element.getPayload());
565a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande            }
5669eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills        } else {
5679eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills            dest.writeInt(0);
5689eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills        }
5699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
5709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
5719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /** Implement the Parcelable interface {@hide} */
5729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final Creator<ScanResult> CREATOR =
5739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        new Creator<ScanResult>() {
5749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            public ScanResult createFromParcel(Parcel in) {
575b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff                WifiSsid wifiSsid = null;
576b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff                if (in.readInt() == 1) {
577b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff                    wifiSsid = WifiSsid.CREATOR.createFromParcel(in);
578b6deeed3ceff9e0f754697987b7c724901996082Irfan Sheriff                }
579a4864472313208e4f1de02f45d3eadad237c54afYuhao Zheng                ScanResult sr = new ScanResult(
580a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        wifiSsid,
581a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readString(),                    /* SSID  */
582a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readString(),                    /* BSSID */
583a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readLong(),                      /* HESSID */
584a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readInt(),                       /* ANQP Domain ID */
585a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readString(),                    /* capabilities */
586a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readInt(),                       /* level */
587a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readInt(),                       /* frequency */
588a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readLong(),                      /* timestamp */
589a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readInt(),                       /* distanceCm */
590a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readInt(),                       /* distanceSdCm */
591a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readInt(),                       /* channelWidth */
592a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readInt(),                       /* centerFreq0 */
593a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readInt(),                       /* centerFreq1 */
594a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        false                               /* rtt responder,
595a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                                                               fixed with flags below */
5969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                );
597a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande
5985fb7bf5fdb93831684b00eb637ec15b5cf0d1e2dvandwalle                sr.seen = in.readLong();
5994eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle                sr.untrusted = in.readInt() != 0;
6004eeecb25509f91ac7a6e2cde76dac782fbec5360vandwalle                sr.numConnection = in.readInt();
601b1dce0220bec5d81dca0aac645d84854ef4324cbvandwalle                sr.numUsage = in.readInt();
602176a27f3abf18af18a1ad4012ca3eadbff12ba96vandwalle                sr.numIpConfigFailures = in.readInt();
60363edd98d2eb744cc78dc3a3f8ec1ce7e6164d69dvandwalle                sr.isAutoJoinCandidate = in.readInt();
6042522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande                sr.venueName = in.readString();
6052522c830a3ad3ae2ca7f675f13fafab8835d4f0cVinit Deshpande                sr.operatorFriendlyName = in.readString();
606a0d929e505432a8c84f3899696c910db16bd73bfVinit Deshpande                sr.flags = in.readLong();
60755027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                int n = in.readInt();
60855027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                if (n != 0) {
60955027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                    sr.informationElements = new InformationElement[n];
61055027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                    for (int i = 0; i < n; i++) {
61155027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                        sr.informationElements[i] = new InformationElement();
61255027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                        sr.informationElements[i].id = in.readInt();
61355027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                        int len = in.readInt();
61455027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                        sr.informationElements[i].bytes = new byte[len];
61555027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                        in.readByteArray(sr.informationElements[i].bytes);
61655027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                    }
61755027bb7b87ddcb05d65892677a2e0fe42f66ba2Vinit Deshpande                }
6189eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills
6199eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills                n = in.readInt();
6209eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills                if (n != 0) {
6219eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills                    sr.anqpLines = new ArrayList<String>();
6229eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills                    for (int i = 0; i < n; i++) {
6239eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills                        sr.anqpLines.add(in.readString());
6249eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills                    }
6259eeba37851ef432cca7e35675a6b64b2b83b802cMitchell Wills                }
626a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                n = in.readInt();
627a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                if (n != 0) {
628a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                    sr.anqpElements = new AnqpInformationElement[n];
629a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                    for (int i = 0; i < n; i++) {
630a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        int vendorId = in.readInt();
631a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        int elementId = in.readInt();
632a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        int len = in.readInt();
633a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        byte[] payload = new byte[len];
634a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                        in.readByteArray(payload);
6357a504417f23a1388d2a9bf53f0871d274e70c6b2Jan Nordqvist                        sr.anqpElements[i] =
636a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                                new AnqpInformationElement(vendorId, elementId, payload);
637a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                    }
638a772f0cf34f0db67997cb31fa44315c0933563daVinit Deshpande                }
639a4864472313208e4f1de02f45d3eadad237c54afYuhao Zheng                return sr;
6409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
6419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
6429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            public ScanResult[] newArray(int size) {
6439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                return new ScanResult[size];
6449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            }
6459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        };
6469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
647