WifiNative.java revision 71c4c2a898a827a867564159ce78e41aedd2295b
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; 30f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalleimport android.os.SystemClock; 31155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport android.util.Log; 32ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Piusimport android.util.Pair; 33a26a8b33616c94859ba33f33403794cf636baa54Roshan Piusimport android.util.SparseArray; 34fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski 3509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawalimport com.android.internal.annotations.Immutable; 360fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport com.android.internal.util.HexDump; 37c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadhamimport com.android.server.connectivity.KeepalivePacketData; 38590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tanimport com.android.server.wifi.util.FrameParser; 39fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski 400fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport java.io.PrintWriter; 410fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport java.io.StringWriter; 425cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.ByteBuffer; 435cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.CharBuffer; 445cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.CharacterCodingException; 455cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.CharsetDecoder; 465cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.StandardCharsets; 47eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.text.SimpleDateFormat; 48155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport java.util.ArrayList; 49eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.util.Date; 50fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowskiimport java.util.Map; 511bf983a4211f547593a60523e43112ecdb5c8997Roshan Piusimport java.util.Objects; 529ec71f6499e0e3d6f52310a41ff4a59d2fa4f8b2Mitchell Willsimport java.util.Set; 53eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.util.TimeZone; 5418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills 55fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski 56155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande/** 57155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Native calls for bring up/shut down of the supplicant daemon and for 58155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * sending requests to the supplicant daemon 59155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 60155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * {@hide} 61155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 62155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandepublic class WifiNative { 6318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills private final String mTAG; 6418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills private final String mInterfaceName; 65b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private final SupplicantStaIfaceHal mSupplicantStaIfaceHal; 66b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private final WifiVendorHal mWifiVendorHal; 67b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private final WificondControl mWificondControl; 68b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 69b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public WifiNative(String interfaceName, WifiVendorHal vendorHal, 70163f9765f9e4c3f868b1e0d630b6adeaa115fb4aRoshan Pius SupplicantStaIfaceHal staIfaceHal, WificondControl condControl) { 71155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande mTAG = "WifiNative-" + interfaceName; 72b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mInterfaceName = interfaceName; 73b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWifiVendorHal = vendorHal; 74b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal = staIfaceHal; 75b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWificondControl = condControl; 76155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 77155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 7818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public String getInterfaceName() { 7918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills return mInterfaceName; 80e26ad459b63271548abbdeba4f8d77fcca9f88bdxinhe } 81e26ad459b63271548abbdeba4f8d77fcca9f88bdxinhe 82b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 83b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Enable verbose logging for all sub modules. 84b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 85b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public void enableVerboseLogging(int verbose) { 86b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWificondControl.enableVerboseLogging(verbose > 0 ? true : false); 87b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.enableVerboseLogging(verbose > 0); 88b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWifiVendorHal.enableVerboseLogging(verbose > 0); 89ed9938883ae2dade81c8be6cd6ceaef3febd5239vandwalle } 90ed9938883ae2dade81c8be6cd6ceaef3febd5239vandwalle 91b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 92b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Native Initialization/Deinitialization 93b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 94ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius public static final int SETUP_SUCCESS = 0; 95ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius public static final int SETUP_FAILURE_HAL = 1; 96ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius public static final int SETUP_FAILURE_WIFICOND = 2; 97155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 9870603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 993a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * Setup wifi native for Client mode operations. 1003a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1013a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1. Starts the Wifi HAL and configures it in client/STA mode. 1023a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 2. Setup Wificond to operate in client mode and retrieve the handle to use for client 1033a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * operations. 1043a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 105ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius * @return Pair of <Integer, IClientInterface> to indicate the status and the associated wificond 106ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius * client interface binder handler (will be null on failure). 10770603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang */ 108ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius public Pair<Integer, IClientInterface> setupForClientMode() { 1098131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius if (!startHalIfNecessary(true)) { 110b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Failed to start HAL for client mode"); 111ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius return Pair.create(SETUP_FAILURE_HAL, null); 11270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 113ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius IClientInterface iClientInterface = mWificondControl.setupDriverForClientMode(); 114ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius if (iClientInterface == null) { 115ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius return Pair.create(SETUP_FAILURE_WIFICOND, null); 116ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius } 117ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius return Pair.create(SETUP_SUCCESS, iClientInterface); 11870603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 119155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 12070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 1213a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * Setup wifi native for AP mode operations. 1223a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1233a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1. Starts the Wifi HAL and configures it in AP mode. 1243a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 2. Setup Wificond to operate in AP mode and retrieve the handle to use for ap operations. 1253a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 126ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius * @return Pair of <Integer, IApInterface> to indicate the status and the associated wificond 127ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius * AP interface binder handler (will be null on failure). 1283a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius */ 129ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius public Pair<Integer, IApInterface> setupForSoftApMode() { 1308131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius if (!startHalIfNecessary(false)) { 131b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Failed to start HAL for AP mode"); 132ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius return Pair.create(SETUP_FAILURE_HAL, null); 133ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius } 134ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius IApInterface iApInterface = mWificondControl.setupDriverForSoftApMode(); 135ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius if (iApInterface == null) { 136ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius return Pair.create(SETUP_FAILURE_WIFICOND, null); 13770603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 138ce1de180e7652e2b2313b401451ca3d9d027b372Roshan Pius return Pair.create(SETUP_SUCCESS, iApInterface); 13970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 14070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang 14170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 1423a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * Teardown all mode configurations in wifi native. 1433a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1448e03a147b1d9ca721e1fe4f95b6b67491cfd7084Etan Cohen * 1. Stops the Wifi HAL. 1458e03a147b1d9ca721e1fe4f95b6b67491cfd7084Etan Cohen * 2. Tears down all the interfaces from Wificond. 1463a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius */ 1477130816d6c62e07d6d41150805515d7fd56f1f0dRoshan Pius public void tearDown() { 1488e03a147b1d9ca721e1fe4f95b6b67491cfd7084Etan Cohen stopHalIfNecessary(); 1493a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius if (!mWificondControl.tearDownInterfaces()) { 1503a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius // TODO(b/34859006): Handle failures. 151b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Failed to teardown interfaces from Wificond"); 1523a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius } 15370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 15470603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang 155b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 156b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Wificond operations 157b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 158b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 159b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Result of a signal poll. 160b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 161b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static class SignalPollResult { 162b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // RSSI value in dBM. 163b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int currentRssi; 164b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius //Transmission bit rate in Mbps. 165b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int txBitrate; 166b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Association frequency in MHz. 167b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int associationFrequency; 168b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 169b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 170b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 171b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * WiFi interface transimission counters. 172b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 173b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static class TxPacketCounters { 174b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Number of successfully transmitted packets. 175b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int txSucceeded; 176b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Number of tramsmission failures. 177b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int txFailed; 178b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 179b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 18070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 18170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * Disable wpa_supplicant via wificond. 18270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * @return Returns true on success. 18370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang */ 18470603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang public boolean disableSupplicant() { 18570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang return mWificondControl.disableSupplicant(); 18670603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 18770603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang 18870603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 18970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * Enable wpa_supplicant via wificond. 19070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * @return Returns true on success. 19170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang */ 19270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang public boolean enableSupplicant() { 19370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang return mWificondControl.enableSupplicant(); 19470603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 19518786eca942042388748b0d98979f21c9dff4a89Mitchell Wills 196d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang /** 197d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Request signal polling to wificond. 198d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Returns an SignalPollResult object. 199d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Returns null on failure. 200d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang */ 201d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang public SignalPollResult signalPoll() { 202d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang return mWificondControl.signalPoll(); 203d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang } 204d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang 205d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang /** 206d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Fetch TX packet counters on current connection from wificond. 207d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Returns an TxPacketCounters object. 208d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Returns null on failure. 209d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang */ 210d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang public TxPacketCounters getTxPacketCounters() { 211d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang return mWificondControl.getTxPacketCounters(); 212d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang } 213d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang 21424250365afbd9a20b2e03364eddf2025c8f1138aRoshan Pius /** 215b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start a scan using wificond for the given parameters. 216b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param freqs list of frequencies to scan for, if null scan all supported channels. 217b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param hiddenNetworkSSIDs List of hidden networks to be scanned for. 218b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Returns true on success. 21924250365afbd9a20b2e03364eddf2025c8f1138aRoshan Pius */ 220b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean scan(Set<Integer> freqs, Set<String> hiddenNetworkSSIDs) { 221b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWificondControl.scan(freqs, hiddenNetworkSSIDs); 222155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 223155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 22418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills /** 225b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Fetch the latest scan result from kernel via wificond. 226b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Returns an ArrayList of ScanDetail. 227b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Returns an empty ArrayList on failure. 22818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills */ 229b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public ArrayList<ScanDetail> getScanResults() { 23071c4c2a898a827a867564159ce78e41aedd2295bSohani Rao return mWificondControl.getScanResults(WificondControl.SCAN_TYPE_SINGLE_SCAN); 23171c4c2a898a827a867564159ce78e41aedd2295bSohani Rao } 23271c4c2a898a827a867564159ce78e41aedd2295bSohani Rao 23371c4c2a898a827a867564159ce78e41aedd2295bSohani Rao /** 23471c4c2a898a827a867564159ce78e41aedd2295bSohani Rao * Fetch the latest scan result from kernel via wificond. 23571c4c2a898a827a867564159ce78e41aedd2295bSohani Rao * @return Returns an ArrayList of ScanDetail. 23671c4c2a898a827a867564159ce78e41aedd2295bSohani Rao * Returns an empty ArrayList on failure. 23771c4c2a898a827a867564159ce78e41aedd2295bSohani Rao */ 23871c4c2a898a827a867564159ce78e41aedd2295bSohani Rao public ArrayList<ScanDetail> getPnoScanResults() { 23971c4c2a898a827a867564159ce78e41aedd2295bSohani Rao return mWificondControl.getScanResults(WificondControl.SCAN_TYPE_PNO_SCAN); 240155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 241155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 242b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 243b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start PNO scan. 244b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param pnoSettings Pno scan configuration. 245b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success. 24618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills */ 247b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean startPnoScan(PnoSettings pnoSettings) { 248b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWificondControl.startPnoScan(pnoSettings); 249155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 250155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 251b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 252b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stop PNO scan. 253b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success. 254b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 255b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean stopPnoScan() { 256b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWificondControl.stopPnoScan(); 25718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills } 25818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills 259b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 260b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Supplicant operations 261b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 262f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius 263f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius /** 264b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * This method is called repeatedly until the connection to wpa_supplicant is established. 265f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius * 266b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if connection is established, false otherwise. 267b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * TODO: Add unit tests for these once we remove the legacy code. 268f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius */ 269163f9765f9e4c3f868b1e0d630b6adeaa115fb4aRoshan Pius public boolean connectToSupplicant() { 270b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Start initialization if not already started. 271b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (!mSupplicantStaIfaceHal.isInitializationStarted() 272b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && !mSupplicantStaIfaceHal.initialize()) { 273b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return false; 2745cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius } 275b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Check if the initialization is complete. 276b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.isInitializationComplete(); 277ad7319939c424d42fa6a3791c47f613db8ef3cd8vandwalle } 278ad7319939c424d42fa6a3791c47f613db8ef3cd8vandwalle 279b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 280b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Close supplicant connection. 281ed6a985c7b63e295248fa7e8292c99b48b7a4283Mitchell Wills */ 282b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public void closeSupplicantConnection() { 283b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Nothing to do for HIDL. 284155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 285155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 286782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski /** 287b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set supplicant log level 288782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski * 289b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param turnOnVerbose Whether to turn on verbose logging or not. 290782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski */ 291b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public void setSupplicantLogLevel(boolean turnOnVerbose) { 292f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius mSupplicantStaIfaceHal.setLogLevel(turnOnVerbose); 293e3831b70d4a8a967fe8df5496d542a432692c434Roshan Pius } 294e3831b70d4a8a967fe8df5496d542a432692c434Roshan Pius 29538a6c1ba5d461b8c7b11685c5dd2e98d9e106b55Roshan Pius /** 296b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Trigger a reconnection if the iface is disconnected. 297b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 298b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 29938a6c1ba5d461b8c7b11685c5dd2e98d9e106b55Roshan Pius */ 300b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean reconnect() { 301b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.reconnect(); 302f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle } 3039d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius 3049d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius /** 305b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Trigger a reassociation even if the iface is currently connected. 306b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 307b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 3089d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius */ 309155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean reassociate() { 310b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.reassociate(); 311155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 312155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 313155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 314b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Trigger a disconnection from the currently connected network. 315b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 316b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 317b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 318b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean disconnect() { 319b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.disconnect(); 32077f2b82a2e80af8da52c22d69a76def6d4209757Jan Nordqvist } 32177f2b82a2e80af8da52c22d69a76def6d4209757Jan Nordqvist 322155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 323b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Makes a callback to HIDL to getMacAddress from supplicant 324b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 325b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return string containing the MAC address, or null on a failed call 326b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 327b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public String getMacAddress() { 328b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.getMacAddress(); 329446db2d5457456743e4476029e14d7c3bb9f5bccYuhao Zheng } 330446db2d5457456743e4476029e14d7c3bb9f5bccYuhao Zheng 331f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int RX_FILTER_TYPE_V4_MULTICAST = 0; 332f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int RX_FILTER_TYPE_V6_MULTICAST = 1; 333155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 334155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Start filtering out Multicast V4 packets 335155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the operation succeeded, {@code false} otherwise 336155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 337155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Multicast filtering rules work as follows: 338155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 339155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * The driver can filter multicast (v4 and/or v6) and broadcast packets when in 340155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * a power optimized mode (typically when screen goes off). 341155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 342155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * In order to prevent the driver from filtering the multicast/broadcast packets, we have to 343155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * add a DRIVER RXFILTER-ADD rule followed by DRIVER RXFILTER-START to make the rule effective 344155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 345155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * DRIVER RXFILTER-ADD Num 346155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * where Num = 0 - Unicast, 1 - Broadcast, 2 - Mutil4 or 3 - Multi6 347155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 348155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * and DRIVER RXFILTER-START 349155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * In order to stop the usage of these rules, we do 350155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 351155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * DRIVER RXFILTER-STOP 352155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * DRIVER RXFILTER-REMOVE Num 353155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * where Num is as described for RXFILTER-ADD 354155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 355155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * The SETSUSPENDOPT driver command overrides the filtering rules 356155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 357155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startFilteringMulticastV4Packets() { 358b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.stopRxFilter() 359b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.removeRxFilter( 360f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius RX_FILTER_TYPE_V4_MULTICAST) 361b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.startRxFilter(); 362155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 363155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 364155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 365155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Stop filtering out Multicast V4 packets. 366155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the operation succeeded, {@code false} otherwise 367155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 368155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean stopFilteringMulticastV4Packets() { 369b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.stopRxFilter() 370b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.addRxFilter( 371f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius RX_FILTER_TYPE_V4_MULTICAST) 372b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.startRxFilter(); 373155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 374155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 375155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 376155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Start filtering out Multicast V6 packets 377155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the operation succeeded, {@code false} otherwise 378155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 379155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startFilteringMulticastV6Packets() { 380b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.stopRxFilter() 381b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.removeRxFilter( 382f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius RX_FILTER_TYPE_V6_MULTICAST) 383b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.startRxFilter(); 384155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 385155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 386155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 387155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Stop filtering out Multicast V6 packets. 388155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the operation succeeded, {@code false} otherwise 389155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 390155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean stopFilteringMulticastV6Packets() { 391b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.stopRxFilter() 392b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.addRxFilter( 393f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius RX_FILTER_TYPE_V6_MULTICAST) 394b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.startRxFilter(); 395155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 396155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 397f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int BLUETOOTH_COEXISTENCE_MODE_ENABLED = 0; 398f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int BLUETOOTH_COEXISTENCE_MODE_DISABLED = 1; 399f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int BLUETOOTH_COEXISTENCE_MODE_SENSE = 2; 4007ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde /** 4017ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * Sets the bluetooth coexistence mode. 4027ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * 4037ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * @param mode One of {@link #BLUETOOTH_COEXISTENCE_MODE_DISABLED}, 4047ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * {@link #BLUETOOTH_COEXISTENCE_MODE_ENABLED}, or 4057ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * {@link #BLUETOOTH_COEXISTENCE_MODE_SENSE}. 4067ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * @return Whether the mode was successfully set. 4077ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde */ 408155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setBluetoothCoexistenceMode(int mode) { 409f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius return mSupplicantStaIfaceHal.setBtCoexistenceMode(mode); 410155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 411155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 412155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 413155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Enable or disable Bluetooth coexistence scan mode. When this mode is on, 414155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * some of the low-level scan parameters used by the driver are changed to 415155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * reduce interference with A2DP streaming. 416155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 417cc180872c51908b15ce5cbf834634ff323e036bcChristopher Wiley * @param setCoexScanMode whether to enable or disable this mode 418155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the command succeeded, {@code false} otherwise. 419155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 420155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setBluetoothCoexistenceScanMode(boolean setCoexScanMode) { 421b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setBtCoexistenceScanModeEnabled(setCoexScanMode); 422155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 423155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 424b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 425b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Enable or disable suspend mode optimizations. 426b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 427b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param enabled true to enable, false otherwise. 428b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 429b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 430155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setSuspendOptimizations(boolean enabled) { 431b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setSuspendModeEnabled(enabled); 432155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 433155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 4349153bd67d51b305ffdd61355e0748e3c332c2cafRoshan Pius /** 435b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set country code. 436b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 437b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param countryCode 2 byte ASCII string. For ex: US, CA. 438b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 4399153bd67d51b305ffdd61355e0748e3c332c2cafRoshan Pius */ 440b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setCountryCode(String countryCode) { 441b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setCountryCode(countryCode); 44204c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang } 44304c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang 44404c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang /** 445b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Initiate TDLS discover and setup or teardown with the specified peer. 446b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 447b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param macAddr MAC Address of the peer. 448b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param enable true to start discovery and setup, false to teardown. 44904c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang */ 450155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public void startTdls(String macAddr, boolean enable) { 451b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (enable) { 452b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.initiateTdlsDiscover(macAddr); 453b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.initiateTdlsSetup(macAddr); 454155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } else { 455b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.initiateTdlsTeardown(macAddr); 456155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 457155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 458155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 459b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 460b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start WPS pin display operation with the specified peer. 461b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 462b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the peer. 463b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 464b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 465155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startWpsPbc(String bssid) { 466b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.startWpsPbc(bssid); 467155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 468155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 469b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 470b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start WPS pin keypad operation with the specified pin. 471b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 472b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param pin Pin to be used. 473b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 474b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 475155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startWpsPinKeypad(String pin) { 476b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.startWpsPinKeypad(pin); 477155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 478155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 479b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 480b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start WPS pin display operation with the specified peer. 481b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 482b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the peer. 483b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return new pin generated on success, null otherwise. 484b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 485155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public String startWpsPinDisplay(String bssid) { 486b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.startWpsPinDisplay(bssid); 487155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 488155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 489b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 490b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Sets whether to use external sim for SIM/USIM processing. 491b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 492b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param external true to enable, false otherwise. 493b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 494b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 49533b575ca6bee66183929f9474b5a161432918604Vinit Deshpande public boolean setExternalSim(boolean external) { 496b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setExternalSim(external); 49733b575ca6bee66183929f9474b5a161432918604Vinit Deshpande } 49833b575ca6bee66183929f9474b5a161432918604Vinit Deshpande 499b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 500b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Sim auth response types. 501b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 502b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static final String SIM_AUTH_RESP_TYPE_GSM_AUTH = "GSM-AUTH"; 503b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static final String SIM_AUTH_RESP_TYPE_UMTS_AUTH = "UMTS-AUTH"; 504b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static final String SIM_AUTH_RESP_TYPE_UMTS_AUTS = "UMTS-AUTS"; 505b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 506b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 507b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Send the sim auth response for the currently configured network. 508b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 509b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param type |GSM-AUTH|, |UMTS-AUTH| or |UMTS-AUTS|. 510b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param response Response params. 511b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if succeeds, false otherwise. 512b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 513f97140d51d14ce0659d381f443c08dbd94dfea28Honore Tricot public boolean simAuthResponse(int id, String type, String response) { 514b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (SIM_AUTH_RESP_TYPE_GSM_AUTH.equals(type)) { 515b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimGsmAuthResponse(response); 516b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } else if (SIM_AUTH_RESP_TYPE_UMTS_AUTH.equals(type)) { 517b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAuthResponse(response); 518b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } else if (SIM_AUTH_RESP_TYPE_UMTS_AUTS.equals(type)) { 519b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAutsResponse(response); 5205cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius } else { 521b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return false; 5225cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius } 52333b575ca6bee66183929f9474b5a161432918604Vinit Deshpande } 52433b575ca6bee66183929f9474b5a161432918604Vinit Deshpande 525b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 526b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Send the eap sim gsm auth failure for the currently configured network. 527b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 528b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if succeeds, false otherwise. 529b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 53026eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande public boolean simAuthFailedResponse(int id) { 531b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimGsmAuthFailure(); 53226eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande } 53326eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande 534b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 535b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Send the eap sim umts auth failure for the currently configured network. 536b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 537b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if succeeds, false otherwise. 538b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 53926eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande public boolean umtsAuthFailedResponse(int id) { 540b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAuthFailure(); 54126eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande } 54226eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande 543b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 544b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Send the eap identity response for the currently configured network. 545b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 546b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param response String to send. 547b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if succeeds, false otherwise. 548b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 549ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot public boolean simIdentityResponse(int id, String response) { 550b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapIdentityResponse(response); 551ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot } 552ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot 553b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 554a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang * This get anonymous identity from supplicant and returns it as a string. 555a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang * 556a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang * @return anonymous identity string if succeeds, null otherwise. 557a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang */ 558a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang public String getEapAnonymousIdentity() { 559a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang return mSupplicantStaIfaceHal.getCurrentNetworkEapAnonymousIdentity(); 560a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang } 561a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang 562a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang /** 563b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start WPS pin registrar operation with the specified peer and pin. 564b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 565b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the peer. 566b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param pin Pin to be used. 567b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 568b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 569155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startWpsRegistrar(String bssid, String pin) { 570b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.startWpsRegistrar(bssid, pin); 571155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 572155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 573b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 574b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Cancels any ongoing WPS requests. 575b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 576b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 577b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 578155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean cancelWps() { 579b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.cancelWps(); 580155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 581155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 582b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 583b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS device name. 584b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 585b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param name String to be set. 586b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 587b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 588155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setDeviceName(String name) { 589b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsDeviceName(name); 590155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 591155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 592b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 593b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS device type. 594b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 595b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param type Type specified as a string. Used format: <categ>-<OUI>-<subcateg> 596b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 597b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 598155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setDeviceType(String type) { 599b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsDeviceType(type); 600155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 601155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 602b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 603b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS config methods 604b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 605b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param cfg List of config methods. 606b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 607b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 608155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setConfigMethods(String cfg) { 609b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsConfigMethods(cfg); 610155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 611155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 612b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 613b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS manufacturer. 614b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 615b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param value String to be set. 616b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 617b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 618155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setManufacturer(String value) { 619b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsManufacturer(value); 620155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 621155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 622b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 623b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS model name. 624b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 625b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param value String to be set. 626b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 627b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 628155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setModelName(String value) { 629b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsModelName(value); 630155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 631155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 632b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 633b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS model number. 634b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 635b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param value String to be set. 636b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 637b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 638155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setModelNumber(String value) { 639b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsModelNumber(value); 640155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 641155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 642b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 643b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS serial number. 644b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 645b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param value String to be set. 646b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 647b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 648155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setSerialNumber(String value) { 649b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsSerialNumber(value); 650155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 651155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 652b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 653b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Enable or disable power save mode. 654b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 655b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param enabled true to enable, false to disable. 656b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 657155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public void setPowerSave(boolean enabled) { 658b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.setPowerSave(enabled); 659155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 660155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 661b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 662b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set concurrency priority between P2P & STA operations. 663b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 664b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param isStaHigherPriority Set to true to prefer STA over P2P during concurrency operations, 665b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * false otherwise. 666b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 667b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 668b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setConcurrencyPriority(boolean isStaHigherPriority) { 669b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setConcurrencyPriority(isStaHigherPriority); 670155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 671155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 672155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 6733e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius * Enable/Disable auto reconnect functionality in wpa_supplicant. 6743e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius * 6753e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius * @param enable true to enable auto reconnecting, false to disable. 6763e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius * @return true if request is sent successfully, false otherwise. 6773e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius */ 6783e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius public boolean enableStaAutoReconnect(boolean enable) { 6793e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius return mSupplicantStaIfaceHal.enableAutoReconnect(enable); 6803e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius } 6813e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius 6823e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius /** 683b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Migrate all the configured networks from wpa_supplicant. 684b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 685b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param configs Map of configuration key to configuration objects corresponding to all 686b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * the networks. 687b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param networkExtras Map of extra configuration parameters stored in wpa_supplicant.conf 688b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Max priority of all the configs. 689155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 690b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean migrateNetworksFromSupplicant(Map<String, WifiConfiguration> configs, 691b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius SparseArray<Map<String, String>> networkExtras) { 692b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.loadNetworks(configs, networkExtras); 693155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 694155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 695b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 696b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Add the provided network configuration to wpa_supplicant and initiate connection to it. 697b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * This method does the following: 698c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 1. Abort any ongoing scan to unblock the connection request. 699c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 2. Remove any existing network in wpa_supplicant(This implicitly triggers disconnect). 700c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 3. Add a new network to wpa_supplicant. 701c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 4. Save the provided configuration to wpa_supplicant. 702c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 5. Select the new network in wpa_supplicant. 703c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 6. Triggers reconnect command to wpa_supplicant. 704b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 705b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param configuration WifiConfiguration parameters for the provided network. 706b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return {@code true} if it succeeds, {@code false} otherwise 707b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 708a5936a61582404692c6046e3b496d3b1d22a94cbNingyuan Wang public boolean connectToNetwork(WifiConfiguration configuration) { 709c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang // Abort ongoing scan before connect() to unblock connection request. 710c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang mWificondControl.abortScan(); 711a5936a61582404692c6046e3b496d3b1d22a94cbNingyuan Wang return mSupplicantStaIfaceHal.connectToNetwork(configuration); 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). 718c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 1. Abort any ongoing scan to unblock the roam request. 719c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 2. First check if we're attempting to connect to the same network as we currently have 720b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * configured. 721c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 3. Set the new bssid for the network in wpa_supplicant. 722c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 4. Triggers reassociate command to wpa_supplicant. 723b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 724b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param configuration WifiConfiguration parameters for the provided network. 725b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return {@code true} if it succeeds, {@code false} otherwise 726b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 727b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean roamToNetwork(WifiConfiguration configuration) { 728c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang // Abort ongoing scan before connect() to unblock roaming request. 729c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang mWificondControl.abortScan(); 730b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.roamToNetwork(configuration); 731155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 732155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 733b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 734b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Get the framework network ID corresponding to the provided supplicant network ID for the 735b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * network configured in wpa_supplicant. 736b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 737b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param supplicantNetworkId network ID in wpa_supplicant for the network. 738b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Corresponding framework network ID if found, -1 if network not found. 739b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 740b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int getFrameworkNetworkId(int supplicantNetworkId) { 741b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return supplicantNetworkId; 742155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 743155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 744b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 745b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Remove all the networks. 746b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 747b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return {@code true} if it succeeds, {@code false} otherwise 748b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 749b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean removeAllNetworks() { 750b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.removeAllNetworks(); 751155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 752155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 753b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 754b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set the BSSID for the currently configured network in wpa_supplicant. 755b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 756b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if successful, false otherwise. 757b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 758b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setConfiguredNetworkBSSID(String bssid) { 759b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setCurrentNetworkBssid(bssid); 760155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 761155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 762b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 763b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Initiate ANQP query. 764b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 765b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the AP to be queried 766b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param anqpIds Set of anqp IDs. 767b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param hs20Subtypes Set of HS20 subtypes. 768b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 769b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 770b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean requestAnqp(String bssid, Set<Integer> anqpIds, Set<Integer> hs20Subtypes) { 771b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (bssid == null || ((anqpIds == null || anqpIds.isEmpty()) 772b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && (hs20Subtypes == null || hs20Subtypes.isEmpty()))) { 773b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Invalid arguments for ANQP request."); 774155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande return false; 775155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 776b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ArrayList<Short> anqpIdList = new ArrayList<>(); 777b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius for (Integer anqpId : anqpIds) { 778b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius anqpIdList.add(anqpId.shortValue()); 77961233efc46707ace6cb3a45dd84766f06df946afTomasz Wiszkowski } 780b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ArrayList<Integer> hs20SubtypeList = new ArrayList<>(); 781b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius hs20SubtypeList.addAll(hs20Subtypes); 782b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.initiateAnqpQuery(bssid, anqpIdList, hs20SubtypeList); 783155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 784155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 785b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 786b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Request a passpoint icon file |filename| from the specified AP |bssid|. 787b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the AP 788b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param fileName name of the icon file 789b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise 790b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 791b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean requestIcon(String bssid, String fileName) { 792b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (bssid == null || fileName == null) { 793b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Invalid arguments for Icon request."); 79461233efc46707ace6cb3a45dd84766f06df946afTomasz Wiszkowski return false; 795155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 796b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.initiateHs20IconQuery(bssid, fileName); 797155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 798155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 799b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 800b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Get the currently configured network's WPS NFC token. 801b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 802b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Hex string corresponding to the WPS NFC token. 803b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 804ba3f5bc64ef27f2ec0d3eae3f53c633ea9e66268Amin Shaikh public String getCurrentNetworkWpsNfcConfigurationToken() { 805b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.getCurrentNetworkWpsNfcConfigurationToken(); 806155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 807403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang 808403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang /** Remove the request |networkId| from supplicant if it's the current network, 809403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang * if the current configured network matches |networkId|. 810403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang * 811403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang * @param networkId network id of the network to be removed from supplicant. 812403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang */ 813403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang public void removeNetworkIfCurrent(int networkId) { 814403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang mSupplicantStaIfaceHal.removeNetworkIfCurrent(networkId); 815403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang } 816403df479e25031276c738dbea334f09bb7e4bf37Ningyuan Wang 817b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 818b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Vendor HAL operations 819b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 820af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius /** 821af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius * Callback to notify vendor HAL death. 822af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius */ 823af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius public interface VendorHalDeathEventHandler { 824af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius /** 825af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius * Invoked when the vendor HAL dies. 826af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius */ 827af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius void onDeath(); 828af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius } 829b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 830d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius /** 831520fbe7db055661af039303c1081236c73b04abdRoshan Pius * Initializes the vendor HAL. This is just used to initialize the {@link HalDeviceManager}. 832520fbe7db055661af039303c1081236c73b04abdRoshan Pius */ 833af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius public boolean initializeVendorHal(VendorHalDeathEventHandler handler) { 834af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius return mWifiVendorHal.initialize(handler); 835520fbe7db055661af039303c1081236c73b04abdRoshan Pius } 836520fbe7db055661af039303c1081236c73b04abdRoshan Pius 837520fbe7db055661af039303c1081236c73b04abdRoshan Pius /** 8388131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius * Bring up the Vendor HAL and configure for STA mode or AP mode, if vendor HAL is supported. 839d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius * 840d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius * @param isStaMode true to start HAL in STA mode, false to start in AP mode. 8418131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius * @return false if the HAL start fails, true if successful or if vendor HAL not supported. 842d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius */ 8438131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius private boolean startHalIfNecessary(boolean isStaMode) { 8448131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius if (!mWifiVendorHal.isVendorHalSupported()) { 8458131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius Log.i(mTAG, "Vendor HAL not supported, Ignore start..."); 8468131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius return true; 8478131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius } 848b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startVendorHal(isStaMode); 8497ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde } 8507ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde 851b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 8528131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius * Stops the HAL, if vendor HAL is supported. 853b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 8548131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius private void stopHalIfNecessary() { 8558131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius if (!mWifiVendorHal.isVendorHalSupported()) { 8568131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius Log.i(mTAG, "Vendor HAL not supported, Ignore stop..."); 8578131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius return; 8588131b04dc799cb0c75240c7b9eb0517ba1f00be8Roshan Pius } 859b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWifiVendorHal.stopVendorHal(); 8607ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde } 8617f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 862b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 863b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Tests whether the HAL is running or not 864b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 86518786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean isHalStarted() { 866b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.isHalStarted(); 8677f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde } 8687f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 869062e3f39e37874fedc01f267de5f4cf7dbebe2b4Randy Pan // TODO: Change variable names to camel style. 870e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public static class ScanCapabilities { 871297c3acabe7a85eb87240fe3ccf772e57ce6aef7Mitchell Wills public int max_scan_cache_size; 872e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public int max_scan_buckets; 873e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public int max_ap_cache_per_scan; 874e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public int max_rssi_sample_size; 875297c3acabe7a85eb87240fe3ccf772e57ce6aef7Mitchell Wills public int max_scan_reporting_threshold; 876e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 877e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 878b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 879b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Gets the scan capabilities 880b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 881b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param capabilities object to be filled in 882b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success. false for failure 883b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 8846ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public boolean getBgScanCapabilities(ScanCapabilities capabilities) { 8856ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass return mWifiVendorHal.getBgScanCapabilities(capabilities); 886e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 887e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 888e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public static class ChannelSettings { 889712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int frequency; 890712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int dwell_time_ms; 891712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public boolean passive; 8927f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde } 8937f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 894e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public static class BucketSettings { 895712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int bucket; 896712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int band; 897712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int period_ms; 898712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int max_period_ms; 899712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int step_count; 900712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int report_events; 901712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int num_channels; 902712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public ChannelSettings[] channels; 903e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 9047f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 9056259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius /** 9066259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius * Network parameters for hidden networks to be scanned for. 9076259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius */ 9086259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius public static class HiddenNetwork { 9096259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius public String ssid; 9106259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius 9116259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius @Override 9126259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius public boolean equals(Object otherObj) { 9136259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius if (this == otherObj) { 9146259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius return true; 9156259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius } else if (otherObj == null || getClass() != otherObj.getClass()) { 9166259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius return false; 9176259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius } 9186259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius HiddenNetwork other = (HiddenNetwork) otherObj; 9196259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius return Objects.equals(ssid, other.ssid); 9206259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius } 921ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh 922ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh @Override 923ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh public int hashCode() { 924ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh return (ssid == null ? 0 : ssid.hashCode()); 925ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh } 9266259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius } 9276259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius 928e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public static class ScanSettings { 929712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int base_period_ms; 930712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int max_ap_per_scan; 931712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int report_threshold_percent; 932712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int report_threshold_num_scans; 933712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int num_buckets; 9346259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius /* Not used for bg scans. Only works for single scans. */ 9356259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius public HiddenNetwork[] hiddenNetworks; 936712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public BucketSettings[] buckets; 937e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 9387f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 93968cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang /** 9409bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Network parameters to start PNO scan. 9419bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 9429bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public static class PnoNetwork { 9439bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public String ssid; 9449bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public byte flags; 945ef3ea1092bc17673c0a85a845b053151b7c10e07Roshan Pius public byte auth_bit_field; 9461bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius 9471bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius @Override 9481bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius public boolean equals(Object otherObj) { 9491bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius if (this == otherObj) { 9501bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius return true; 9511bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius } else if (otherObj == null || getClass() != otherObj.getClass()) { 9521bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius return false; 9531bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius } 9541bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius PnoNetwork other = (PnoNetwork) otherObj; 9556259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius return ((Objects.equals(ssid, other.ssid)) && (flags == other.flags) 9561bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius && (auth_bit_field == other.auth_bit_field)); 9571bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius } 958ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh 959ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh @Override 960ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh public int hashCode() { 961ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh int result = (ssid == null ? 0 : ssid.hashCode()); 962ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh result ^= ((int) flags * 31) + ((int) auth_bit_field << 8); 963ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh return result; 964ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh } 9659bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius } 9669bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius 9679bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius /** 9689bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Parameters to start PNO scan. This holds the list of networks which are going to used for 9699bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * PNO scan. 9709bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 9719bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public static class PnoSettings { 9729bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int min5GHzRssi; 9739bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int min24GHzRssi; 9749bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int initialScoreMax; 9759bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int currentConnectionBonus; 9769bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int sameNetworkBonus; 9779bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int secureBonus; 9789bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int band5GHzBonus; 97904c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang public int periodInMs; 980dcd877d6c143db557884993ea437e2a432cb0ba3Roshan Pius public boolean isConnected; 9819bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public PnoNetwork[] networkList; 9829bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius } 9839bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius 984b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande public static interface ScanEventHandler { 98563539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills /** 98663539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Called for each AP as it is found with the entire contents of the beacon/probe response. 98763539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Only called when WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT is specified. 98863539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills */ 989c9e6069eb941d282af213dc20b171877db6b567bMitchell Wills void onFullScanResult(ScanResult fullScanResult, int bucketsScanned); 99063539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills /** 99163539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Callback on an event during a gscan scan. 99263539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * See WifiNative.WIFI_SCAN_* for possible values. 99363539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills */ 99463539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills void onScanStatus(int event); 99563539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills /** 99663539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Called with the current cached scan results when gscan is paused. 99763539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills */ 99883a674a18c84ff4f01377bbfd8988699dec93bc2Vinit Deshpande void onScanPaused(WifiScanner.ScanData[] data); 99963539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills /** 100063539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Called with the current cached scan results when gscan is resumed. 100163539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills */ 1002b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande void onScanRestarted(); 1003e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 1004e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 10059bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius /** 10069bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Handler to notify the occurrence of various events during PNO scan. 10079bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 10089bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public interface PnoEventHandler { 10099bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius /** 10109bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Callback to notify when one of the shortlisted networks is found during PNO scan. 10119bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @param results List of Scan results received. 10129bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 10139bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius void onPnoNetworkFound(ScanResult[] results); 1014063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius 1015063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius /** 1016063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius * Callback to notify when the PNO scan schedule fails. 1017063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius */ 1018063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius void onPnoScanFailed(); 10199bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius } 10209bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius 102171af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills public static final int WIFI_SCAN_RESULTS_AVAILABLE = 0; 102271af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills public static final int WIFI_SCAN_THRESHOLD_NUM_SCANS = 1; 102371af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills public static final int WIFI_SCAN_THRESHOLD_PERCENT = 2; 102471af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills public static final int WIFI_SCAN_FAILED = 3; 1025b7cc309f06da8a18224057c21ba086f8550367d6Vinit Deshpande 1026b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1027b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Starts a background scan. 1028b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Any ongoing scan will be stopped first 1029b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1030b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param settings to control the scan 1031b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param eventHandler to call with the results 1032b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success 1033b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10346ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public boolean startBgScan(ScanSettings settings, ScanEventHandler eventHandler) { 10356ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass return mWifiVendorHal.startBgScan(settings, eventHandler); 10367f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde } 10377f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 1038b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1039b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stops any ongoing backgound scan 1040b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10416ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public void stopBgScan() { 10426ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass mWifiVendorHal.stopBgScan(); 1043b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande } 1044b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande 1045b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1046b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Pauses an ongoing backgound scan 1047b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10486ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public void pauseBgScan() { 10496ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass mWifiVendorHal.pauseBgScan(); 1050b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande } 1051b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande 1052b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1053b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Restarts a paused scan 1054b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10556ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public void restartBgScan() { 10566ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass mWifiVendorHal.restartBgScan(); 1057e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 1058e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 1059b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1060b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Gets the latest scan results received. 1061b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10626ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public WifiScanner.ScanData[] getBgScanResults() { 10636ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass return mWifiVendorHal.getBgScanResults(); 1064e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 1065e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 106618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public WifiLinkLayerStats getWifiLinkLayerStats(String iface) { 1067b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getWifiLinkLayerStats(); 10685c08cc119b92af69997af194cc8b6d0111e37d31Andres Morales } 10695c08cc119b92af69997af194cc8b6d0111e37d31Andres Morales 1070b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1071b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Get the supported features 1072b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1073b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return bitmask defined by WifiManager.WIFI_FEATURE_* 1074b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 107518786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public int getSupportedFeatureSet() { 1076b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getSupportedFeatureSet(); 1077a632d8a6edd350c7644b593b18eceaa5b368505bVinit Deshpande } 1078143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande 1079143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande public static interface RttEventHandler { 1080143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande void onRttResults(RttManager.RttResult[] result); 1081143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande } 1082143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande 1083b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1084b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Starts a new rtt request 1085b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1086b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param params RTT request params. Refer to {@link RttManager#RttParams}. 1087b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param handler Callback to be invoked to notify any results. 1088b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if the request was successful, false otherwise. 1089b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 109018786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean requestRtt( 1091143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande RttManager.RttParams[] params, RttEventHandler handler) { 1092b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.requestRtt(params, handler); 1093143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande } 1094143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande 1095b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1096b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Cancels an outstanding rtt request 1097b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1098b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param params RTT request params. Refer to {@link RttManager#RttParams} 1099b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if there was an outstanding request and it was successfully cancelled 1100b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 110118786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean cancelRtt(RttManager.RttParams[] params) { 1102b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.cancelRtt(params); 1103143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande } 1104042c54bfd5144ce8e720585b2093796e7e28de5eVinit Deshpande 110568cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang /** 110668cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang * Enable RTT responder role on the device. Returns {@link ResponderConfig} if the responder 110768cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang * role is successfully enabled, {@code null} otherwise. 1108b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1109b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param timeoutSeconds timeout to use for the responder. 111068cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang */ 111168cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang @Nullable 1112b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public ResponderConfig enableRttResponder(int timeoutSeconds) { 1113b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.enableRttResponder(timeoutSeconds); 111412cf388ecf3b2aa5ba66ed680b931fa356ab75b5xinhe } 1115939177ff615062ec826601d536466875d8457375xinhe 1116b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1117b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Disable RTT responder role. Returns {@code true} if responder role is successfully disabled, 1118b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * {@code false} otherwise. 1119b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1120b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean disableRttResponder() { 1121b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.disableRttResponder(); 11226609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen } 11236609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen 1124b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1125b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set the MAC OUI during scanning. 1126b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * An OUI {Organizationally Unique Identifier} is a 24-bit number that 1127b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * uniquely identifies a vendor or manufacturer. 1128b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1129b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param oui OUI to set. 1130b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success 1131b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1132b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setScanningMacOui(byte[] oui) { 1133b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.setScanningMacOui(oui); 11346609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen } 11356609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen 1136b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1137b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Query the list of valid frequencies for the provided band. 1138b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * The result depends on the on the country code that has been set. 1139b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1140b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param band as specified by one of the WifiScanner.WIFI_BAND_* constants. 1141b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return frequencies vector of valid frequencies (MHz), or null for error. 1142b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @throws IllegalArgumentException if band is not recognized. 1143b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1144b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int [] getChannelsForBand(int band) { 1145b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getChannelsForBand(band); 1146939177ff615062ec826601d536466875d8457375xinhe } 1147939177ff615062ec826601d536466875d8457375xinhe 1148b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1149b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Indicates whether getChannelsForBand is supported. 1150b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1151b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if it is. 1152b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1153b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean isGetChannelsForBandSupported() { 1154b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.isGetChannelsForBandSupported(); 1155d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1156d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1157b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1158b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * RTT (Round Trip Time) measurement capabilities of the device. 1159b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1160b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public RttManager.RttCapabilities getRttCapabilities() { 1161b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRttCapabilities(); 1162d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1163d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1164b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1165b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Get the APF (Android Packet Filter) capabilities of the device 1166b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1167b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public ApfCapabilities getApfCapabilities() { 1168b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getApfCapabilities(); 1169d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1170d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1171b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1172b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Installs an APF program on this iface, replacing any existing program. 1173b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1174b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param filter is the android packet filter program 1175b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success 1176b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1177b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean installPacketFilter(byte[] filter) { 1178b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.installPacketFilter(filter); 1179d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1180d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1181b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1182b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set country code for this AP iface. 1183b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1184b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param countryCode - two-letter country code (as ISO 3166) 1185b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success 1186b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1187b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setCountryCodeHal(String countryCode) { 1188b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.setCountryCodeHal(countryCode); 1189d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1190d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1191a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle //--------------------------------------------------------------------------------- 1192a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle /* Wifi Logger commands/events */ 1193a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle public static interface WifiLoggerEventHandler { 11940bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande void onRingBufferData(RingBufferStatus status, byte[] buffer); 11950bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande void onWifiAlert(int errorCode, byte[] buffer); 1196a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle } 1197a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle 1198b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1199b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Registers the logger callback and enables alerts. 1200b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Ring buffer data collection is only triggered when |startLoggingRingBuffer| is invoked. 1201b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1202b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param handler Callback to be invoked. 1203b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 1204b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 120518786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean setLoggingEventHandler(WifiLoggerEventHandler handler) { 1206b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.setLoggingEventHandler(handler); 120703ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 120803ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1209b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1210b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Control debug data collection 1211b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1212b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param verboseLevel 0 to 3, inclusive. 0 stops logging. 1213b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param flags Ignored. 1214b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param maxInterval Maximum interval between reports; ignore if 0. 1215b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param minDataSize Minimum data size in buffer for report; ignore if 0. 1216b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param ringName Name of the ring for which data collection is to start. 1217b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 1218b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 121918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean startLoggingRingBuffer(int verboseLevel, int flags, int maxInterval, 122003ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe int minDataSize, String ringName){ 1221b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startLoggingRingBuffer( 1222b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius verboseLevel, flags, maxInterval, minDataSize, ringName); 122303ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 122403ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1225b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1226b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Logger features exposed. 1227b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * This is a no-op now, will always return -1. 1228b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1229b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 1230b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 123118786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public int getSupportedLoggerFeatureSet() { 1232b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getSupportedLoggerFeatureSet(); 123303ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 123403ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1235b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1236b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stops all logging and resets the logger callback. 1237b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * This stops both the alerts and ring buffer data collection. 1238b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 1239b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 124018786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean resetLogHandler() { 1241b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.resetLogHandler(); 1242b797893fc1966803d0c013faac42e6396a37a384xinhe } 1243b797893fc1966803d0c013faac42e6396a37a384xinhe 1244b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1245b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Vendor-provided wifi driver version string 1246b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1247b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return String returned from the HAL. 1248b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 124918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public String getDriverVersion() { 1250b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getDriverVersion(); 125103ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 125203ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1253b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1254b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Vendor-provided wifi firmware version string 1255b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1256b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return String returned from the HAL. 1257b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 125818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public String getFirmwareVersion() { 1259b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getFirmwareVersion(); 126003ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 126103ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 12620bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande public static class RingBufferStatus{ 12630bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande String name; 12640bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int flag; 12650bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int ringBufferId; 12660bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int ringBufferByteSize; 12670bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int verboseLevel; 12680bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int writtenBytes; 12690bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int readBytes; 12700bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int writtenRecords; 12710bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande 127253f278b6fed422a18d763b07216a21e96d9445f9Michael Plass // Bit masks for interpreting |flag| 127353f278b6fed422a18d763b07216a21e96d9445f9Michael Plass public static final int HAS_BINARY_ENTRIES = (1 << 0); 127453f278b6fed422a18d763b07216a21e96d9445f9Michael Plass public static final int HAS_ASCII_ENTRIES = (1 << 1); 127553f278b6fed422a18d763b07216a21e96d9445f9Michael Plass public static final int HAS_PER_PACKET_ENTRIES = (1 << 2); 127653f278b6fed422a18d763b07216a21e96d9445f9Michael Plass 12770bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande @Override 12780bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande public String toString() { 12790bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande return "name: " + name + " flag: " + flag + " ringBufferId: " + ringBufferId + 12800bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande " ringBufferByteSize: " +ringBufferByteSize + " verboseLevel: " +verboseLevel + 12810bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande " writtenBytes: " + writtenBytes + " readBytes: " + readBytes + 12820bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande " writtenRecords: " + writtenRecords; 12830bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande } 12840bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande } 12850bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande 1286b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1287b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * API to get the status of all ring buffers supported by driver 1288b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 128918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public RingBufferStatus[] getRingBufferStatus() { 1290b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRingBufferStatus(); 129103ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 129203ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1293b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1294b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Indicates to driver that all the data has to be uploaded urgently 1295b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1296b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param ringName Name of the ring buffer requested. 1297b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 1298b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 129918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean getRingBufferData(String ringName) { 1300b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRingBufferData(ringName); 130103ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 1302127f7244183786e6ccae09e81eeccdac31973e69xinhe 1303b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1304b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Request vendor debug info from the firmware 1305b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1306b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Raw data obtained from the HAL. 1307b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 130818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public byte[] getFwMemoryDump() { 1309b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getFwMemoryDump(); 1310a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle } 1311dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle 1312b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1313b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Request vendor debug info from the driver 1314b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1315b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Raw data obtained from the HAL. 1316b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1317d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal public byte[] getDriverStateDump() { 1318b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getDriverStateDump(); 1319d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal } 1320d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal 1321dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle //--------------------------------------------------------------------------------- 132209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal /* Packet fate API */ 132309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 132409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal @Immutable 132509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal abstract static class FateReport { 1326eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final static int USEC_PER_MSEC = 1000; 1327eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // The driver timestamp is a 32-bit counter, in microseconds. This field holds the 1328eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // maximal value of a driver timestamp in milliseconds. 1329eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final static int MAX_DRIVER_TIMESTAMP_MSEC = (int) (0xffffffffL / 1000); 1330eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final static SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss.SSS"); 1331eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal 133209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal final byte mFate; 133309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal final long mDriverTimestampUSec; 133409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal final byte mFrameType; 133509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal final byte[] mFrameBytes; 1336eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long mEstimatedWallclockMSec; 133709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 133809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal FateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) { 133909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal mFate = fate; 134009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal mDriverTimestampUSec = driverTimestampUSec; 1341eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal mEstimatedWallclockMSec = 1342eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal convertDriverTimestampUSecToWallclockMSec(mDriverTimestampUSec); 134309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal mFrameType = frameType; 134409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal mFrameBytes = frameBytes; 134509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 13460fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 1347590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan public String toTableRowString() { 1348590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan StringWriter sw = new StringWriter(); 1349590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan PrintWriter pw = new PrintWriter(sw); 1350590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan FrameParser parser = new FrameParser(mFrameType, mFrameBytes); 1351eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal dateFormatter.setTimeZone(TimeZone.getDefault()); 1352eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal pw.format("%-15s %12s %-9s %-32s %-12s %-23s %s\n", 1353eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal mDriverTimestampUSec, 1354eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal dateFormatter.format(new Date(mEstimatedWallclockMSec)), 1355eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal directionToString(), fateToString(), parser.mMostSpecificProtocolString, 1356eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal parser.mTypeString, parser.mResultString); 1357590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan return sw.toString(); 1358590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan } 1359590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan 1360590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan public String toVerboseStringWithPiiAllowed() { 13610fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal StringWriter sw = new StringWriter(); 13620fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal PrintWriter pw = new PrintWriter(sw); 1363590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan FrameParser parser = new FrameParser(mFrameType, mFrameBytes); 13640fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame direction: %s\n", directionToString()); 13650fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame timestamp: %d\n", mDriverTimestampUSec); 13660fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame fate: %s\n", fateToString()); 13670fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame type: %s\n", frameTypeToString(mFrameType)); 1368590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan pw.format("Frame protocol: %s\n", parser.mMostSpecificProtocolString); 1369590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan pw.format("Frame protocol type: %s\n", parser.mTypeString); 13700fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame length: %d\n", mFrameBytes.length); 13710fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.append("Frame bytes"); 1372590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan pw.append(HexDump.dumpHexString(mFrameBytes)); // potentially contains PII 13730fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.append("\n"); 13740fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return sw.toString(); 13750fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 13760fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 1377590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan /* Returns a header to match the output of toTableRowString(). */ 1378590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan public static String getTableHeader() { 1379590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan StringWriter sw = new StringWriter(); 1380590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan PrintWriter pw = new PrintWriter(sw); 1381eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal pw.format("\n%-15s %-12s %-9s %-32s %-12s %-23s %s\n", 1382eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal "Time usec", "Walltime", "Direction", "Fate", "Protocol", "Type", "Result"); 1383eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal pw.format("%-15s %-12s %-9s %-32s %-12s %-23s %s\n", 1384eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal "---------", "--------", "---------", "----", "--------", "----", "------"); 1385590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan return sw.toString(); 1386590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan } 1387590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan 13880fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected abstract String directionToString(); 13890fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 13900fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected abstract String fateToString(); 13910fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 13920fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal private static String frameTypeToString(byte frameType) { 13930fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal switch (frameType) { 13940fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.FRAME_TYPE_UNKNOWN: 13950fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "unknown"; 13960fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.FRAME_TYPE_ETHERNET_II: 13970fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "data"; 13980fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.FRAME_TYPE_80211_MGMT: 13990fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "802.11 management"; 14000fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal default: 14010fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return Byte.toString(frameType); 14020fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14030fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 1404eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal 1405eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal /** 1406eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal * Converts a driver timestamp to a wallclock time, based on the current 1407eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal * BOOTTIME to wallclock mapping. The driver timestamp is a 32-bit counter of 1408eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal * microseconds, with the same base as BOOTTIME. 1409eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal */ 1410eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal private static long convertDriverTimestampUSecToWallclockMSec(long driverTimestampUSec) { 1411eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long wallclockMillisNow = System.currentTimeMillis(); 1412eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long boottimeMillisNow = SystemClock.elapsedRealtime(); 1413eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long driverTimestampMillis = driverTimestampUSec / USEC_PER_MSEC; 1414eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal 1415eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal long boottimeTimestampMillis = boottimeMillisNow % MAX_DRIVER_TIMESTAMP_MSEC; 1416eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal if (boottimeTimestampMillis < driverTimestampMillis) { 1417eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // The 32-bit microsecond count has wrapped between the time that the driver 1418eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // recorded the packet, and the call to this function. Adjust the BOOTTIME 1419eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // timestamp, to compensate. 1420eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // 1421eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // Note that overflow is not a concern here, since the result is less than 1422eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // 2 * MAX_DRIVER_TIMESTAMP_MSEC. (Given the modulus operation above, 1423eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // boottimeTimestampMillis must be less than MAX_DRIVER_TIMESTAMP_MSEC.) And, since 1424eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // MAX_DRIVER_TIMESTAMP_MSEC is an int, 2 * MAX_DRIVER_TIMESTAMP_MSEC must fit 1425eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // within a long. 1426eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal boottimeTimestampMillis += MAX_DRIVER_TIMESTAMP_MSEC; 1427eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal } 1428eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal 1429eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long millisSincePacketTimestamp = boottimeTimestampMillis - driverTimestampMillis; 1430eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal return wallclockMillisNow - millisSincePacketTimestamp; 1431eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal } 143209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 143309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 143409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal /** 143509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal * Represents the fate information for one outbound packet. 143609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal */ 143709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal @Immutable 143809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal public static final class TxFateReport extends FateReport { 143909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal TxFateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) { 144009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal super(fate, driverTimestampUSec, frameType, frameBytes); 144109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 14420fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14430fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal @Override 14440fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected String directionToString() { 14450fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "TX"; 14460fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14470fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14480fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal @Override 14490fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected String fateToString() { 14500fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal switch (mFate) { 14510fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_ACKED: 14520fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "acked"; 14530fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_SENT: 14540fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "sent"; 14550fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_FW_QUEUED: 14560fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware queued"; 14570fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_FW_DROP_INVALID: 14580fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (invalid frame)"; 14590fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_FW_DROP_NOBUFS: 14600fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (no bufs)"; 14610fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_FW_DROP_OTHER: 14620fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (other)"; 14630fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_DRV_QUEUED: 14640fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver queued"; 14650fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_INVALID: 14660fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (invalid frame)"; 14670fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_NOBUFS: 14680fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (no bufs)"; 14690fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_OTHER: 14700fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (other)"; 14710fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal default: 14720fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return Byte.toString(mFate); 14730fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14740fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 147509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 147609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 147709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal /** 147809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal * Represents the fate information for one inbound packet. 147909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal */ 148009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal @Immutable 148109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal public static final class RxFateReport extends FateReport { 148209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal RxFateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) { 148309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal super(fate, driverTimestampUSec, frameType, frameBytes); 148409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 14850fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14860fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal @Override 14870fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected String directionToString() { 14880fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "RX"; 14890fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14900fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14910fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal @Override 14920fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected String fateToString() { 14930fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal switch (mFate) { 14940fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_SUCCESS: 14950fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "success"; 14960fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_QUEUED: 14970fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware queued"; 14980fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_DROP_FILTER: 14990fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (filter)"; 15000fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_DROP_INVALID: 15010fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (invalid frame)"; 15020fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_DROP_NOBUFS: 15030fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (no bufs)"; 15040fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_DROP_OTHER: 15050fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (other)"; 15060fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_QUEUED: 15070fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver queued"; 15080fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_FILTER: 15090fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (filter)"; 15100fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_INVALID: 15110fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (invalid frame)"; 15120fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_NOBUFS: 15130fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (no bufs)"; 15140fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_OTHER: 15150fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (other)"; 15160fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal default: 15170fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return Byte.toString(mFate); 15180fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 15190fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 152009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 152109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 15220fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal /** 15230fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal * Ask the HAL to enable packet fate monitoring. Fails unless HAL is started. 1524b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1525b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 15260fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal */ 15270fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal public boolean startPktFateMonitoring() { 1528b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startPktFateMonitoring(); 15290fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 15300fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 15310fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal /** 15320fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal * Fetch the most recent TX packet fates from the HAL. Fails unless HAL is started. 1533b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1534b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 15350fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal */ 15360fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal public boolean getTxPktFates(TxFateReport[] reportBufs) { 1537b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getTxPktFates(reportBufs); 15380fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 15390fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 15400fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal /** 15410fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal * Fetch the most recent RX packet fates from the HAL. Fails unless HAL is started. 15420fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal */ 15430fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal public boolean getRxPktFates(RxFateReport[] reportBufs) { 1544b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRxPktFates(reportBufs); 15450fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 154609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 15475c3c06082b24f9ff0d479e82a63b52220c86598bRoshan Pius /** 15489bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Set the PNO settings & the network list in HAL to start PNO. 15499bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @param settings PNO settings and network list. 15509bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @param eventHandler Handler to receive notifications back during PNO scan. 15519bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @return true if success, false otherwise 15525c3c06082b24f9ff0d479e82a63b52220c86598bRoshan Pius */ 15539bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public boolean setPnoList(PnoSettings settings, PnoEventHandler eventHandler) { 1554b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "setPnoList not supported"); 1555b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return false; 1556dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle } 1557dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle 15589bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius /** 15599bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Reset the PNO settings in HAL to stop PNO. 15609bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @return true if success, false otherwise 15619bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 15629bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public boolean resetPnoList() { 1563b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "resetPnoList not supported"); 1564b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return false; 1565d4c25fd76644d5490700ae69fada4669de5193a1Pierre Vandwalle } 1566d4c25fd76644d5490700ae69fada4669de5193a1Pierre Vandwalle 1567b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1568b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start sending the specified keep alive packets periodically. 1569b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1570b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param slot Integer used to identify each request. 1571b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param keepAlivePacket Raw packet contents to send. 1572b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param period Period to use for sending these packets. 1573b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return 0 for success, -1 for error 1574b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1575b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int startSendingOffloadedPacket(int slot, KeepalivePacketData keepAlivePacket, 1576b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius int period) { 15773bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham String[] macAddrStr = getMacAddress().split(":"); 15783bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham byte[] srcMac = new byte[6]; 1579520fbe7db055661af039303c1081236c73b04abdRoshan Pius for (int i = 0; i < 6; i++) { 15803bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham Integer hexVal = Integer.parseInt(macAddrStr[i], 16); 15813bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham srcMac[i] = hexVal.byteValue(); 15823bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham } 1583b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startSendingOffloadedPacket( 1584b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius slot, srcMac, keepAlivePacket, period); 1585c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham } 1586c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham 1587b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1588b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stop sending the specified keep alive packets. 1589b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1590b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param slot id - same as startSendingOffloadedPacket call. 1591b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return 0 for success, -1 for error 1592b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1593b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int stopSendingOffloadedPacket(int slot) { 1594b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.stopSendingOffloadedPacket(slot); 1595c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham } 1596aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham 1597aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham public static interface WifiRssiEventHandler { 1598aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham void onRssiThresholdBreached(byte curRssi); 1599aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham } 1600aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham 1601b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1602b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start RSSI monitoring on the currently connected access point. 1603b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1604b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param maxRssi Maximum RSSI threshold. 1605b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param minRssi Minimum RSSI threshold. 1606b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param rssiEventHandler Called when RSSI goes above maxRssi or below minRssi 1607b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return 0 for success, -1 for failure 1608b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 160918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public int startRssiMonitoring(byte maxRssi, byte minRssi, 1610b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius WifiRssiEventHandler rssiEventHandler) { 1611b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startRssiMonitoring(maxRssi, minRssi, rssiEventHandler); 1612aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham } 1613aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham 161418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public int stopRssiMonitoring() { 1615b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.stopRssiMonitoring(); 1616aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham } 16175ea42964ba17901a8d724736b450ace6ed48880fPrerepa Viswanadham 16186bf6986d359556010638dfae332b585162f06520Roshan Pius /** 16196bf6986d359556010638dfae332b585162f06520Roshan Pius * Fetch the host wakeup reasons stats from wlan driver. 1620b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 16216bf6986d359556010638dfae332b585162f06520Roshan Pius * @return the |WifiWakeReasonAndCounts| object retrieved from the wlan driver. 16226bf6986d359556010638dfae332b585162f06520Roshan Pius */ 16236bf6986d359556010638dfae332b585162f06520Roshan Pius public WifiWakeReasonAndCounts getWlanWakeReasonCount() { 1624b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getWlanWakeReasonCount(); 16256bf6986d359556010638dfae332b585162f06520Roshan Pius } 16263dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline 1627b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1628b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Enable/Disable Neighbour discovery offload functionality in the firmware. 1629b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1630b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param enabled true to enable, false to disable. 1631b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 1632b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 16333dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline public boolean configureNeighborDiscoveryOffload(boolean enabled) { 1634b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.configureNeighborDiscoveryOffload(enabled); 16353dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline } 1636da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1637da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan // Firmware roaming control. 1638da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1639da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1640da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Class to retrieve firmware roaming capability parameters. 1641da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1642da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public static class RoamingCapabilities { 1643da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public int maxBlacklistSize; 1644da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public int maxWhitelistSize; 1645da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1646da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1647da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1648da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Query the firmware roaming capabilities. 1649b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 1650da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1651da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public boolean getRoamingCapabilities(RoamingCapabilities capabilities) { 1652b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRoamingCapabilities(capabilities); 1653da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1654da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1655da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1656da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Macros for controlling firmware roaming. 1657da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1658da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public static final int DISABLE_FIRMWARE_ROAMING = 0; 1659da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public static final int ENABLE_FIRMWARE_ROAMING = 1; 1660da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1661da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1662da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Enable/disable firmware roaming. 1663b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1664b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return error code returned from HAL. 1665da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1666da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public int enableFirmwareRoaming(int state) { 1667b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.enableFirmwareRoaming(state); 1668da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1669da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1670da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1671da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Class for specifying the roaming configurations. 1672da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1673da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public static class RoamingConfig { 1674da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public ArrayList<String> blacklistBssids; 1675da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public ArrayList<String> whitelistSsids; 1676da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1677da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1678da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1679da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Set firmware roaming configurations. 1680da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1681da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public boolean configureRoaming(RoamingConfig config) { 1682b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.d(mTAG, "configureRoaming "); 1683b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.configureRoaming(config); 1684da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1685da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1686374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan /** 1687374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan * Reset firmware roaming configuration. 1688374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan */ 1689374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan public boolean resetRoamingConfiguration() { 1690b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Pass in an empty RoamingConfig object which translates to zero size 1691b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // blacklist and whitelist to reset the firmware roaming configuration. 1692b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.configureRoaming(new RoamingConfig()); 1693b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 1694b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 1695ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius /** 1696b7f35c58029fe5dce64813271ad4e8b1b6ea8893Roshan Pius * Tx power level scenarios that can be selected. 1697ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius */ 1698b7f35c58029fe5dce64813271ad4e8b1b6ea8893Roshan Pius public static final int TX_POWER_SCENARIO_NORMAL = 0; 1699b7f35c58029fe5dce64813271ad4e8b1b6ea8893Roshan Pius public static final int TX_POWER_SCENARIO_VOICE_CALL = 1; 1700ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius 1701ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius /** 1702b7f35c58029fe5dce64813271ad4e8b1b6ea8893Roshan Pius * Select one of the pre-configured TX power level scenarios or reset it back to normal. 1703ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius * Primarily used for meeting SAR requirements during voice calls. 1704ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius * 1705b7f35c58029fe5dce64813271ad4e8b1b6ea8893Roshan Pius * @param scenario Should be one {@link #TX_POWER_SCENARIO_NORMAL} or 1706b7f35c58029fe5dce64813271ad4e8b1b6ea8893Roshan Pius * {@link #TX_POWER_SCENARIO_VOICE_CALL}. 1707ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius * @return true for success; false for failure or if the HAL version does not support this API. 1708ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius */ 1709b7f35c58029fe5dce64813271ad4e8b1b6ea8893Roshan Pius public boolean selectTxPowerScenario(int scenario) { 1710b7f35c58029fe5dce64813271ad4e8b1b6ea8893Roshan Pius return mWifiVendorHal.selectTxPowerScenario(scenario); 1711ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius } 1712ba89009ba7554d5073c0b93c04f167c3a11667faRoshan Pius 1713b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 1714b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * JNI operations 1715b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 1716b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /* Register native functions */ 1717b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius static { 1718b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /* Native functions are defined in libwifi-service.so */ 1719b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius System.loadLibrary("wifi-service"); 1720b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius registerNatives(); 1721b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 1722b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 1723b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private static native int registerNatives(); 1724b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /* kernel logging support */ 1725b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private static native byte[] readKernelLogNative(); 1726b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 1727b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1728b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Fetches the latest kernel logs. 1729b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1730b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public synchronized String readKernelLog() { 1731b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius byte[] bytes = readKernelLogNative(); 1732b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (bytes != null) { 1733b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder(); 1734b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius try { 1735b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius CharBuffer decoded = decoder.decode(ByteBuffer.wrap(bytes)); 1736b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return decoded.toString(); 1737b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } catch (CharacterCodingException cce) { 1738b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return new String(bytes, StandardCharsets.ISO_8859_1); 1739b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 1740520fbe7db055661af039303c1081236c73b04abdRoshan Pius } else { 1741b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return "*** failed to read kernel log ***"; 1742374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan } 1743da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1744155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande} 1745