WifiNative.java revision 3e240b2bfb6fefe8b91ad68e8a12b652b4136c69
1155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande/*
2155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Copyright (C) 2008 The Android Open Source Project
3155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *
4155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Licensed under the Apache License, Version 2.0 (the "License");
5155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * you may not use this file except in compliance with the License.
6155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * You may obtain a copy of the License at
7155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *
8155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *      http://www.apache.org/licenses/LICENSE-2.0
9155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *
10155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Unless required by applicable law or agreed to in writing, software
11155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * distributed under the License is distributed on an "AS IS" BASIS,
12155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * See the License for the specific language governing permissions and
14155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * limitations under the License.
15155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */
16155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
17155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandepackage com.android.server.wifi;
18155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
1968cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wangimport android.annotation.Nullable;
20e1dab7a2e3ab5911f812a302b4beed1f6eb5aba7Paul Jensenimport android.net.apf.ApfCapabilities;
2170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wangimport android.net.wifi.IApInterface;
2270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wangimport android.net.wifi.IClientInterface;
23143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpandeimport android.net.wifi.RttManager;
2468cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wangimport android.net.wifi.RttManager.ResponderConfig;
25e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapndeimport android.net.wifi.ScanResult;
26dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalleimport android.net.wifi.WifiConfiguration;
27aabe7a9f2f32915fd1f25416a6d2034a844005d6vandwalleimport android.net.wifi.WifiLinkLayerStats;
28e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapndeimport android.net.wifi.WifiScanner;
292a6d76f0899289cd3b96e3428f02076fdbc0363eMitchell Willsimport android.net.wifi.WifiWakeReasonAndCounts;
30155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.net.wifi.p2p.WifiP2pConfig;
31155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.net.wifi.p2p.WifiP2pGroup;
32782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowskiimport android.net.wifi.p2p.WifiP2pGroupList;
3303cdd624f5da6d62cb731304aa7505921566f69dDmitry Shmidtimport android.net.wifi.p2p.nsd.WifiP2pServiceInfo;
34f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalleimport android.os.SystemClock;
35155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.util.Log;
36a26a8b33616c94859ba33f33403794cf636baa54Roshan Piusimport android.util.SparseArray;
37fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski
3809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawalimport com.android.internal.annotations.Immutable;
390fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport com.android.internal.util.HexDump;
40c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadhamimport com.android.server.connectivity.KeepalivePacketData;
41590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tanimport com.android.server.wifi.util.FrameParser;
42fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski
430fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport java.io.PrintWriter;
440fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport java.io.StringWriter;
455cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.ByteBuffer;
465cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.CharBuffer;
475cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.CharacterCodingException;
485cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.CharsetDecoder;
495cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.StandardCharsets;
50eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.text.SimpleDateFormat;
51155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport java.util.ArrayList;
52eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.util.Date;
53fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowskiimport java.util.Map;
541bf983a4211f547593a60523e43112ecdb5c8997Roshan Piusimport java.util.Objects;
559ec71f6499e0e3d6f52310a41ff4a59d2fa4f8b2Mitchell Willsimport java.util.Set;
56eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.util.TimeZone;
5718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills
58fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski
59155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande/**
60155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Native calls for bring up/shut down of the supplicant daemon and for
61155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * sending requests to the supplicant daemon
62155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande *
63155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * {@hide}
64155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */
65155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandepublic class WifiNative {
6618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    private final String mTAG;
6718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    private final String mInterfaceName;
68b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    private final SupplicantStaIfaceHal mSupplicantStaIfaceHal;
69b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    private final SupplicantP2pIfaceHal mSupplicantP2pIfaceHal;
70b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    private final WifiVendorHal mWifiVendorHal;
71b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    private final WificondControl mWificondControl;
72b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius
73b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public WifiNative(String interfaceName, WifiVendorHal vendorHal,
74b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                      SupplicantStaIfaceHal staIfaceHal, SupplicantP2pIfaceHal p2pIfaceHal,
75b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                      WificondControl condControl) {
76155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        mTAG = "WifiNative-" + interfaceName;
77b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mInterfaceName = interfaceName;
78b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mWifiVendorHal = vendorHal;
79b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mSupplicantStaIfaceHal = staIfaceHal;
80b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mSupplicantP2pIfaceHal = p2pIfaceHal;
81b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mWificondControl = condControl;
82155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
83155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
8418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public String getInterfaceName() {
8518786eca942042388748b0d98979f21c9dff4a89Mitchell Wills        return mInterfaceName;
86e26ad459b63271548abbdeba4f8d77fcca9f88bdxinhe    }
87e26ad459b63271548abbdeba4f8d77fcca9f88bdxinhe
88b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
89b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Enable verbose logging for all sub modules.
90b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
91b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public void enableVerboseLogging(int verbose) {
92b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mWificondControl.enableVerboseLogging(verbose > 0 ? true : false);
93b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mSupplicantStaIfaceHal.enableVerboseLogging(verbose > 0);
94b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mWifiVendorHal.enableVerboseLogging(verbose > 0);
95ed9938883ae2dade81c8be6cd6ceaef3febd5239vandwalle    }
96ed9938883ae2dade81c8be6cd6ceaef3febd5239vandwalle
97b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius   /********************************************************
98b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    * Native Initialization/Deinitialization
99b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    ********************************************************/
100155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
10170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang   /**
1023a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    * Setup wifi native for Client mode operations.
1033a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    *
1043a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    * 1. Starts the Wifi HAL and configures it in client/STA mode.
1053a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    * 2. Setup Wificond to operate in client mode and retrieve the handle to use for client
1063a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    * operations.
1073a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    *
10870603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    * @return An IClientInterface as wificond client interface binder handler.
10970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    * Returns null on failure.
11070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    */
1113a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    public IClientInterface setupForClientMode() {
11270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang        if (!startHal(true)) {
11370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang            // TODO(b/34859006): Handle failures.
114b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            Log.e(mTAG, "Failed to start HAL for client mode");
11570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang        }
1163a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius        return mWificondControl.setupDriverForClientMode();
11770603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    }
118155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
11970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    /**
1203a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * Setup wifi native for AP mode operations.
1213a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     *
1223a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * 1. Starts the Wifi HAL and configures it in AP mode.
1233a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * 2. Setup Wificond to operate in AP mode and retrieve the handle to use for ap operations.
1243a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     *
1253a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * @return An IApInterface as wificond Ap interface binder handler.
1263a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * Returns null on failure.
1273a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     */
1283a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    public IApInterface setupForSoftApMode() {
12970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang        if (!startHal(false)) {
13070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang            // TODO(b/34859006): Handle failures.
131b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            Log.e(mTAG, "Failed to start HAL for AP mode");
13270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang        }
1333a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius        return mWificondControl.setupDriverForSoftApMode();
13470603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    }
13570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang
13670603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    /**
1373a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * Teardown all mode configurations in wifi native.
1383a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     *
1393a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * 1. Tears down all the interfaces from Wificond.
1403a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * 2. Stops the Wifi HAL.
1413a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     *
1423a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     * @return Returns true on success.
1433a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius     */
1443a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius    public boolean tearDown() {
1453a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius        if (!mWificondControl.tearDownInterfaces()) {
1463a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius            // TODO(b/34859006): Handle failures.
147b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            Log.e(mTAG, "Failed to teardown interfaces from Wificond");
1483a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius            return false;
1493a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius        }
1503a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius        stopHal();
1513a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius        return true;
15270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    }
15370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang
154b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /********************************************************
155b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Wificond operations
156b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     ********************************************************/
157b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
158b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Result of a signal poll.
159b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
160b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public static class SignalPollResult {
161b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // RSSI value in dBM.
162b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        public int currentRssi;
163b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        //Transmission bit rate in Mbps.
164b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        public int txBitrate;
165b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Association frequency in MHz.
166b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        public int associationFrequency;
167b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    }
168b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius
169b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
170b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * WiFi interface transimission counters.
171b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
172b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public static class TxPacketCounters {
173b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Number of successfully transmitted packets.
174b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        public int txSucceeded;
175b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Number of tramsmission failures.
176b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        public int txFailed;
177b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    }
178b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius
17970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    /**
18070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    * Disable wpa_supplicant via wificond.
18170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    * @return Returns true on success.
18270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    */
18370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    public boolean disableSupplicant() {
18470603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang        return mWificondControl.disableSupplicant();
18570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    }
18670603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang
18770603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    /**
18870603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    * Enable wpa_supplicant via wificond.
18970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    * @return Returns true on success.
19070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    */
19170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    public boolean enableSupplicant() {
19270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang        return mWificondControl.enableSupplicant();
19370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang    }
19418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills
195d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    /**
196d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    * Request signal polling to wificond.
197d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    * Returns an SignalPollResult object.
198d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    * Returns null on failure.
199d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    */
200d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    public SignalPollResult signalPoll() {
201d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang        return mWificondControl.signalPoll();
202d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    }
203d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang
204d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    /**
205d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang     * Fetch TX packet counters on current connection from wificond.
206d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    * Returns an TxPacketCounters object.
207d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    * Returns null on failure.
208d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    */
209d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    public TxPacketCounters getTxPacketCounters() {
210d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang        return mWificondControl.getTxPacketCounters();
211d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang    }
212d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang
21324250365afbd9a20b2e03364eddf2025c8f1138aRoshan Pius    /**
214b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start a scan using wificond for the given parameters.
215b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param freqs list of frequencies to scan for, if null scan all supported channels.
216b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param hiddenNetworkSSIDs List of hidden networks to be scanned for.
217b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return Returns true on success.
21824250365afbd9a20b2e03364eddf2025c8f1138aRoshan Pius     */
219b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean scan(Set<Integer> freqs, Set<String> hiddenNetworkSSIDs) {
220b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWificondControl.scan(freqs, hiddenNetworkSSIDs);
221155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
222155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
22318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    /**
224b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Fetch the latest scan result from kernel via wificond.
225b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return Returns an ArrayList of ScanDetail.
226b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Returns an empty ArrayList on failure.
22718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills     */
228b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public ArrayList<ScanDetail> getScanResults() {
229b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWificondControl.getScanResults();
230155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
231155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
232b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
233b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start PNO scan.
234b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param pnoSettings Pno scan configuration.
235b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success.
23618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills     */
237b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean startPnoScan(PnoSettings pnoSettings) {
238b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWificondControl.startPnoScan(pnoSettings);
239155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
240155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
241b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
242b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Stop PNO scan.
243b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success.
244b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
245b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean stopPnoScan() {
246b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWificondControl.stopPnoScan();
24718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    }
24818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills
249b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /********************************************************
250b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Supplicant operations
251b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     ********************************************************/
252f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius
253f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius    /**
254b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This method is called repeatedly until the connection to wpa_supplicant is established.
255f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius     *
256b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if connection is established, false otherwise.
257b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * TODO: Add unit tests for these once we remove the legacy code.
258f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius     */
259b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean connectToStaSupplicant() {
260b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Start initialization if not already started.
261b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        if (!mSupplicantStaIfaceHal.isInitializationStarted()
262b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && !mSupplicantStaIfaceHal.initialize()) {
263b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            return false;
2645cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius        }
265b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Check if the initialization is complete.
266b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.isInitializationComplete();
267ad7319939c424d42fa6a3791c47f613db8ef3cd8vandwalle    }
268ad7319939c424d42fa6a3791c47f613db8ef3cd8vandwalle
269b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
270b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This method is called repeatedly until the connection to wpa_supplicant is established.
271b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
272b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if connection is established, false otherwise.
273b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * TODO: Add unit tests for these once we remove the legacy code.
2746259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius     */
275b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean connectToP2pSupplicant() {
276b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Start initialization if not already started.
277b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        if (!mSupplicantP2pIfaceHal.isInitializationStarted()
278b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && !mSupplicantP2pIfaceHal.initialize()) {
279b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            return false;
2806259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius        }
281b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Check if the initialization is complete.
282b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.isInitializationComplete();
2836259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius    }
2846259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius
2853d995b8a3a508e957e3dac2e508956020cd9abfeRoshan Pius    /**
286b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Close supplicant connection.
287ed6a985c7b63e295248fa7e8292c99b48b7a4283Mitchell Wills     */
288b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public void closeSupplicantConnection() {
289b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Nothing to do for HIDL.
290155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
291155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
292782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski    /**
293b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set supplicant log level
294782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski     *
295b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param turnOnVerbose Whether to turn on verbose logging or not.
296782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski     */
297b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public void setSupplicantLogLevel(boolean turnOnVerbose) {
298b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        int logLevel = turnOnVerbose
299b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                ? SupplicantStaIfaceHal.LOG_LEVEL_DEBUG
300b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                : SupplicantStaIfaceHal.LOG_LEVEL_INFO;
301b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mSupplicantStaIfaceHal.setLogLevel(logLevel);
302e3831b70d4a8a967fe8df5496d542a432692c434Roshan Pius    }
303e3831b70d4a8a967fe8df5496d542a432692c434Roshan Pius
30438a6c1ba5d461b8c7b11685c5dd2e98d9e106b55Roshan Pius    /**
305b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Trigger a reconnection if the iface is disconnected.
306b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
307b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
30838a6c1ba5d461b8c7b11685c5dd2e98d9e106b55Roshan Pius     */
309b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean reconnect() {
310b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.reconnect();
311f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle    }
3129d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius
3139d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius    /**
314b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Trigger a reassociation even if the iface is currently connected.
315b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
316b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
3179d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius     */
318155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean reassociate() {
319b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.reassociate();
320155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
321155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
322155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /**
323b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Trigger a disconnection from the currently connected network.
324b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
325b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
326b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
327b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean disconnect() {
328b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.disconnect();
32977f2b82a2e80af8da52c22d69a76def6d4209757Jan Nordqvist    }
33077f2b82a2e80af8da52c22d69a76def6d4209757Jan Nordqvist
331155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /**
332b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Makes a callback to HIDL to getMacAddress from supplicant
333b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
334b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return string containing the MAC address, or null on a failed call
335b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
336b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String getMacAddress() {
337b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.getMacAddress();
338446db2d5457456743e4476029e14d7c3bb9f5bccYuhao Zheng    }
339446db2d5457456743e4476029e14d7c3bb9f5bccYuhao Zheng
340155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /**
341155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * Start filtering out Multicast V4 packets
342155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * @return {@code true} if the operation succeeded, {@code false} otherwise
343155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *
344155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * Multicast filtering rules work as follows:
345155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *
346155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * The driver can filter multicast (v4 and/or v6) and broadcast packets when in
347155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * a power optimized mode (typically when screen goes off).
348155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *
349155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * In order to prevent the driver from filtering the multicast/broadcast packets, we have to
350155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * add a DRIVER RXFILTER-ADD rule followed by DRIVER RXFILTER-START to make the rule effective
351155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *
352155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * DRIVER RXFILTER-ADD Num
353155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *   where Num = 0 - Unicast, 1 - Broadcast, 2 - Mutil4 or 3 - Multi6
354155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *
355155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * and DRIVER RXFILTER-START
356155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * In order to stop the usage of these rules, we do
357155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *
358155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * DRIVER RXFILTER-STOP
359155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * DRIVER RXFILTER-REMOVE Num
360155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *   where Num is as described for RXFILTER-ADD
361155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *
362155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * The  SETSUSPENDOPT driver command overrides the filtering rules
363155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     */
364155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean startFilteringMulticastV4Packets() {
365b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.stopRxFilter()
366b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && mSupplicantStaIfaceHal.removeRxFilter(
367b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                SupplicantStaIfaceHal.RX_FILTER_TYPE_V4_MULTICAST)
368b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && mSupplicantStaIfaceHal.startRxFilter();
369155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
370155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
371155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /**
372155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * Stop filtering out Multicast V4 packets.
373155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * @return {@code true} if the operation succeeded, {@code false} otherwise
374155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     */
375155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean stopFilteringMulticastV4Packets() {
376b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.stopRxFilter()
377b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && mSupplicantStaIfaceHal.addRxFilter(
378b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                SupplicantStaIfaceHal.RX_FILTER_TYPE_V4_MULTICAST)
379b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && mSupplicantStaIfaceHal.startRxFilter();
380155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
381155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
382155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /**
383155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * Start filtering out Multicast V6 packets
384155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * @return {@code true} if the operation succeeded, {@code false} otherwise
385155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     */
386155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean startFilteringMulticastV6Packets() {
387b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.stopRxFilter()
388b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && mSupplicantStaIfaceHal.removeRxFilter(
389b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                SupplicantStaIfaceHal.RX_FILTER_TYPE_V6_MULTICAST)
390b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && mSupplicantStaIfaceHal.startRxFilter();
391155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
392155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
393155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /**
394155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * Stop filtering out Multicast V6 packets.
395155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * @return {@code true} if the operation succeeded, {@code false} otherwise
396155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     */
397155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean stopFilteringMulticastV6Packets() {
398b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.stopRxFilter()
399b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && mSupplicantStaIfaceHal.addRxFilter(
400b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                SupplicantStaIfaceHal.RX_FILTER_TYPE_V6_MULTICAST)
401b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && mSupplicantStaIfaceHal.startRxFilter();
402155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
403155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
404b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public static final int BLUETOOTH_COEXISTENCE_MODE_ENABLED  =
405b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            SupplicantStaIfaceHal.BT_COEX_MODE_ENABLED;
406b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public static final int BLUETOOTH_COEXISTENCE_MODE_DISABLED =
407b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            SupplicantStaIfaceHal.BT_COEX_MODE_DISABLED;
408b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public static final int BLUETOOTH_COEXISTENCE_MODE_SENSE    =
409b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            SupplicantStaIfaceHal.BT_COEX_MODE_SENSE;
4107ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde    /**
4117ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde      * Sets the bluetooth coexistence mode.
4127ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde      *
4137ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde      * @param mode One of {@link #BLUETOOTH_COEXISTENCE_MODE_DISABLED},
4147ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde      *            {@link #BLUETOOTH_COEXISTENCE_MODE_ENABLED}, or
4157ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde      *            {@link #BLUETOOTH_COEXISTENCE_MODE_SENSE}.
4167ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde      * @return Whether the mode was successfully set.
4177ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde      */
418155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setBluetoothCoexistenceMode(int mode) {
419b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setBtCoexistenceMode((byte) mode);
420155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
421155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
422155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /**
423155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * Enable or disable Bluetooth coexistence scan mode. When this mode is on,
424155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * some of the low-level scan parameters used by the driver are changed to
425155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * reduce interference with A2DP streaming.
426155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     *
427cc180872c51908b15ce5cbf834634ff323e036bcChristopher Wiley     * @param setCoexScanMode whether to enable or disable this mode
428155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     * @return {@code true} if the command succeeded, {@code false} otherwise.
429155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     */
430155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setBluetoothCoexistenceScanMode(boolean setCoexScanMode) {
431b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setBtCoexistenceScanModeEnabled(setCoexScanMode);
432155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
433155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
434b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
435b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Enable or disable suspend mode optimizations.
436b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
437b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param enabled true to enable, false otherwise.
438b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
439b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
440155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setSuspendOptimizations(boolean enabled) {
441b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setSuspendModeEnabled(enabled);
442155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
443155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
4449153bd67d51b305ffdd61355e0748e3c332c2cafRoshan Pius    /**
445b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set country code.
446b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
447b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param countryCode 2 byte ASCII string. For ex: US, CA.
448b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
4499153bd67d51b305ffdd61355e0748e3c332c2cafRoshan Pius     */
450b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setCountryCode(String countryCode) {
451b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setCountryCode(countryCode);
45204c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang    }
45304c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang
45404c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang    /**
455b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Initiate TDLS discover and setup or teardown with the specified peer.
456b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
457b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param macAddr MAC Address of the peer.
458b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param enable true to start discovery and setup, false to teardown.
45904c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang     */
460155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public void startTdls(String macAddr, boolean enable) {
461b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        if (enable) {
462b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            mSupplicantStaIfaceHal.initiateTdlsDiscover(macAddr);
463b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            mSupplicantStaIfaceHal.initiateTdlsSetup(macAddr);
464155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        } else {
465b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            mSupplicantStaIfaceHal.initiateTdlsTeardown(macAddr);
466155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
467155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
468155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
469b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
470b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start WPS pin display operation with the specified peer.
471b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
472b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param bssid BSSID of the peer.
473b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
474b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
475155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean startWpsPbc(String bssid) {
476b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.startWpsPbc(bssid);
477155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
478155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
479b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
480b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start WPS pin keypad operation with the specified pin.
481b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
482b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param pin Pin to be used.
483b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
484b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
485155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean startWpsPinKeypad(String pin) {
486b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.startWpsPinKeypad(pin);
487155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
488155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
489b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
490b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start WPS pin display operation with the specified peer.
491b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
492b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param bssid BSSID of the peer.
493b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return new pin generated on success, null otherwise.
494b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
495155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public String startWpsPinDisplay(String bssid) {
496b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.startWpsPinDisplay(bssid);
497155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
498155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
499b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
500b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Sets whether to use external sim for SIM/USIM processing.
501b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
502b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param external true to enable, false otherwise.
503b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
504b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
50533b575ca6bee66183929f9474b5a161432918604Vinit Deshpande    public boolean setExternalSim(boolean external) {
506b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setExternalSim(external);
50733b575ca6bee66183929f9474b5a161432918604Vinit Deshpande    }
50833b575ca6bee66183929f9474b5a161432918604Vinit Deshpande
509b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
510b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Sim auth response types.
511b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
512b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public static final String SIM_AUTH_RESP_TYPE_GSM_AUTH = "GSM-AUTH";
513b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public static final String SIM_AUTH_RESP_TYPE_UMTS_AUTH = "UMTS-AUTH";
514b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public static final String SIM_AUTH_RESP_TYPE_UMTS_AUTS = "UMTS-AUTS";
515b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius
516b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
517b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Send the sim auth response for the currently configured network.
518b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
519b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param type |GSM-AUTH|, |UMTS-AUTH| or |UMTS-AUTS|.
520b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param response Response params.
521b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if succeeds, false otherwise.
522b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
523f97140d51d14ce0659d381f443c08dbd94dfea28Honore Tricot    public boolean simAuthResponse(int id, String type, String response) {
524b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        if (SIM_AUTH_RESP_TYPE_GSM_AUTH.equals(type)) {
525b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimGsmAuthResponse(response);
526b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        } else if (SIM_AUTH_RESP_TYPE_UMTS_AUTH.equals(type)) {
527b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAuthResponse(response);
528b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        } else if (SIM_AUTH_RESP_TYPE_UMTS_AUTS.equals(type)) {
529b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAutsResponse(response);
5305cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius        } else {
531b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            return false;
5325cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius        }
53333b575ca6bee66183929f9474b5a161432918604Vinit Deshpande    }
53433b575ca6bee66183929f9474b5a161432918604Vinit Deshpande
535b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
536b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Send the eap sim gsm auth failure for the currently configured network.
537b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
538b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if succeeds, false otherwise.
539b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
54026eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande    public boolean simAuthFailedResponse(int id) {
541b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimGsmAuthFailure();
54226eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande    }
54326eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande
544b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
545b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Send the eap sim umts auth failure for the currently configured network.
546b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
547b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if succeeds, false otherwise.
548b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
54926eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande    public boolean umtsAuthFailedResponse(int id) {
550b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAuthFailure();
55126eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande    }
55226eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande
553b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
554b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Send the eap identity response for the currently configured network.
555b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
556b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param response String to send.
557b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if succeeds, false otherwise.
558b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
559ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot    public boolean simIdentityResponse(int id, String response) {
560b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.sendCurrentNetworkEapIdentityResponse(response);
561ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot    }
562ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot
563b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
564b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start WPS pin registrar operation with the specified peer and pin.
565b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
566b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param bssid BSSID of the peer.
567b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param pin Pin to be used.
568b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
569b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
570155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean startWpsRegistrar(String bssid, String pin) {
571b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.startWpsRegistrar(bssid, pin);
572155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
573155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
574b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
575b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Cancels any ongoing WPS requests.
576b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
577b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
578b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
579155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean cancelWps() {
580b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.cancelWps();
581155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
582155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
583b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
584b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS device name.
585b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
586b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param name String to be set.
587b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
588b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
589155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setDeviceName(String name) {
590b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setWpsDeviceName(name);
591155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
592155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
593b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
594b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS device type.
595b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
596b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param type Type specified as a string. Used format: <categ>-<OUI>-<subcateg>
597b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
598b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
599155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setDeviceType(String type) {
600b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setWpsDeviceType(type);
601155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
602155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
603b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
604b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS config methods
605b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
606b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param cfg List of config methods.
607b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
608b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
609155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setConfigMethods(String cfg) {
610b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setWpsConfigMethods(cfg);
611155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
612155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
613b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
614b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS manufacturer.
615b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
616b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param value String to be set.
617b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
618b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
619155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setManufacturer(String value) {
620b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setWpsManufacturer(value);
621155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
622155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
623b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
624b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS model name.
625b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
626b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param value String to be set.
627b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
628b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
629155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setModelName(String value) {
630b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setWpsModelName(value);
631155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
632155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
633b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
634b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS model number.
635b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
636b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param value String to be set.
637b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
638b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
639155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setModelNumber(String value) {
640b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setWpsModelNumber(value);
641155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
642155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
643b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
644b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS serial number.
645b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
646b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param value String to be set.
647b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
648b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
649155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public boolean setSerialNumber(String value) {
650b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setWpsSerialNumber(value);
651155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
652155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
653b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
654b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Enable or disable power save mode.
655b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
656b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param enabled true to enable, false to disable.
657b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
658155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    public void setPowerSave(boolean enabled) {
659b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mSupplicantStaIfaceHal.setPowerSave(enabled);
660155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
661155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
662b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
663b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set concurrency priority between P2P & STA operations.
664b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
665b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param isStaHigherPriority Set to true to prefer STA over P2P during concurrency operations,
666b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *                            false otherwise.
667b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
668b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
669b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setConcurrencyPriority(boolean isStaHigherPriority) {
670b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setConcurrencyPriority(isStaHigherPriority);
671155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
672155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
673155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    /**
6743e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius     * Enable/Disable auto reconnect functionality in wpa_supplicant.
6753e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius     *
6763e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius     * @param enable true to enable auto reconnecting, false to disable.
6773e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius     * @return true if request is sent successfully, false otherwise.
6783e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius     */
6793e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius    public boolean enableStaAutoReconnect(boolean enable) {
6803e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius        return mSupplicantStaIfaceHal.enableAutoReconnect(enable);
6813e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius    }
6823e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius
6833e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius    /**
684b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Migrate all the configured networks from wpa_supplicant.
685b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
686b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param configs       Map of configuration key to configuration objects corresponding to all
687b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *                      the networks.
688b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param networkExtras Map of extra configuration parameters stored in wpa_supplicant.conf
689b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return Max priority of all the configs.
690155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     */
691b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean migrateNetworksFromSupplicant(Map<String, WifiConfiguration> configs,
692b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                                                 SparseArray<Map<String, String>> networkExtras) {
693b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.loadNetworks(configs, networkExtras);
694155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
695155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
696b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
697b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Add the provided network configuration to wpa_supplicant and initiate connection to it.
698b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This method does the following:
699b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 1. Triggers disconnect command to wpa_supplicant (if |shouldDisconnect| is true).
700b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 2. Remove any existing network in wpa_supplicant.
701b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 3. Add a new network to wpa_supplicant.
702b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 4. Save the provided configuration to wpa_supplicant.
703b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 5. Select the new network in wpa_supplicant.
704b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 6. Triggers reconnect command to wpa_supplicant.
705b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
706b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param configuration WifiConfiguration parameters for the provided network.
707b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param shouldDisconnect whether to trigger a disconnection or not.
708b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return {@code true} if it succeeds, {@code false} otherwise
709b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
710b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean connectToNetwork(WifiConfiguration configuration, boolean shouldDisconnect) {
711b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.connectToNetwork(configuration, shouldDisconnect);
712155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
713155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
714b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
715b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Initiates roaming to the already configured network in wpa_supplicant. If the network
716b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * configuration provided does not match the already configured network, then this triggers
717b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * a new connection attempt (instead of roam).
718b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 1. First check if we're attempting to connect to the same network as we currently have
719b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * configured.
720b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 2. Set the new bssid for the network in wpa_supplicant.
721b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * 3. Triggers reassociate command to wpa_supplicant.
722b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
723b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param configuration WifiConfiguration parameters for the provided network.
724b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return {@code true} if it succeeds, {@code false} otherwise
725b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
726b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean roamToNetwork(WifiConfiguration configuration) {
727b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.roamToNetwork(configuration);
728155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
729155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
730b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
731b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Get the framework network ID corresponding to the provided supplicant network ID for the
732b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * network configured in wpa_supplicant.
733b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
734b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param supplicantNetworkId network ID in wpa_supplicant for the network.
735b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return Corresponding framework network ID if found, -1 if network not found.
736b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
737b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public int getFrameworkNetworkId(int supplicantNetworkId) {
738b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return supplicantNetworkId;
739155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
740155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
741b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
742b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Remove all the networks.
743b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
744b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return {@code true} if it succeeds, {@code false} otherwise
745b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
746b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean removeAllNetworks() {
747b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.removeAllNetworks();
748155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
749155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
750b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
751b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set the BSSID for the currently configured network in wpa_supplicant.
752b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
753b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if successful, false otherwise.
754b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
755b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setConfiguredNetworkBSSID(String bssid) {
756b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.setCurrentNetworkBssid(bssid);
757155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
758155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
759b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
760b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Initiate ANQP query.
761b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
762b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param bssid BSSID of the AP to be queried
763b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param anqpIds Set of anqp IDs.
764b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param hs20Subtypes Set of HS20 subtypes.
765b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success, false otherwise.
766b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
767b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean requestAnqp(String bssid, Set<Integer> anqpIds, Set<Integer> hs20Subtypes) {
768b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        if (bssid == null || ((anqpIds == null || anqpIds.isEmpty())
769b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                && (hs20Subtypes == null || hs20Subtypes.isEmpty()))) {
770b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            Log.e(mTAG, "Invalid arguments for ANQP request.");
771155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande            return false;
772155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
773b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        ArrayList<Short> anqpIdList = new ArrayList<>();
774b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        for (Integer anqpId : anqpIds) {
775b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            anqpIdList.add(anqpId.shortValue());
77661233efc46707ace6cb3a45dd84766f06df946afTomasz Wiszkowski        }
777b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        ArrayList<Integer> hs20SubtypeList = new ArrayList<>();
778b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        hs20SubtypeList.addAll(hs20Subtypes);
779b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.initiateAnqpQuery(bssid, anqpIdList, hs20SubtypeList);
780155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
781155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
782b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
783b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Request a passpoint icon file |filename| from the specified AP |bssid|.
784b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param bssid BSSID of the AP
785b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param fileName name of the icon file
786b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise
787b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
788b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean requestIcon(String  bssid, String fileName) {
789b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        if (bssid == null || fileName == null) {
790b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            Log.e(mTAG, "Invalid arguments for Icon request.");
79161233efc46707ace6cb3a45dd84766f06df946afTomasz Wiszkowski            return false;
792155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande        }
793b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.initiateHs20IconQuery(bssid, fileName);
794155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
795155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
796b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
797b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Get the currently configured network's WPS NFC token.
798b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
799b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return Hex string corresponding to the WPS NFC token.
800b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
801b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String getNfcWpsConfigurationToken(int netId) {
802b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantStaIfaceHal.getCurrentNetworkWpsNfcConfigurationToken();
803155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
804155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
805b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
806b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Populate list of available networks or update existing list.
807b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
808b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if list has been modified.
809b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
810b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pListNetworks(WifiP2pGroupList groups) {
811b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.loadGroups(groups);
812155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
813155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
814b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
815b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Initiate WPS Push Button setup.
816b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * The PBC operation requires that a button is also pressed at the
817b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * AP/Registrar at about the same time (2 minute window).
818b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
819b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param iface Group interface name to use.
820b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param bssid BSSID of the AP. Use zero'ed bssid to indicate wildcard.
821b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
822b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
823b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean startWpsPbc(String iface, String bssid) {
824b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.startWpsPbc(iface, bssid);
825155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
826155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
827b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
828b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Initiate WPS Pin Keypad setup.
829b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
830b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param iface Group interface name to use.
831b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param pin 8 digit pin to be used.
832b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
833b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
834b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean startWpsPinKeypad(String iface, String pin) {
835b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.startWpsPinKeypad(iface, pin);
836155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
837155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
838b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
839b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Initiate WPS Pin Display setup.
840b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
841b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param iface Group interface name to use.
842b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param bssid BSSID of the AP. Use zero'ed bssid to indicate wildcard.
843b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return generated pin if operation was successful, null otherwise.
844b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
845b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String startWpsPinDisplay(String iface, String bssid) {
846b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.startWpsPinDisplay(iface, bssid);
847155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
848155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
849b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
850b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Remove network with provided id.
851b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
852b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param netId Id of the network to lookup.
853b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
854b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
855b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean removeP2pNetwork(int netId) {
856b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.removeNetwork(netId);
857155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
858155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
859b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
860b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS device name.
861b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
862b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param name String to be set.
863b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
864b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
865b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setP2pDeviceName(String name) {
866b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.setWpsDeviceName(name);
867155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
868155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
869b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
870b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set WPS device type.
871b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
872b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param type Type specified as a string. Used format: <categ>-<OUI>-<subcateg>
873b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if request is sent successfully, false otherwise.
874b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
875b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setP2pDeviceType(String type) {
876b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.setWpsDeviceType(type);
877155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
878155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
879b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
880b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set the postfix to be used for P2P SSID's.
881b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
882b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param postfix String to be appended to SSID.
883b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
884b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
885b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
886b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setP2pSsidPostfix(String postfix) {
887b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.setSsidPostfix(postfix);
888155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
889155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
890b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
891b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set the Maximum idle time in seconds for P2P groups.
892b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This value controls how long a P2P group is maintained after there
893b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * is no other members in the group. As a group owner, this means no
894b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * associated stations in the group. As a P2P client, this means no
895b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * group owner seen in scan results.
896b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
897b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param iface Group interface name to use.
898b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param time Timeout value in seconds.
899b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
900b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
901b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
902b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setP2pGroupIdle(String iface, int time) {
903b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.setGroupIdle(iface, time);
904155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
905155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
906b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
907b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Turn on/off power save mode for the interface.
908b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
909b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param iface Group interface name to use.
910b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param enabled Indicate if power save is to be turned on/off.
911b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
912b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
913b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
914b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setP2pPowerSave(String iface, boolean enabled) {
915b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.setPowerSave(iface, enabled);
916155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
917155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
918b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
919b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Enable/Disable Wifi Display.
920b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
921b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param enable true to enable, false to disable.
922b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
923b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
924b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setWfdEnable(boolean enable) {
925b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.enableWfd(enable);
926155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
927155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
928b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
929b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set Wifi Display device info.
930b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
931b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param hex WFD device info as described in section 5.1.2 of WFD technical
932b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        specification v1.0.0.
933b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
934b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
935b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setWfdDeviceInfo(String hex) {
936b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.setWfdDeviceInfo(hex);
937155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
938155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
939b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
940b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Initiate a P2P service discovery indefinitely.
941b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
942b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
943b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
944b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pFind() {
945b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return p2pFind(0);
946155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
947155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
948b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
949b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Initiate a P2P service discovery with a (optional) timeout.
950b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
951b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param timeout Max time to be spent is peforming discovery.
952b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        Set to 0 to indefinely continue discovery untill and explicit
953b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        |stopFind| is sent.
954b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
955b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
956b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pFind(int timeout) {
957b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.find(timeout);
958155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
959155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
960b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
961b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Stop an ongoing P2P service discovery.
962b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
963b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
964b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
965b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pStopFind() {
966b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.stopFind();
967155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
968155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
969b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
970b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Configure Extended Listen Timing.
971b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
972b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * If enabled, listen state must be entered every |intervalInMillis| for at
973b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * least |periodInMillis|. Both values have acceptable range of 1-65535
974b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * (with interval obviously having to be larger than or equal to duration).
975b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * If the P2P module is not idle at the time the Extended Listen Timing
976b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * timeout occurs, the Listen State operation must be skipped.
977b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
978b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param enable Enables or disables listening.
979b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param period Period in milliseconds.
980b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param interval Interval in milliseconds.
981b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
982b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
983b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
984b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pExtListen(boolean enable, int period, int interval) {
985b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.configureExtListen(enable, period, interval);
986155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
987155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande
988b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
989b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set P2P Listen channel.
990b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
991b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * When specifying a social channel on the 2.4 GHz band (1/6/11) there is no
992b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * need to specify the operating class since it defaults to 81. When
993b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * specifying a social channel on the 60 GHz band (2), specify the 60 GHz
994b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * operating class (180).
995b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
996b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param lc Wifi channel. eg, 1, 6, 11.
997b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param oc Operating Class indicates the channel set of the AP
998b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        indicated by this BSSID
999b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1000b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
1001155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande     */
1002b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pSetChannel(int lc, int oc) {
1003b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.setListenChannel(lc, oc);
1004155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande    }
10053f7ef65ab71619040032aee96b5599849881d6fdAndres Morales
1006b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1007b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Flush P2P peer table and state.
1008b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1009b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
1010f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande     */
1011b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pFlush() {
1012b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.flush();
1013f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande    }
1014f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande
1015b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1016b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start P2P group formation with a discovered P2P peer. This includes
1017b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * optional group owner negotiation, group interface setup, provisioning,
1018b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * and establishing data connection.
1019b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1020b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param config Configuration to use to connect to remote device.
1021b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param joinExistingGroup Indicates that this is a command to join an
1022b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        existing group as a client. It skips the group owner negotiation
1023b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        part. This must send a Provision Discovery Request message to the
1024b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        target group owner before associating for WPS provisioning.
1025b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1026b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return String containing generated pin, if selected provision method
1027b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        uses PIN.
1028b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1029b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String p2pConnect(WifiP2pConfig config, boolean joinExistingGroup) {
1030b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.connect(config, joinExistingGroup);
1031f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande    }
1032f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande
1033b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1034b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Cancel an ongoing P2P group formation and joining-a-group related
1035b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * operation. This operation unauthorizes the specific peer device (if any
1036b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * had been authorized to start group formation), stops P2P find (if in
1037b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * progress), stops pending operations for join-a-group, and removes the
1038b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * P2P group interface (if one was used) that is in the WPS provisioning
1039b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * step. If the WPS provisioning step has been completed, the group is not
1040b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * terminated.
1041b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1042b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
1043b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1044b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pCancelConnect() {
1045b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.cancelConnect();
1046f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande    }
1047f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande
1048b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1049b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Send P2P provision discovery request to the specified peer. The
1050b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * parameters for this command are the P2P device address of the peer and the
1051b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * desired configuration method.
1052b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1053b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param config Config class describing peer setup.
1054b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1055b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
1056b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1057b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pProvisionDiscovery(WifiP2pConfig config) {
1058b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.provisionDiscovery(config);
1059f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande    }
1060f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande
1061b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1062b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set up a P2P group owner manually.
1063b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This is a helper method that invokes groupAdd(networkId, isPersistent) internally.
1064b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1065b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param persistent Used to request a persistent group to be formed.
1066b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1067b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
1068b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1069b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pGroupAdd(boolean persistent) {
1070b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.groupAdd(persistent);
1071f49a59bda006b13e0118d144e0a4a5f569b2251eVinit Deshpande    }
107296c464e93515cda4326ca93ecf8a90c9ab551b7fRoshan Pius
1073b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1074b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set up a P2P group owner manually (i.e., without group owner
1075b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * negotiation with a specific peer). This is also known as autonomous
1076b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * group owner.
1077b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1078b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param netId Used to specify the restart of a persistent group.
1079b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1080b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
1081b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1082b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pGroupAdd(int netId) {
1083b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.groupAdd(netId, true);
108496c464e93515cda4326ca93ecf8a90c9ab551b7fRoshan Pius    }
108596c464e93515cda4326ca93ecf8a90c9ab551b7fRoshan Pius
1086b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1087b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Terminate a P2P group. If a new virtual network interface was used for
1088b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * the group, it must also be removed. The network interface name of the
1089b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * group interface is used as a parameter for this command.
1090b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1091b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param iface Group interface name to use.
1092b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
1093b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1094b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pGroupRemove(String iface) {
1095b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.groupRemove(iface);
109696c464e93515cda4326ca93ecf8a90c9ab551b7fRoshan Pius    }
109796c464e93515cda4326ca93ecf8a90c9ab551b7fRoshan Pius
1098a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1099b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Reject connection attempt from a peer (specified with a device
1100b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * address). This is a mechanism to reject a pending group owner negotiation
1101b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * with a peer and request to automatically block any further connection or
1102b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * discovery of the peer.
1103a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     *
1104b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param deviceAddress MAC address of the device to reject.
1105b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1106b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
1107a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1108b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pReject(String deviceAddress) {
1109b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.reject(deviceAddress);
1110a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1111a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1112a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1113b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Invite a device to a persistent group.
1114b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * If the peer device is the group owner of the persistent group, the peer
1115b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * parameter is not needed. Otherwise it is used to specify which
1116b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * device to invite. |goDeviceAddress| parameter may be used to override
1117b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * the group owner device address for Invitation Request should it not be
1118b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * known for some reason (this should not be needed in most cases).
1119a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     *
1120b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param group Group object to use.
1121b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param deviceAddress MAC address of the device to invite.
1122b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1123b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
1124a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1125b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pInvite(WifiP2pGroup group, String deviceAddress) {
1126b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.invite(group, deviceAddress);
1127a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1128a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1129a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1130b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Reinvoke a device from a persistent group.
1131a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     *
1132b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param netId Used to specify the persistent group.
1133b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param deviceAddress MAC address of the device to reinvoke.
1134b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1135b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
1136a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1137b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pReinvoke(int netId, String deviceAddress) {
1138b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.reinvoke(netId, deviceAddress);
1139a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1140a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1141a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1142b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Gets the operational SSID of the device.
1143a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     *
1144b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param deviceAddress MAC address of the peer.
1145b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1146b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return SSID of the device.
1147a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1148b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String p2pGetSsid(String deviceAddress) {
1149b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.getSsid(deviceAddress);
1150a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1151a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1152a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1153b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Gets the MAC address of the device.
1154a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     *
1155b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return MAC address of the device.
1156a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1157b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String p2pGetDeviceAddress() {
1158b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.getDeviceAddress();
1159a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1160a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1161a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1162b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Gets the capability of the group which the device is a
1163b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * member of.
1164a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     *
1165b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param deviceAddress MAC address of the peer.
1166b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1167b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return combination of |GroupCapabilityMask| values.
1168a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1169b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public int getGroupCapability(String deviceAddress) {
1170b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.getGroupCapability(deviceAddress);
1171a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1172a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1173a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1174b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This command can be used to add a upnp/bonjour service.
1175b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1176b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param servInfo List of service queries.
1177b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1178b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
1179a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1180b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pServiceAdd(WifiP2pServiceInfo servInfo) {
1181b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.serviceAdd(servInfo);
1182a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1183a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1184a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1185b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This command can be used to remove a upnp/bonjour service.
1186b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1187b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param servInfo List of service queries.
1188a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     *
1189b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
1190a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1191b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pServiceDel(WifiP2pServiceInfo servInfo) {
1192b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.serviceRemove(servInfo);
1193a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1194a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1195a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1196b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This command can be used to flush all services from the
1197b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * device.
1198b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1199b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return boolean value indicating whether operation was successful.
1200a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1201b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pServiceFlush() {
1202b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.serviceFlush();
1203a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
1204a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius
1205a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    /**
1206b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Schedule a P2P service discovery request. The parameters for this command
1207b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * are the device address of the peer device (or 00:00:00:00:00:00 for
1208b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * wildcard query that is sent to every discovered P2P peer that supports
1209b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * service discovery) and P2P Service Query TLV(s) as hexdump.
1210b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1211b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param addr MAC address of the device to discover.
1212b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param query Hex dump of the query data.
1213b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return identifier Identifier for the request. Can be used to cancel the
1214b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *         request.
1215a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius     */
1216b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String p2pServDiscReq(String addr, String query) {
1217b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.requestServiceDiscovery(addr, query);
1218a26a8b33616c94859ba33f33403794cf636baa54Roshan Pius    }
12197e0315140767e6f12200f7dbbe7aff43b4f75089Vinit Deshpande
1220fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius    /**
1221b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Cancel a previous service discovery request.
1222fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius     *
1223b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param id Identifier for the request to cancel.
1224b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true, if operation was successful.
1225fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius     */
1226b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean p2pServDiscCancelReq(String id) {
1227b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.cancelServiceDiscovery(id);
1228fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius    }
1229fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius
1230fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius    /**
1231b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Send driver command to set Miracast mode.
1232fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius     *
1233b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param mode Mode of Miracast.
1234b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        0 = disabled
1235b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        1 = operating as source
1236b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *        2 = operating as sink
1237fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius     */
1238b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public void setMiracastMode(int mode) {
1239b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mSupplicantP2pIfaceHal.setMiracastMode(mode);
1240fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius    }
1241fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius
1242fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius    /**
1243b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Get NFC handover request message.
1244b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1245b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return select message if created successfully, null otherwise.
1246fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius     */
1247b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String getNfcHandoverRequest() {
1248b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.getNfcHandoverRequest();
1249fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius    }
1250fc83b303a3382329c28d631b1e0fb2bb35969f85Roshan Pius
1251b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1252b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Get NFC handover select message.
1253b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1254b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return select message if created successfully, null otherwise.
1255b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1256b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String getNfcHandoverSelect() {
1257b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.getNfcHandoverSelect();
12587e0315140767e6f12200f7dbbe7aff43b4f75089Vinit Deshpande    }
12597e0315140767e6f12200f7dbbe7aff43b4f75089Vinit Deshpande
1260b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1261b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Report NFC handover select message.
1262b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1263b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if reported successfully, false otherwise.
1264b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1265b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean initiatorReportNfcHandover(String selectMessage) {
1266b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.initiatorReportNfcHandover(selectMessage);
1267b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    }
12687f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
1269b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1270b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Report NFC handover request message.
1271b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1272b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if reported successfully, false otherwise.
1273b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1274b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean responderReportNfcHandover(String requestMessage) {
1275b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mSupplicantP2pIfaceHal.responderReportNfcHandover(requestMessage);
127618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    }
127718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills
1278b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1279b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Get P2P client list for the given network ID.
1280b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success, false otherwise.
1281b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1282b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public String getP2pClientList(int netId) {
1283b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // TODO(b/36042785): Add HIDL method.
1284b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return null;
1285b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    }
12867f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
1287b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1288b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set P2P client list for the given network ID.
1289b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success, false otherwise.
1290b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1291b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setP2pClientList(int netId, String list) {
1292b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // TODO(b/36042785): Add HIDL method.
1293b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return false;
1294b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    }
12957f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
1296b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1297b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Save the current configuration to wpa_supplicant.conf.
1298b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1299b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean saveConfig() {
1300b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // TODO(b/36042785): Add HIDL method.
1301b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return false;
13027ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde    }
13037ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde
1304b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /********************************************************
1305b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Vendor HAL operations
1306b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     ********************************************************/
1307b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius
1308d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius    /**
1309520fbe7db055661af039303c1081236c73b04abdRoshan Pius     * Initializes the vendor HAL. This is just used to initialize the {@link HalDeviceManager}.
1310520fbe7db055661af039303c1081236c73b04abdRoshan Pius     */
1311520fbe7db055661af039303c1081236c73b04abdRoshan Pius    public boolean initializeVendorHal() {
1312b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.initialize();
1313520fbe7db055661af039303c1081236c73b04abdRoshan Pius    }
1314520fbe7db055661af039303c1081236c73b04abdRoshan Pius
1315520fbe7db055661af039303c1081236c73b04abdRoshan Pius    /**
1316d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius     * Bring up the Vendor HAL and configure for STA mode or AP mode.
1317d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius     *
1318d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius     * @param isStaMode true to start HAL in STA mode, false to start in AP mode.
1319d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius     */
1320d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius    public boolean startHal(boolean isStaMode) {
1321b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.startVendorHal(isStaMode);
13227ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde    }
13237ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde
1324b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1325b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Stops the HAL
1326b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
132718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public void stopHal() {
1328b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        mWifiVendorHal.stopVendorHal();
13297ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde    }
13307f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
1331b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1332b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Tests whether the HAL is running or not
1333b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
133418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean isHalStarted() {
1335b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.isHalStarted();
13367f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde    }
13377f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
1338062e3f39e37874fedc01f267de5f4cf7dbebe2b4Randy Pan    // TODO: Change variable names to camel style.
1339e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    public static class ScanCapabilities {
1340297c3acabe7a85eb87240fe3ccf772e57ce6aef7Mitchell Wills        public int  max_scan_cache_size;
1341e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde        public int  max_scan_buckets;
1342e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde        public int  max_ap_cache_per_scan;
1343e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde        public int  max_rssi_sample_size;
1344297c3acabe7a85eb87240fe3ccf772e57ce6aef7Mitchell Wills        public int  max_scan_reporting_threshold;
13457d6301ead19afdf3de37455e9ed133c25b4938cdVinit Deshpande        public int  max_hotlist_bssids;
1346e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde        public int  max_significant_wifi_change_aps;
1347d34e3a7b98d51f684100483151fceb233fd95215Roshan Pius        public int  max_bssid_history_entries;
1348d34e3a7b98d51f684100483151fceb233fd95215Roshan Pius        public int  max_number_epno_networks;
1349d34e3a7b98d51f684100483151fceb233fd95215Roshan Pius        public int  max_number_epno_networks_by_ssid;
1350d34e3a7b98d51f684100483151fceb233fd95215Roshan Pius        public int  max_number_of_white_listed_ssid;
1351e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1352e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
1353b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1354b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Gets the scan capabilities
1355b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1356b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param capabilities object to be filled in
1357b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success. false for failure
1358b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
13596ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass    public boolean getBgScanCapabilities(ScanCapabilities capabilities) {
13606ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass        return mWifiVendorHal.getBgScanCapabilities(capabilities);
1361e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1362e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
1363e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    public static class ChannelSettings {
1364712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int frequency;
1365712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int dwell_time_ms;
1366712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public boolean passive;
13677f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde    }
13687f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
1369e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    public static class BucketSettings {
1370712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int bucket;
1371712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int band;
1372712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int period_ms;
1373712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int max_period_ms;
1374712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int step_count;
1375712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int report_events;
1376712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int num_channels;
1377712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public ChannelSettings[] channels;
1378e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
13797f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
13806259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius    /**
13816259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius     * Network parameters for hidden networks to be scanned for.
13826259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius     */
13836259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius    public static class HiddenNetwork {
13846259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius        public String ssid;
13856259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius
13866259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius        @Override
13876259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius        public boolean equals(Object otherObj) {
13886259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius            if (this == otherObj) {
13896259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius                return true;
13906259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius            } else if (otherObj == null || getClass() != otherObj.getClass()) {
13916259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius                return false;
13926259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius            }
13936259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius            HiddenNetwork other = (HiddenNetwork) otherObj;
13946259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius            return Objects.equals(ssid, other.ssid);
13956259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius        }
1396ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh
1397ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh        @Override
1398ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh        public int hashCode() {
1399ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh            return (ssid == null ? 0 : ssid.hashCode());
1400ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh        }
14016259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius    }
14026259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius
1403e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    public static class ScanSettings {
1404712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int base_period_ms;
1405712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int max_ap_per_scan;
1406712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int report_threshold_percent;
1407712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int report_threshold_num_scans;
1408712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public int num_buckets;
14096259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius        /* Not used for bg scans. Only works for single scans. */
14106259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius        public HiddenNetwork[] hiddenNetworks;
1411712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills        public BucketSettings[] buckets;
1412e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
14137f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
141468cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang    /**
14159bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * Network parameters to start PNO scan.
14169bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     */
14179bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    public static class PnoNetwork {
14189bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public String ssid;
14199bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public byte flags;
1420ef3ea1092bc17673c0a85a845b053151b7c10e07Roshan Pius        public byte auth_bit_field;
14211bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius
14221bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius        @Override
14231bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius        public boolean equals(Object otherObj) {
14241bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius            if (this == otherObj) {
14251bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius                return true;
14261bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius            } else if (otherObj == null || getClass() != otherObj.getClass()) {
14271bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius                return false;
14281bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius            }
14291bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius            PnoNetwork other = (PnoNetwork) otherObj;
14306259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius            return ((Objects.equals(ssid, other.ssid)) && (flags == other.flags)
14311bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius                    && (auth_bit_field == other.auth_bit_field));
14321bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius        }
1433ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh
1434ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh        @Override
1435ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh        public int hashCode() {
1436ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh            int result = (ssid == null ? 0 : ssid.hashCode());
1437ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh            result ^= ((int) flags * 31) + ((int) auth_bit_field << 8);
1438ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh            return result;
1439ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh        }
14409bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    }
14419bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius
14429bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    /**
14439bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * Parameters to start PNO scan. This holds the list of networks which are going to used for
14449bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * PNO scan.
14459bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     */
14469bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    public static class PnoSettings {
14479bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public int min5GHzRssi;
14489bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public int min24GHzRssi;
14499bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public int initialScoreMax;
14509bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public int currentConnectionBonus;
14519bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public int sameNetworkBonus;
14529bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public int secureBonus;
14539bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public int band5GHzBonus;
145404c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang        public int periodInMs;
1455dcd877d6c143db557884993ea437e2a432cb0ba3Roshan Pius        public boolean isConnected;
14569bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        public PnoNetwork[] networkList;
14579bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    }
14589bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius
1459b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande    public static interface ScanEventHandler {
146063539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills        /**
146163539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         * Called for each AP as it is found with the entire contents of the beacon/probe response.
146263539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         * Only called when WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT is specified.
146363539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         */
1464c9e6069eb941d282af213dc20b171877db6b567bMitchell Wills        void onFullScanResult(ScanResult fullScanResult, int bucketsScanned);
146563539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills        /**
146663539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         * Callback on an event during a gscan scan.
146763539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         * See WifiNative.WIFI_SCAN_* for possible values.
146863539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         */
146963539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills        void onScanStatus(int event);
147063539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills        /**
147163539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         * Called with the current cached scan results when gscan is paused.
147263539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         */
147383a674a18c84ff4f01377bbfd8988699dec93bc2Vinit Deshpande        void onScanPaused(WifiScanner.ScanData[] data);
147463539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills        /**
147563539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         * Called with the current cached scan results when gscan is resumed.
147663539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills         */
1477b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande        void onScanRestarted();
1478e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1479e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
14809bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    /**
14819bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * Handler to notify the occurrence of various events during PNO scan.
14829bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     */
14839bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    public interface PnoEventHandler {
14849bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        /**
14859bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius         * Callback to notify when one of the shortlisted networks is found during PNO scan.
14869bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius         * @param results List of Scan results received.
14879bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius         */
14889bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius        void onPnoNetworkFound(ScanResult[] results);
1489063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius
1490063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius        /**
1491063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius         * Callback to notify when the PNO scan schedule fails.
1492063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius         */
1493063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius        void onPnoScanFailed();
14949bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    }
14959bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius
149671af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills    public static final int WIFI_SCAN_RESULTS_AVAILABLE = 0;
149771af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills    public static final int WIFI_SCAN_THRESHOLD_NUM_SCANS = 1;
149871af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills    public static final int WIFI_SCAN_THRESHOLD_PERCENT = 2;
149971af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills    public static final int WIFI_SCAN_FAILED = 3;
1500b7cc309f06da8a18224057c21ba086f8550367d6Vinit Deshpande
1501b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1502b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Starts a background scan.
1503b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Any ongoing scan will be stopped first
1504b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1505b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param settings     to control the scan
1506b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param eventHandler to call with the results
1507b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success
1508b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
15096ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass    public boolean startBgScan(ScanSettings settings, ScanEventHandler eventHandler) {
15106ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass        return mWifiVendorHal.startBgScan(settings, eventHandler);
15117f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde    }
15127f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde
1513b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1514b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Stops any ongoing backgound scan
1515b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
15166ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass    public void stopBgScan() {
15176ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass        mWifiVendorHal.stopBgScan();
1518b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande    }
1519b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande
1520b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1521b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Pauses an ongoing backgound scan
1522b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
15236ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass    public void pauseBgScan() {
15246ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass        mWifiVendorHal.pauseBgScan();
1525b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande    }
1526b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande
1527b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1528b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Restarts a paused scan
1529b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
15306ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass    public void restartBgScan() {
15316ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass        mWifiVendorHal.restartBgScan();
1532e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1533e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
1534b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1535b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Gets the latest scan results received.
1536b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
15376ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass    public WifiScanner.ScanData[] getBgScanResults() {
15386ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass        return mWifiVendorHal.getBgScanResults();
1539e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1540e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
1541b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande    public static interface HotlistEventHandler {
1542d4762401ec14be6bdd2d27aff2478ddbf8d6ce2aVinit Deshpande        void onHotlistApFound (ScanResult[] result);
1543d4762401ec14be6bdd2d27aff2478ddbf8d6ce2aVinit Deshpande        void onHotlistApLost  (ScanResult[] result);
1544e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1545e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
154618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean setHotlist(WifiScanner.HotlistSettings settings,
154718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills            HotlistEventHandler eventHandler) {
1548b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        Log.e(mTAG, "setHotlist not supported");
1549b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return false;
1550e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1551e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
155218786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public void resetHotlist() {
1553b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        Log.e(mTAG, "resetHotlist not supported");
1554e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1555e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
1556b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande    public static interface SignificantWifiChangeEventHandler {
1557e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde        void onChangesFound(ScanResult[] result);
1558e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1559e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
156018786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean trackSignificantWifiChange(
1561b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande            WifiScanner.WifiChangeSettings settings, SignificantWifiChangeEventHandler handler) {
1562b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        Log.e(mTAG, "trackSignificantWifiChange not supported");
1563b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return false;
1564e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1565e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
156618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public void untrackSignificantWifiChange() {
1567b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        Log.e(mTAG, "untrackSignificantWifiChange not supported");
1568e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde    }
1569e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde
157018786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public WifiLinkLayerStats getWifiLinkLayerStats(String iface) {
1571b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getWifiLinkLayerStats();
15725c08cc119b92af69997af194cc8b6d0111e37d31Andres Morales    }
15735c08cc119b92af69997af194cc8b6d0111e37d31Andres Morales
157418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public void setWifiLinkLayerStats(String iface, int enable) {
1575b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // TODO(b//36087365) Remove this. Link layer stats is enabled when the HAL is started.
1576d745a52dc4f929d4a4030f205ed173bdf60eaf10Pierre Vandwalle    }
1577d745a52dc4f929d4a4030f205ed173bdf60eaf10Pierre Vandwalle
1578b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1579b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Get the supported features
1580b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1581b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return bitmask defined by WifiManager.WIFI_FEATURE_*
1582b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
158318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public int getSupportedFeatureSet() {
1584b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getSupportedFeatureSet();
1585a632d8a6edd350c7644b593b18eceaa5b368505bVinit Deshpande    }
1586143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande
1587143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande    public static interface RttEventHandler {
1588143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande        void onRttResults(RttManager.RttResult[] result);
1589143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande    }
1590143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande
1591b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1592b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Starts a new rtt request
1593b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1594b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param params RTT request params. Refer to {@link RttManager#RttParams}.
1595b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param handler Callback to be invoked to notify any results.
1596b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if the request was successful, false otherwise.
1597b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
159818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean requestRtt(
1599143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande            RttManager.RttParams[] params, RttEventHandler handler) {
1600b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.requestRtt(params, handler);
1601143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande    }
1602143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande
1603b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1604b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Cancels an outstanding rtt request
1605b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1606b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param params RTT request params. Refer to {@link RttManager#RttParams}
1607b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if there was an outstanding request and it was successfully cancelled
1608b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
160918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean cancelRtt(RttManager.RttParams[] params) {
1610b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.cancelRtt(params);
1611143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande    }
1612042c54bfd5144ce8e720585b2093796e7e28de5eVinit Deshpande
161368cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang    /**
161468cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang     * Enable RTT responder role on the device. Returns {@link ResponderConfig} if the responder
161568cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang     * role is successfully enabled, {@code null} otherwise.
1616b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1617b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param timeoutSeconds timeout to use for the responder.
161868cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang     */
161968cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang    @Nullable
1620b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public ResponderConfig enableRttResponder(int timeoutSeconds) {
1621b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.enableRttResponder(timeoutSeconds);
162212cf388ecf3b2aa5ba66ed680b931fa356ab75b5xinhe    }
1623939177ff615062ec826601d536466875d8457375xinhe
1624b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1625b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Disable RTT responder role. Returns {@code true} if responder role is successfully disabled,
1626b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * {@code false} otherwise.
1627b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1628b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean disableRttResponder() {
1629b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.disableRttResponder();
16306609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen    }
16316609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen
1632b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1633b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set the MAC OUI during scanning.
1634b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * An OUI {Organizationally Unique Identifier} is a 24-bit number that
1635b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * uniquely identifies a vendor or manufacturer.
1636b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1637b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param oui OUI to set.
1638b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success
1639b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1640b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setScanningMacOui(byte[] oui) {
1641b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.setScanningMacOui(oui);
16426609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen    }
16436609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen
1644b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1645b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Query the list of valid frequencies for the provided band.
1646b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * The result depends on the on the country code that has been set.
1647b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1648b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param band as specified by one of the WifiScanner.WIFI_BAND_* constants.
1649b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return frequencies vector of valid frequencies (MHz), or null for error.
1650b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @throws IllegalArgumentException if band is not recognized.
1651b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1652b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public int [] getChannelsForBand(int band) {
1653b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getChannelsForBand(band);
1654939177ff615062ec826601d536466875d8457375xinhe    }
1655939177ff615062ec826601d536466875d8457375xinhe
1656b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1657b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Indicates whether getChannelsForBand is supported.
1658b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1659b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true if it is.
1660b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1661b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean isGetChannelsForBandSupported() {
1662b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.isGetChannelsForBandSupported();
1663d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe    }
1664d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe
1665b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1666b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set DFS - actually, this is always on.
1667b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1668b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param dfsOn
1669b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return success indication
1670b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1671b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setDfsFlag(boolean dfsOn) {
1672b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.setDfsFlag(dfsOn);
1673d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe    }
1674d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe
1675b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1676b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * RTT (Round Trip Time) measurement capabilities of the device.
1677b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1678b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public RttManager.RttCapabilities getRttCapabilities() {
1679b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getRttCapabilities();
1680d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe    }
1681d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe
1682b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1683b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Get the APF (Android Packet Filter) capabilities of the device
1684b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1685b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public ApfCapabilities getApfCapabilities() {
1686b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getApfCapabilities();
1687d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe    }
1688d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe
1689b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1690b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Installs an APF program on this iface, replacing any existing program.
1691b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1692b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param filter is the android packet filter program
1693b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success
1694b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1695b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean installPacketFilter(byte[] filter) {
1696b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.installPacketFilter(filter);
1697d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe    }
1698d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe
1699b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1700b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Set country code for this AP iface.
1701b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1702b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param countryCode - two-letter country code (as ISO 3166)
1703b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success
1704b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1705b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public boolean setCountryCodeHal(String countryCode) {
1706b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.setCountryCodeHal(countryCode);
1707d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe    }
1708d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe
1709a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle    //---------------------------------------------------------------------------------
1710a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle    /* Wifi Logger commands/events */
1711a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle    public static interface WifiLoggerEventHandler {
17120bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        void onRingBufferData(RingBufferStatus status, byte[] buffer);
17130bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        void onWifiAlert(int errorCode, byte[] buffer);
1714a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle    }
1715a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle
1716b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1717b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Registers the logger callback and enables alerts.
1718b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Ring buffer data collection is only triggered when |startLoggingRingBuffer| is invoked.
1719b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1720b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param handler Callback to be invoked.
1721b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success, false otherwise.
1722b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
172318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean setLoggingEventHandler(WifiLoggerEventHandler handler) {
1724b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.setLoggingEventHandler(handler);
172503ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe    }
172603ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe
1727b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1728b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Control debug data collection
1729b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1730b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param verboseLevel 0 to 3, inclusive. 0 stops logging.
1731b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param flags        Ignored.
1732b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param maxInterval  Maximum interval between reports; ignore if 0.
1733b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param minDataSize  Minimum data size in buffer for report; ignore if 0.
1734b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param ringName     Name of the ring for which data collection is to start.
1735b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success, false otherwise.
1736b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
173718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean startLoggingRingBuffer(int verboseLevel, int flags, int maxInterval,
173803ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe            int minDataSize, String ringName){
1739b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.startLoggingRingBuffer(
1740b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                verboseLevel, flags, maxInterval, minDataSize, ringName);
174103ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe    }
174203ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe
1743b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1744b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Logger features exposed.
1745b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This is a no-op now, will always return -1.
1746b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1747b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success, false otherwise.
1748b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
174918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public int getSupportedLoggerFeatureSet() {
1750b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getSupportedLoggerFeatureSet();
175103ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe    }
175203ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe
1753b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1754b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Stops all logging and resets the logger callback.
1755b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * This stops both the alerts and ring buffer data collection.
1756b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success, false otherwise.
1757b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
175818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean resetLogHandler() {
1759b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.resetLogHandler();
1760b797893fc1966803d0c013faac42e6396a37a384xinhe    }
1761b797893fc1966803d0c013faac42e6396a37a384xinhe
1762b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1763b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Vendor-provided wifi driver version string
1764b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1765b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return String returned from the HAL.
1766b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
176718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public String getDriverVersion() {
1768b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getDriverVersion();
176903ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe    }
177003ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe
1771b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1772b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Vendor-provided wifi firmware version string
1773b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1774b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return String returned from the HAL.
1775b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
177618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public String getFirmwareVersion() {
1777b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getFirmwareVersion();
177803ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe    }
177903ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe
17800bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande    public static class RingBufferStatus{
17810bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        String name;
17820bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        int flag;
17830bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        int ringBufferId;
17840bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        int ringBufferByteSize;
17850bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        int verboseLevel;
17860bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        int writtenBytes;
17870bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        int readBytes;
17880bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        int writtenRecords;
17890bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande
179053f278b6fed422a18d763b07216a21e96d9445f9Michael Plass        // Bit masks for interpreting |flag|
179153f278b6fed422a18d763b07216a21e96d9445f9Michael Plass        public static final int HAS_BINARY_ENTRIES = (1 << 0);
179253f278b6fed422a18d763b07216a21e96d9445f9Michael Plass        public static final int HAS_ASCII_ENTRIES = (1 << 1);
179353f278b6fed422a18d763b07216a21e96d9445f9Michael Plass        public static final int HAS_PER_PACKET_ENTRIES = (1 << 2);
179453f278b6fed422a18d763b07216a21e96d9445f9Michael Plass
17950bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        @Override
17960bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        public String toString() {
17970bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande            return "name: " + name + " flag: " + flag + " ringBufferId: " + ringBufferId +
17980bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande                    " ringBufferByteSize: " +ringBufferByteSize + " verboseLevel: " +verboseLevel +
17990bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande                    " writtenBytes: " + writtenBytes + " readBytes: " + readBytes +
18000bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande                    " writtenRecords: " + writtenRecords;
18010bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande        }
18020bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande    }
18030bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande
1804b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1805b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * API to get the status of all ring buffers supported by driver
1806b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
180718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public RingBufferStatus[] getRingBufferStatus() {
1808b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getRingBufferStatus();
180903ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe    }
181003ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe
1811b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1812b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Indicates to driver that all the data has to be uploaded urgently
1813b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1814b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param ringName Name of the ring buffer requested.
1815b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true on success, false otherwise.
1816b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
181718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public boolean getRingBufferData(String ringName) {
1818b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getRingBufferData(ringName);
181903ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe    }
1820127f7244183786e6ccae09e81eeccdac31973e69xinhe
1821b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1822b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Request vendor debug info from the firmware
1823b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1824b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return Raw data obtained from the HAL.
1825b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
182618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public byte[] getFwMemoryDump() {
1827b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getFwMemoryDump();
1828a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle    }
1829dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle
1830b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
1831b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Request vendor debug info from the driver
1832b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
1833b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return Raw data obtained from the HAL.
1834b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
1835d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal    public byte[] getDriverStateDump() {
1836b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getDriverStateDump();
1837d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal    }
1838d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal
1839dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle    //---------------------------------------------------------------------------------
184009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    /* Packet fate API */
184109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal
184209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    @Immutable
184309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    abstract static class FateReport {
1844eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        final static int USEC_PER_MSEC = 1000;
1845eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        // The driver timestamp is a 32-bit counter, in microseconds. This field holds the
1846eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        // maximal value of a driver timestamp in milliseconds.
1847eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        final static int MAX_DRIVER_TIMESTAMP_MSEC = (int) (0xffffffffL / 1000);
1848eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        final static SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss.SSS");
1849eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal
185009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        final byte mFate;
185109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        final long mDriverTimestampUSec;
185209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        final byte mFrameType;
185309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        final byte[] mFrameBytes;
1854eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        final long mEstimatedWallclockMSec;
185509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal
185609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        FateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) {
185709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal            mFate = fate;
185809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal            mDriverTimestampUSec = driverTimestampUSec;
1859eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            mEstimatedWallclockMSec =
1860eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                    convertDriverTimestampUSecToWallclockMSec(mDriverTimestampUSec);
186109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal            mFrameType = frameType;
186209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal            mFrameBytes = frameBytes;
186309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        }
18640fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
1865590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan        public String toTableRowString() {
1866590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            StringWriter sw = new StringWriter();
1867590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            PrintWriter pw = new PrintWriter(sw);
1868590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            FrameParser parser = new FrameParser(mFrameType, mFrameBytes);
1869eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            dateFormatter.setTimeZone(TimeZone.getDefault());
1870eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            pw.format("%-15s  %12s  %-9s  %-32s  %-12s  %-23s  %s\n",
1871eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                    mDriverTimestampUSec,
1872eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                    dateFormatter.format(new Date(mEstimatedWallclockMSec)),
1873eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                    directionToString(), fateToString(), parser.mMostSpecificProtocolString,
1874eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                    parser.mTypeString, parser.mResultString);
1875590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            return sw.toString();
1876590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan        }
1877590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan
1878590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan        public String toVerboseStringWithPiiAllowed() {
18790fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            StringWriter sw = new StringWriter();
18800fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            PrintWriter pw = new PrintWriter(sw);
1881590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            FrameParser parser = new FrameParser(mFrameType, mFrameBytes);
18820fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            pw.format("Frame direction: %s\n", directionToString());
18830fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            pw.format("Frame timestamp: %d\n", mDriverTimestampUSec);
18840fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            pw.format("Frame fate: %s\n", fateToString());
18850fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            pw.format("Frame type: %s\n", frameTypeToString(mFrameType));
1886590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            pw.format("Frame protocol: %s\n", parser.mMostSpecificProtocolString);
1887590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            pw.format("Frame protocol type: %s\n", parser.mTypeString);
18880fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            pw.format("Frame length: %d\n", mFrameBytes.length);
18890fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            pw.append("Frame bytes");
1890590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            pw.append(HexDump.dumpHexString(mFrameBytes));  // potentially contains PII
18910fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            pw.append("\n");
18920fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            return sw.toString();
18930fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        }
18940fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
1895590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan        /* Returns a header to match the output of toTableRowString(). */
1896590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan        public static String getTableHeader() {
1897590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            StringWriter sw = new StringWriter();
1898590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            PrintWriter pw = new PrintWriter(sw);
1899eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            pw.format("\n%-15s  %-12s  %-9s  %-32s  %-12s  %-23s  %s\n",
1900eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                    "Time usec", "Walltime", "Direction", "Fate", "Protocol", "Type", "Result");
1901eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            pw.format("%-15s  %-12s  %-9s  %-32s  %-12s  %-23s  %s\n",
1902eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                    "---------", "--------", "---------", "----", "--------", "----", "------");
1903590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan            return sw.toString();
1904590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan        }
1905590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan
19060fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        protected abstract String directionToString();
19070fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
19080fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        protected abstract String fateToString();
19090fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
19100fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        private static String frameTypeToString(byte frameType) {
19110fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            switch (frameType) {
19120fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.FRAME_TYPE_UNKNOWN:
19130fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "unknown";
19140fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.FRAME_TYPE_ETHERNET_II:
19150fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "data";
19160fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.FRAME_TYPE_80211_MGMT:
19170fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "802.11 management";
19180fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                default:
19190fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return Byte.toString(frameType);
19200fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            }
19210fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        }
1922eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal
1923eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        /**
1924eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal         * Converts a driver timestamp to a wallclock time, based on the current
1925eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal         * BOOTTIME to wallclock mapping. The driver timestamp is a 32-bit counter of
1926eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal         * microseconds, with the same base as BOOTTIME.
1927eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal         */
1928eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        private static long convertDriverTimestampUSecToWallclockMSec(long driverTimestampUSec) {
1929eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            final long wallclockMillisNow = System.currentTimeMillis();
1930eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            final long boottimeMillisNow = SystemClock.elapsedRealtime();
1931eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            final long driverTimestampMillis = driverTimestampUSec / USEC_PER_MSEC;
1932eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal
1933eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            long boottimeTimestampMillis = boottimeMillisNow % MAX_DRIVER_TIMESTAMP_MSEC;
1934eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            if (boottimeTimestampMillis < driverTimestampMillis) {
1935eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                // The 32-bit microsecond count has wrapped between the time that the driver
1936eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                // recorded the packet, and the call to this function. Adjust the BOOTTIME
1937eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                // timestamp, to compensate.
1938eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                //
1939eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                // Note that overflow is not a concern here, since the result is less than
1940eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                // 2 * MAX_DRIVER_TIMESTAMP_MSEC. (Given the modulus operation above,
1941eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                // boottimeTimestampMillis must be less than MAX_DRIVER_TIMESTAMP_MSEC.) And, since
1942eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                // MAX_DRIVER_TIMESTAMP_MSEC is an int, 2 * MAX_DRIVER_TIMESTAMP_MSEC must fit
1943eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                // within a long.
1944eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal                boottimeTimestampMillis += MAX_DRIVER_TIMESTAMP_MSEC;
1945eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            }
1946eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal
1947eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            final long millisSincePacketTimestamp = boottimeTimestampMillis - driverTimestampMillis;
1948eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal            return wallclockMillisNow - millisSincePacketTimestamp;
1949eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal        }
195009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    }
195109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal
195209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    /**
195309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal     * Represents the fate information for one outbound packet.
195409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal     */
195509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    @Immutable
195609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    public static final class TxFateReport extends FateReport {
195709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        TxFateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) {
195809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal            super(fate, driverTimestampUSec, frameType, frameBytes);
195909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        }
19600fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
19610fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        @Override
19620fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        protected String directionToString() {
19630fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            return "TX";
19640fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        }
19650fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
19660fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        @Override
19670fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        protected String fateToString() {
19680fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            switch (mFate) {
19690fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_ACKED:
19700fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "acked";
19710fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_SENT:
19720fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "sent";
19730fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_FW_QUEUED:
19740fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware queued";
19750fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_FW_DROP_INVALID:
19760fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware dropped (invalid frame)";
19770fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_FW_DROP_NOBUFS:
19780fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware dropped (no bufs)";
19790fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_FW_DROP_OTHER:
19800fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware dropped (other)";
19810fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_DRV_QUEUED:
19820fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver queued";
19830fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_INVALID:
19840fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver dropped (invalid frame)";
19850fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_NOBUFS:
19860fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver dropped (no bufs)";
19870fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_OTHER:
19880fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver dropped (other)";
19890fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                default:
19900fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return Byte.toString(mFate);
19910fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            }
19920fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        }
199309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    }
199409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal
199509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    /**
199609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal     * Represents the fate information for one inbound packet.
199709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal     */
199809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    @Immutable
199909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    public static final class RxFateReport extends FateReport {
200009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        RxFateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) {
200109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal            super(fate, driverTimestampUSec, frameType, frameBytes);
200209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal        }
20030fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
20040fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        @Override
20050fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        protected String directionToString() {
20060fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            return "RX";
20070fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        }
20080fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
20090fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        @Override
20100fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        protected String fateToString() {
20110fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            switch (mFate) {
20120fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_SUCCESS:
20130fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "success";
20140fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_FW_QUEUED:
20150fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware queued";
20160fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_FW_DROP_FILTER:
20170fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware dropped (filter)";
20180fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_FW_DROP_INVALID:
20190fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware dropped (invalid frame)";
20200fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_FW_DROP_NOBUFS:
20210fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware dropped (no bufs)";
20220fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_FW_DROP_OTHER:
20230fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "firmware dropped (other)";
20240fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_DRV_QUEUED:
20250fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver queued";
20260fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_FILTER:
20270fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver dropped (filter)";
20280fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_INVALID:
20290fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver dropped (invalid frame)";
20300fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_NOBUFS:
20310fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver dropped (no bufs)";
20320fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_OTHER:
20330fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return "driver dropped (other)";
20340fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                default:
20350fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal                    return Byte.toString(mFate);
20360fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal            }
20370fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal        }
203809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal    }
203909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal
20400fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    /**
20410fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal     * Ask the HAL to enable packet fate monitoring. Fails unless HAL is started.
2042b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
2043b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success, false otherwise.
20440fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal     */
20450fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    public boolean startPktFateMonitoring() {
2046b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.startPktFateMonitoring();
20470fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    }
20480fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
20490fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    /**
20500fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal     * Fetch the most recent TX packet fates from the HAL. Fails unless HAL is started.
2051b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
2052b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success, false otherwise.
20530fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal     */
20540fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    public boolean getTxPktFates(TxFateReport[] reportBufs) {
2055b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getTxPktFates(reportBufs);
20560fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    }
20570fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal
20580fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    /**
20590fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal     * Fetch the most recent RX packet fates from the HAL. Fails unless HAL is started.
20600fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal     */
20610fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    public boolean getRxPktFates(RxFateReport[] reportBufs) {
2062b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getRxPktFates(reportBufs);
20630fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal    }
206409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal
20655c3c06082b24f9ff0d479e82a63b52220c86598bRoshan Pius    /**
20669bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * Set the PNO settings & the network list in HAL to start PNO.
20679bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * @param settings PNO settings and network list.
20689bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * @param eventHandler Handler to receive notifications back during PNO scan.
20699bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * @return true if success, false otherwise
20705c3c06082b24f9ff0d479e82a63b52220c86598bRoshan Pius     */
20719bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    public boolean setPnoList(PnoSettings settings, PnoEventHandler eventHandler) {
2072b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        Log.e(mTAG, "setPnoList not supported");
2073b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return false;
2074dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle    }
2075dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle
20769bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    /**
20779bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * Reset the PNO settings in HAL to stop PNO.
20789bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     * @return true if success, false otherwise
20799bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius     */
20809bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius    public boolean resetPnoList() {
2081b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        Log.e(mTAG, "resetPnoList not supported");
2082b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return false;
2083d4c25fd76644d5490700ae69fada4669de5193a1Pierre Vandwalle    }
2084d4c25fd76644d5490700ae69fada4669de5193a1Pierre Vandwalle
2085b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
2086b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start sending the specified keep alive packets periodically.
2087b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
2088b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param slot Integer used to identify each request.
2089b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param keepAlivePacket Raw packet contents to send.
2090b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param period Period to use for sending these packets.
2091b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return 0 for success, -1 for error
2092b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
2093b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public int startSendingOffloadedPacket(int slot, KeepalivePacketData keepAlivePacket,
2094b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                                           int period) {
20953bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham        String[] macAddrStr = getMacAddress().split(":");
20963bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham        byte[] srcMac = new byte[6];
2097520fbe7db055661af039303c1081236c73b04abdRoshan Pius        for (int i = 0; i < 6; i++) {
20983bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham            Integer hexVal = Integer.parseInt(macAddrStr[i], 16);
20993bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham            srcMac[i] = hexVal.byteValue();
21003bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham        }
2101b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.startSendingOffloadedPacket(
2102b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                slot, srcMac, keepAlivePacket, period);
2103c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham    }
2104c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham
2105b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
2106b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Stop sending the specified keep alive packets.
2107b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
2108b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param slot id - same as startSendingOffloadedPacket call.
2109b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return 0 for success, -1 for error
2110b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
2111b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public int stopSendingOffloadedPacket(int slot) {
2112b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.stopSendingOffloadedPacket(slot);
2113c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham    }
2114aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham
2115aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham    public static interface WifiRssiEventHandler {
2116aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham        void onRssiThresholdBreached(byte curRssi);
2117aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham    }
2118aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham
2119b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
2120b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Start RSSI monitoring on the currently connected access point.
2121b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
2122b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param maxRssi          Maximum RSSI threshold.
2123b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param minRssi          Minimum RSSI threshold.
2124b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param rssiEventHandler Called when RSSI goes above maxRssi or below minRssi
2125b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return 0 for success, -1 for failure
2126b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
212718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public int startRssiMonitoring(byte maxRssi, byte minRssi,
2128b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                                   WifiRssiEventHandler rssiEventHandler) {
2129b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.startRssiMonitoring(maxRssi, minRssi, rssiEventHandler);
2130aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham    }
2131aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham
213218786eca942042388748b0d98979f21c9dff4a89Mitchell Wills    public int stopRssiMonitoring() {
2133b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.stopRssiMonitoring();
2134aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham    }
21355ea42964ba17901a8d724736b450ace6ed48880fPrerepa Viswanadham
21366bf6986d359556010638dfae332b585162f06520Roshan Pius    /**
21376bf6986d359556010638dfae332b585162f06520Roshan Pius     * Fetch the host wakeup reasons stats from wlan driver.
2138b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
21396bf6986d359556010638dfae332b585162f06520Roshan Pius     * @return the |WifiWakeReasonAndCounts| object retrieved from the wlan driver.
21406bf6986d359556010638dfae332b585162f06520Roshan Pius     */
21416bf6986d359556010638dfae332b585162f06520Roshan Pius    public WifiWakeReasonAndCounts getWlanWakeReasonCount() {
2142b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getWlanWakeReasonCount();
21436bf6986d359556010638dfae332b585162f06520Roshan Pius    }
21443dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline
2145b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
2146b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Enable/Disable Neighbour discovery offload functionality in the firmware.
2147b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
2148b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @param enabled true to enable, false to disable.
2149b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success, false otherwise.
2150b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
21513dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline    public boolean configureNeighborDiscoveryOffload(boolean enabled) {
2152b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.configureNeighborDiscoveryOffload(enabled);
21533dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline    }
2154da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan
2155da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    // Firmware roaming control.
2156da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan
2157da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    /**
2158da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     * Class to retrieve firmware roaming capability parameters.
2159da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     */
2160da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    public static class RoamingCapabilities {
2161da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan        public int  maxBlacklistSize;
2162da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan        public int  maxWhitelistSize;
2163da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    }
2164da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan
2165da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    /**
2166da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     * Query the firmware roaming capabilities.
2167b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return true for success, false otherwise.
2168da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     */
2169da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    public boolean getRoamingCapabilities(RoamingCapabilities capabilities) {
2170b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.getRoamingCapabilities(capabilities);
2171da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    }
2172da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan
2173da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    /**
2174da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     * Macros for controlling firmware roaming.
2175da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     */
2176da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    public static final int DISABLE_FIRMWARE_ROAMING = 0;
2177da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    public static final int ENABLE_FIRMWARE_ROAMING = 1;
2178da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan
2179da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    /**
2180da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     * Enable/disable firmware roaming.
2181b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     *
2182b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * @return error code returned from HAL.
2183da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     */
2184da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    public int enableFirmwareRoaming(int state) {
2185b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.enableFirmwareRoaming(state);
2186da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    }
2187da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan
2188da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    /**
2189da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     * Class for specifying the roaming configurations.
2190da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     */
2191da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    public static class RoamingConfig {
2192da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan        public ArrayList<String> blacklistBssids;
2193da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan        public ArrayList<String> whitelistSsids;
2194da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    }
2195da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan
2196da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    /**
2197da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     * Set firmware roaming configurations.
2198da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan     */
2199da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    public boolean configureRoaming(RoamingConfig config) {
2200b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        Log.d(mTAG, "configureRoaming ");
2201b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.configureRoaming(config);
2202da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    }
2203da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan
2204374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan    /**
2205374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan     * Reset firmware roaming configuration.
2206374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan     */
2207374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan    public boolean resetRoamingConfiguration() {
2208b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // Pass in an empty RoamingConfig object which translates to zero size
2209b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        // blacklist and whitelist to reset the firmware roaming configuration.
2210b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        return mWifiVendorHal.configureRoaming(new RoamingConfig());
2211b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    }
2212b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius
2213b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /********************************************************
2214b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * JNI operations
2215b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     ********************************************************/
2216b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /* Register native functions */
2217b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    static {
2218b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        /* Native functions are defined in libwifi-service.so */
2219b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        System.loadLibrary("wifi-service");
2220b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        registerNatives();
2221b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    }
2222b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius
2223b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    private static native int registerNatives();
2224b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /* kernel logging support */
2225b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    private static native byte[] readKernelLogNative();
2226b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius
2227b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    /**
2228b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     * Fetches the latest kernel logs.
2229b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius     */
2230b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius    public synchronized String readKernelLog() {
2231b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        byte[] bytes = readKernelLogNative();
2232b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius        if (bytes != null) {
2233b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();
2234b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            try {
2235b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                CharBuffer decoded = decoder.decode(ByteBuffer.wrap(bytes));
2236b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                return decoded.toString();
2237b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            } catch (CharacterCodingException cce) {
2238b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius                return new String(bytes, StandardCharsets.ISO_8859_1);
2239b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            }
2240520fbe7db055661af039303c1081236c73b04abdRoshan Pius        } else {
2241b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius            return "*** failed to read kernel log ***";
2242374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan        }
2243da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan    }
2244155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande}
2245