WifiNative.java revision c4ad341e844e88a34be7ed4c3c9509fb72608b37
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; 32a26a8b33616c94859ba33f33403794cf636baa54Roshan Piusimport android.util.SparseArray; 33fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski 3409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawalimport com.android.internal.annotations.Immutable; 350fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport com.android.internal.util.HexDump; 36c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadhamimport com.android.server.connectivity.KeepalivePacketData; 37590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tanimport com.android.server.wifi.util.FrameParser; 38fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski 390fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport java.io.PrintWriter; 400fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawalimport java.io.StringWriter; 415cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.ByteBuffer; 425cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.CharBuffer; 435cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.CharacterCodingException; 445cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.CharsetDecoder; 455cfd8d8b9f241dcad874125a1b5538ee0d6860fexinheimport java.nio.charset.StandardCharsets; 46eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.text.SimpleDateFormat; 47155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandeimport java.util.ArrayList; 48eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.util.Date; 49fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowskiimport java.util.Map; 501bf983a4211f547593a60523e43112ecdb5c8997Roshan Piusimport java.util.Objects; 519ec71f6499e0e3d6f52310a41ff4a59d2fa4f8b2Mitchell Willsimport java.util.Set; 52eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawalimport java.util.TimeZone; 5318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills 54fbb081b7c28c18f0644701061a1ab38a4627db27Bartosz Fabianowski 55155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande/** 56155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Native calls for bring up/shut down of the supplicant daemon and for 57155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * sending requests to the supplicant daemon 58155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 59155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * {@hide} 60155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 61155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpandepublic class WifiNative { 6218786eca942042388748b0d98979f21c9dff4a89Mitchell Wills private final String mTAG; 6318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills private final String mInterfaceName; 64b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private final SupplicantStaIfaceHal mSupplicantStaIfaceHal; 65b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private final WifiVendorHal mWifiVendorHal; 66b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private final WificondControl mWificondControl; 67b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 68b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public WifiNative(String interfaceName, WifiVendorHal vendorHal, 69163f9765f9e4c3f868b1e0d630b6adeaa115fb4aRoshan Pius SupplicantStaIfaceHal staIfaceHal, WificondControl condControl) { 70155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande mTAG = "WifiNative-" + interfaceName; 71b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mInterfaceName = interfaceName; 72b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWifiVendorHal = vendorHal; 73b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal = staIfaceHal; 74b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWificondControl = condControl; 75155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 76155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 7718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public String getInterfaceName() { 7818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills return mInterfaceName; 79e26ad459b63271548abbdeba4f8d77fcca9f88bdxinhe } 80e26ad459b63271548abbdeba4f8d77fcca9f88bdxinhe 81b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 82b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Enable verbose logging for all sub modules. 83b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 84b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public void enableVerboseLogging(int verbose) { 85b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWificondControl.enableVerboseLogging(verbose > 0 ? true : false); 86b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.enableVerboseLogging(verbose > 0); 87b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWifiVendorHal.enableVerboseLogging(verbose > 0); 88ed9938883ae2dade81c8be6cd6ceaef3febd5239vandwalle } 89ed9938883ae2dade81c8be6cd6ceaef3febd5239vandwalle 90b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 91b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Native Initialization/Deinitialization 92b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 93155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 9470603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 953a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * Setup wifi native for Client mode operations. 963a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 973a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1. Starts the Wifi HAL and configures it in client/STA mode. 983a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 2. Setup Wificond to operate in client mode and retrieve the handle to use for client 993a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * operations. 1003a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 10170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * @return An IClientInterface as wificond client interface binder handler. 10270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * Returns null on failure. 10370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang */ 1043a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius public IClientInterface setupForClientMode() { 10570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang if (!startHal(true)) { 10670603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang // TODO(b/34859006): Handle failures. 107b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Failed to start HAL for client mode"); 10870603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 1093a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius return mWificondControl.setupDriverForClientMode(); 11070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 111155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 11270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 1133a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * Setup wifi native for AP mode operations. 1143a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1153a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1. Starts the Wifi HAL and configures it in AP mode. 1163a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 2. Setup Wificond to operate in AP mode and retrieve the handle to use for ap operations. 1173a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1183a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * @return An IApInterface as wificond Ap interface binder handler. 1193a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * Returns null on failure. 1203a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius */ 1213a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius public IApInterface setupForSoftApMode() { 12270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang if (!startHal(false)) { 12370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang // TODO(b/34859006): Handle failures. 124b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Failed to start HAL for AP mode"); 12570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 1263a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius return mWificondControl.setupDriverForSoftApMode(); 12770603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 12870603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang 12970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 1303a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * Teardown all mode configurations in wifi native. 1313a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1323a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1. Tears down all the interfaces from Wificond. 1333a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 2. Stops the Wifi HAL. 1343a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * 1353a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius * @return Returns true on success. 1363a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius */ 1373a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius public boolean tearDown() { 1383a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius if (!mWificondControl.tearDownInterfaces()) { 1393a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius // TODO(b/34859006): Handle failures. 140b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Failed to teardown interfaces from Wificond"); 1413a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius return false; 1423a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius } 1433a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius stopHal(); 1443a0679d411c5eb889d38ed32181446c82d5bd825Roshan Pius return true; 14570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 14670603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang 147b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 148b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Wificond operations 149b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 150b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 151b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Result of a signal poll. 152b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 153b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static class SignalPollResult { 154b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // RSSI value in dBM. 155b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int currentRssi; 156b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius //Transmission bit rate in Mbps. 157b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int txBitrate; 158b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Association frequency in MHz. 159b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int associationFrequency; 160b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 161b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 162b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 163b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * WiFi interface transimission counters. 164b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 165b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static class TxPacketCounters { 166b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Number of successfully transmitted packets. 167b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int txSucceeded; 168b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Number of tramsmission failures. 169b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int txFailed; 170b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 171b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 17270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 17370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * Disable wpa_supplicant via wificond. 17470603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * @return Returns true on success. 17570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang */ 17670603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang public boolean disableSupplicant() { 17770603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang return mWificondControl.disableSupplicant(); 17870603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 17970603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang 18070603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang /** 18170603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * Enable wpa_supplicant via wificond. 18270603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang * @return Returns true on success. 18370603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang */ 18470603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang public boolean enableSupplicant() { 18570603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang return mWificondControl.enableSupplicant(); 18670603901b67c48202ecbb1818e59d487bbcceedaNingyuan Wang } 18718786eca942042388748b0d98979f21c9dff4a89Mitchell Wills 188d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang /** 189d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Request signal polling to wificond. 190d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Returns an SignalPollResult object. 191d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Returns null on failure. 192d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang */ 193d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang public SignalPollResult signalPoll() { 194d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang return mWificondControl.signalPoll(); 195d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang } 196d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang 197d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang /** 198d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Fetch TX packet counters on current connection from wificond. 199d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Returns an TxPacketCounters object. 200d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang * Returns null on failure. 201d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang */ 202d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang public TxPacketCounters getTxPacketCounters() { 203d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang return mWificondControl.getTxPacketCounters(); 204d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang } 205d45b46b01f8562219468291bdc19363f0540ced0Ningyuan Wang 20624250365afbd9a20b2e03364eddf2025c8f1138aRoshan Pius /** 207b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start a scan using wificond for the given parameters. 208b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param freqs list of frequencies to scan for, if null scan all supported channels. 209b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param hiddenNetworkSSIDs List of hidden networks to be scanned for. 210b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Returns true on success. 21124250365afbd9a20b2e03364eddf2025c8f1138aRoshan Pius */ 212b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean scan(Set<Integer> freqs, Set<String> hiddenNetworkSSIDs) { 213b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWificondControl.scan(freqs, hiddenNetworkSSIDs); 214155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 215155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 21618786eca942042388748b0d98979f21c9dff4a89Mitchell Wills /** 217b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Fetch the latest scan result from kernel via wificond. 218b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Returns an ArrayList of ScanDetail. 219b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Returns an empty ArrayList on failure. 22018786eca942042388748b0d98979f21c9dff4a89Mitchell Wills */ 221b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public ArrayList<ScanDetail> getScanResults() { 222b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWificondControl.getScanResults(); 223155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 224155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 225b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 226b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start PNO scan. 227b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param pnoSettings Pno scan configuration. 228b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success. 22918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills */ 230b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean startPnoScan(PnoSettings pnoSettings) { 231b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWificondControl.startPnoScan(pnoSettings); 232155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 233155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 234b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 235b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stop PNO scan. 236b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success. 237b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 238b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean stopPnoScan() { 239b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWificondControl.stopPnoScan(); 24018786eca942042388748b0d98979f21c9dff4a89Mitchell Wills } 24118786eca942042388748b0d98979f21c9dff4a89Mitchell Wills 242b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 243b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Supplicant operations 244b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 245f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius 246f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius /** 247b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * This method is called repeatedly until the connection to wpa_supplicant is established. 248f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius * 249b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if connection is established, false otherwise. 250b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * TODO: Add unit tests for these once we remove the legacy code. 251f3aae0be78cd02f5fedd7d99b73536d2c799b030Roshan Pius */ 252163f9765f9e4c3f868b1e0d630b6adeaa115fb4aRoshan Pius public boolean connectToSupplicant() { 253b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Start initialization if not already started. 254b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (!mSupplicantStaIfaceHal.isInitializationStarted() 255b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && !mSupplicantStaIfaceHal.initialize()) { 256b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return false; 2575cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius } 258b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Check if the initialization is complete. 259b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.isInitializationComplete(); 260ad7319939c424d42fa6a3791c47f613db8ef3cd8vandwalle } 261ad7319939c424d42fa6a3791c47f613db8ef3cd8vandwalle 262b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 263b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Close supplicant connection. 264ed6a985c7b63e295248fa7e8292c99b48b7a4283Mitchell Wills */ 265b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public void closeSupplicantConnection() { 266b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Nothing to do for HIDL. 267155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 268155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 269782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski /** 270b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set supplicant log level 271782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski * 272b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param turnOnVerbose Whether to turn on verbose logging or not. 273782eac0bacec797262eb4d721ad58cfcf2fbf885Tomasz Wiszkowski */ 274b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public void setSupplicantLogLevel(boolean turnOnVerbose) { 275f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius mSupplicantStaIfaceHal.setLogLevel(turnOnVerbose); 276e3831b70d4a8a967fe8df5496d542a432692c434Roshan Pius } 277e3831b70d4a8a967fe8df5496d542a432692c434Roshan Pius 27838a6c1ba5d461b8c7b11685c5dd2e98d9e106b55Roshan Pius /** 279b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Trigger a reconnection if the iface is disconnected. 280b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 281b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 28238a6c1ba5d461b8c7b11685c5dd2e98d9e106b55Roshan Pius */ 283b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean reconnect() { 284b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.reconnect(); 285f22d23092ab37286a5ef9d257d5bb32c421d2669vandwalle } 2869d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius 2879d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius /** 288b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Trigger a reassociation even if the iface is currently connected. 289b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 290b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 2919d7489491984e86915b2cf4fac38a882de1c8cdbRoshan Pius */ 292155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean reassociate() { 293b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.reassociate(); 294155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 295155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 296155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 297b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Trigger a disconnection from the currently connected network. 298b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 299b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 300b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 301b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean disconnect() { 302b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.disconnect(); 30377f2b82a2e80af8da52c22d69a76def6d4209757Jan Nordqvist } 30477f2b82a2e80af8da52c22d69a76def6d4209757Jan Nordqvist 305155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 306b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Makes a callback to HIDL to getMacAddress from supplicant 307b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 308b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return string containing the MAC address, or null on a failed call 309b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 310b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public String getMacAddress() { 311b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.getMacAddress(); 312446db2d5457456743e4476029e14d7c3bb9f5bccYuhao Zheng } 313446db2d5457456743e4476029e14d7c3bb9f5bccYuhao Zheng 314f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int RX_FILTER_TYPE_V4_MULTICAST = 0; 315f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int RX_FILTER_TYPE_V6_MULTICAST = 1; 316155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 317155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Start filtering out Multicast V4 packets 318155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the operation succeeded, {@code false} otherwise 319155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 320155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Multicast filtering rules work as follows: 321155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 322155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * The driver can filter multicast (v4 and/or v6) and broadcast packets when in 323155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * a power optimized mode (typically when screen goes off). 324155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 325155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * In order to prevent the driver from filtering the multicast/broadcast packets, we have to 326155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * add a DRIVER RXFILTER-ADD rule followed by DRIVER RXFILTER-START to make the rule effective 327155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 328155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * DRIVER RXFILTER-ADD Num 329155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * where Num = 0 - Unicast, 1 - Broadcast, 2 - Mutil4 or 3 - Multi6 330155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 331155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * and DRIVER RXFILTER-START 332155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * In order to stop the usage of these rules, we do 333155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 334155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * DRIVER RXFILTER-STOP 335155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * DRIVER RXFILTER-REMOVE Num 336155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * where Num is as described for RXFILTER-ADD 337155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 338155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * The SETSUSPENDOPT driver command overrides the filtering rules 339155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 340155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startFilteringMulticastV4Packets() { 341b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.stopRxFilter() 342b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.removeRxFilter( 343f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius RX_FILTER_TYPE_V4_MULTICAST) 344b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.startRxFilter(); 345155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 346155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 347155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 348155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Stop filtering out Multicast V4 packets. 349155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the operation succeeded, {@code false} otherwise 350155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 351155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean stopFilteringMulticastV4Packets() { 352b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.stopRxFilter() 353b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.addRxFilter( 354f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius RX_FILTER_TYPE_V4_MULTICAST) 355b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.startRxFilter(); 356155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 357155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 358155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 359155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Start filtering out Multicast V6 packets 360155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the operation succeeded, {@code false} otherwise 361155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 362155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startFilteringMulticastV6Packets() { 363b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.stopRxFilter() 364b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.removeRxFilter( 365f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius RX_FILTER_TYPE_V6_MULTICAST) 366b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.startRxFilter(); 367155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 368155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 369155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 370155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Stop filtering out Multicast V6 packets. 371155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the operation succeeded, {@code false} otherwise 372155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 373155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean stopFilteringMulticastV6Packets() { 374b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.stopRxFilter() 375b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.addRxFilter( 376f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius RX_FILTER_TYPE_V6_MULTICAST) 377b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && mSupplicantStaIfaceHal.startRxFilter(); 378155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 379155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 380f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int BLUETOOTH_COEXISTENCE_MODE_ENABLED = 0; 381f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int BLUETOOTH_COEXISTENCE_MODE_DISABLED = 1; 382f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius public static final int BLUETOOTH_COEXISTENCE_MODE_SENSE = 2; 3837ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde /** 3847ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * Sets the bluetooth coexistence mode. 3857ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * 3867ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * @param mode One of {@link #BLUETOOTH_COEXISTENCE_MODE_DISABLED}, 3877ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * {@link #BLUETOOTH_COEXISTENCE_MODE_ENABLED}, or 3887ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * {@link #BLUETOOTH_COEXISTENCE_MODE_SENSE}. 3897ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde * @return Whether the mode was successfully set. 3907ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde */ 391155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setBluetoothCoexistenceMode(int mode) { 392f2e03411f137f55940a8f3592e96a272585bd7ddRoshan Pius return mSupplicantStaIfaceHal.setBtCoexistenceMode(mode); 393155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 394155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 395155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 396155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * Enable or disable Bluetooth coexistence scan mode. When this mode is on, 397155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * some of the low-level scan parameters used by the driver are changed to 398155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * reduce interference with A2DP streaming. 399155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * 400cc180872c51908b15ce5cbf834634ff323e036bcChristopher Wiley * @param setCoexScanMode whether to enable or disable this mode 401155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande * @return {@code true} if the command succeeded, {@code false} otherwise. 402155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 403155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setBluetoothCoexistenceScanMode(boolean setCoexScanMode) { 404b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setBtCoexistenceScanModeEnabled(setCoexScanMode); 405155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 406155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 407b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 408b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Enable or disable suspend mode optimizations. 409b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 410b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param enabled true to enable, false otherwise. 411b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 412b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 413155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setSuspendOptimizations(boolean enabled) { 414b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setSuspendModeEnabled(enabled); 415155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 416155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 4179153bd67d51b305ffdd61355e0748e3c332c2cafRoshan Pius /** 418b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set country code. 419b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 420b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param countryCode 2 byte ASCII string. For ex: US, CA. 421b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 4229153bd67d51b305ffdd61355e0748e3c332c2cafRoshan Pius */ 423b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setCountryCode(String countryCode) { 424b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setCountryCode(countryCode); 42504c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang } 42604c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang 42704c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang /** 428b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Initiate TDLS discover and setup or teardown with the specified peer. 429b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 430b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param macAddr MAC Address of the peer. 431b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param enable true to start discovery and setup, false to teardown. 43204c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang */ 433155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public void startTdls(String macAddr, boolean enable) { 434b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (enable) { 435b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.initiateTdlsDiscover(macAddr); 436b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.initiateTdlsSetup(macAddr); 437155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } else { 438b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.initiateTdlsTeardown(macAddr); 439155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 440155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 441155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 442b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 443b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start WPS pin display operation with the specified peer. 444b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 445b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the peer. 446b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 447b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 448155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startWpsPbc(String bssid) { 449b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.startWpsPbc(bssid); 450155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 451155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 452b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 453b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start WPS pin keypad operation with the specified pin. 454b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 455b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param pin Pin to be used. 456b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 457b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 458155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startWpsPinKeypad(String pin) { 459b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.startWpsPinKeypad(pin); 460155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 461155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 462b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 463b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start WPS pin display operation with the specified peer. 464b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 465b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the peer. 466b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return new pin generated on success, null otherwise. 467b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 468155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public String startWpsPinDisplay(String bssid) { 469b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.startWpsPinDisplay(bssid); 470155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 471155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 472b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 473b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Sets whether to use external sim for SIM/USIM processing. 474b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 475b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param external true to enable, false otherwise. 476b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 477b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 47833b575ca6bee66183929f9474b5a161432918604Vinit Deshpande public boolean setExternalSim(boolean external) { 479b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setExternalSim(external); 48033b575ca6bee66183929f9474b5a161432918604Vinit Deshpande } 48133b575ca6bee66183929f9474b5a161432918604Vinit Deshpande 482b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 483b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Sim auth response types. 484b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 485b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static final String SIM_AUTH_RESP_TYPE_GSM_AUTH = "GSM-AUTH"; 486b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static final String SIM_AUTH_RESP_TYPE_UMTS_AUTH = "UMTS-AUTH"; 487b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public static final String SIM_AUTH_RESP_TYPE_UMTS_AUTS = "UMTS-AUTS"; 488b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 489b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 490b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Send the sim auth response for the currently configured network. 491b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 492b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param type |GSM-AUTH|, |UMTS-AUTH| or |UMTS-AUTS|. 493b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param response Response params. 494b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if succeeds, false otherwise. 495b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 496f97140d51d14ce0659d381f443c08dbd94dfea28Honore Tricot public boolean simAuthResponse(int id, String type, String response) { 497b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (SIM_AUTH_RESP_TYPE_GSM_AUTH.equals(type)) { 498b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimGsmAuthResponse(response); 499b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } else if (SIM_AUTH_RESP_TYPE_UMTS_AUTH.equals(type)) { 500b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAuthResponse(response); 501b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } else if (SIM_AUTH_RESP_TYPE_UMTS_AUTS.equals(type)) { 502b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAutsResponse(response); 5035cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius } else { 504b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return false; 5055cf97c9b13cc06554c8901e63d55ba051b7e7881Roshan Pius } 50633b575ca6bee66183929f9474b5a161432918604Vinit Deshpande } 50733b575ca6bee66183929f9474b5a161432918604Vinit Deshpande 508b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 509b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Send the eap sim gsm auth failure for the currently configured network. 510b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 511b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if succeeds, false otherwise. 512b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 51326eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande public boolean simAuthFailedResponse(int id) { 514b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimGsmAuthFailure(); 51526eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande } 51626eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande 517b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 518b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Send the eap sim umts auth failure for the currently configured network. 519b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 520b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if succeeds, false otherwise. 521b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 52226eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande public boolean umtsAuthFailedResponse(int id) { 523b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapSimUmtsAuthFailure(); 52426eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande } 52526eebecc04b55129a902d1e7b670fe05668c14faVinit Deshpande 526b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 527b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Send the eap identity response for the currently configured network. 528b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 529b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param response String to send. 530b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if succeeds, false otherwise. 531b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 532ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot public boolean simIdentityResponse(int id, String response) { 533b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.sendCurrentNetworkEapIdentityResponse(response); 534ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot } 535ad607d99c372160c7d4b38e755e1b47d6419856eHonore Tricot 536b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 537a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang * This get anonymous identity from supplicant and returns it as a string. 538a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang * 539a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang * @return anonymous identity string if succeeds, null otherwise. 540a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang */ 541a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang public String getEapAnonymousIdentity() { 542a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang return mSupplicantStaIfaceHal.getCurrentNetworkEapAnonymousIdentity(); 543a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang } 544a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang 545a1da73ea4926ce8a5689594ff3685b0fe033d99fNingyuan Wang /** 546b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start WPS pin registrar operation with the specified peer and pin. 547b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 548b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the peer. 549b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param pin Pin to be used. 550b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 551b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 552155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean startWpsRegistrar(String bssid, String pin) { 553b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.startWpsRegistrar(bssid, pin); 554155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 555155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 556b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 557b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Cancels any ongoing WPS requests. 558b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 559b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 560b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 561155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean cancelWps() { 562b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.cancelWps(); 563155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 564155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 565b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 566b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS device name. 567b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 568b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param name String to be set. 569b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 570b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 571155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setDeviceName(String name) { 572b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsDeviceName(name); 573155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 574155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 575b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 576b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS device type. 577b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 578b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param type Type specified as a string. Used format: <categ>-<OUI>-<subcateg> 579b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 580b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 581155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setDeviceType(String type) { 582b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsDeviceType(type); 583155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 584155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 585b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 586b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS config methods 587b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 588b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param cfg List of config methods. 589b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 590b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 591155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setConfigMethods(String cfg) { 592b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsConfigMethods(cfg); 593155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 594155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 595b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 596b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS manufacturer. 597b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 598b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param value String to be set. 599b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 600b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 601155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setManufacturer(String value) { 602b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsManufacturer(value); 603155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 604155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 605b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 606b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS model name. 607b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 608b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param value String to be set. 609b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 610b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 611155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setModelName(String value) { 612b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsModelName(value); 613155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 614155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 615b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 616b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS model number. 617b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 618b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param value String to be set. 619b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 620b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 621155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setModelNumber(String value) { 622b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsModelNumber(value); 623155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 624155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 625b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 626b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set WPS serial number. 627b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 628b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param value String to be set. 629b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 630b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 631155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public boolean setSerialNumber(String value) { 632b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setWpsSerialNumber(value); 633155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 634155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 635b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 636b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Enable or disable power save mode. 637b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 638b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param enabled true to enable, false to disable. 639b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 640155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande public void setPowerSave(boolean enabled) { 641b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mSupplicantStaIfaceHal.setPowerSave(enabled); 642155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 643155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 644b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 645b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set concurrency priority between P2P & STA operations. 646b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 647b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param isStaHigherPriority Set to true to prefer STA over P2P during concurrency operations, 648b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * false otherwise. 649b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise. 650b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 651b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setConcurrencyPriority(boolean isStaHigherPriority) { 652b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setConcurrencyPriority(isStaHigherPriority); 653155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 654155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 655155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande /** 6563e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius * Enable/Disable auto reconnect functionality in wpa_supplicant. 6573e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius * 6583e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius * @param enable true to enable auto reconnecting, false to disable. 6593e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius * @return true if request is sent successfully, false otherwise. 6603e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius */ 6613e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius public boolean enableStaAutoReconnect(boolean enable) { 6623e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius return mSupplicantStaIfaceHal.enableAutoReconnect(enable); 6633e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius } 6643e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius 6653e240b2bfb6fefe8b91ad68e8a12b652b4136c69Roshan Pius /** 666b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Migrate all the configured networks from wpa_supplicant. 667b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 668b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param configs Map of configuration key to configuration objects corresponding to all 669b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * the networks. 670b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param networkExtras Map of extra configuration parameters stored in wpa_supplicant.conf 671b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Max priority of all the configs. 672155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande */ 673b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean migrateNetworksFromSupplicant(Map<String, WifiConfiguration> configs, 674b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius SparseArray<Map<String, String>> networkExtras) { 675b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.loadNetworks(configs, networkExtras); 676155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 677155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 678b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 679b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Add the provided network configuration to wpa_supplicant and initiate connection to it. 680b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * This method does the following: 681c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 1. Abort any ongoing scan to unblock the connection request. 682c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 2. Remove any existing network in wpa_supplicant(This implicitly triggers disconnect). 683c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 3. Add a new network to wpa_supplicant. 684c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 4. Save the provided configuration to wpa_supplicant. 685c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 5. Select the new network in wpa_supplicant. 686c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 6. Triggers reconnect command to wpa_supplicant. 687b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 688b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param configuration WifiConfiguration parameters for the provided network. 689b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return {@code true} if it succeeds, {@code false} otherwise 690b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 691a5936a61582404692c6046e3b496d3b1d22a94cbNingyuan Wang public boolean connectToNetwork(WifiConfiguration configuration) { 692c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang // Abort ongoing scan before connect() to unblock connection request. 693c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang mWificondControl.abortScan(); 694a5936a61582404692c6046e3b496d3b1d22a94cbNingyuan Wang return mSupplicantStaIfaceHal.connectToNetwork(configuration); 695155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 696155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 697b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 698b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Initiates roaming to the already configured network in wpa_supplicant. If the network 699b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * configuration provided does not match the already configured network, then this triggers 700b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * a new connection attempt (instead of roam). 701c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 1. Abort any ongoing scan to unblock the roam request. 702c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 2. First check if we're attempting to connect to the same network as we currently have 703b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * configured. 704c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 3. Set the new bssid for the network in wpa_supplicant. 705c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang * 4. Triggers reassociate command to wpa_supplicant. 706b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 707b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param configuration WifiConfiguration parameters for the provided network. 708b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return {@code true} if it succeeds, {@code false} otherwise 709b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 710b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean roamToNetwork(WifiConfiguration configuration) { 711c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang // Abort ongoing scan before connect() to unblock roaming request. 712c4ad341e844e88a34be7ed4c3c9509fb72608b37Ningyuan Wang mWificondControl.abortScan(); 713b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.roamToNetwork(configuration); 714155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 715155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 716b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 717b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Get the framework network ID corresponding to the provided supplicant network ID for the 718b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * network configured in wpa_supplicant. 719b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 720b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param supplicantNetworkId network ID in wpa_supplicant for the network. 721b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Corresponding framework network ID if found, -1 if network not found. 722b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 723b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int getFrameworkNetworkId(int supplicantNetworkId) { 724b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return supplicantNetworkId; 725155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 726155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 727b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 728b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Remove all the networks. 729b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 730b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return {@code true} if it succeeds, {@code false} otherwise 731b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 732b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean removeAllNetworks() { 733b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.removeAllNetworks(); 734155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 735155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 736b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 737b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set the BSSID for the currently configured network in wpa_supplicant. 738b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 739b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if successful, false otherwise. 740b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 741b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setConfiguredNetworkBSSID(String bssid) { 742b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.setCurrentNetworkBssid(bssid); 743155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 744155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 745b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 746b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Initiate ANQP query. 747b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 748b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the AP to be queried 749b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param anqpIds Set of anqp IDs. 750b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param hs20Subtypes Set of HS20 subtypes. 751b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 752b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 753b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean requestAnqp(String bssid, Set<Integer> anqpIds, Set<Integer> hs20Subtypes) { 754b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (bssid == null || ((anqpIds == null || anqpIds.isEmpty()) 755b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius && (hs20Subtypes == null || hs20Subtypes.isEmpty()))) { 756b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Invalid arguments for ANQP request."); 757155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande return false; 758155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 759b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ArrayList<Short> anqpIdList = new ArrayList<>(); 760b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius for (Integer anqpId : anqpIds) { 761b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius anqpIdList.add(anqpId.shortValue()); 76261233efc46707ace6cb3a45dd84766f06df946afTomasz Wiszkowski } 763b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ArrayList<Integer> hs20SubtypeList = new ArrayList<>(); 764b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius hs20SubtypeList.addAll(hs20Subtypes); 765b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.initiateAnqpQuery(bssid, anqpIdList, hs20SubtypeList); 766155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 767155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 768b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 769b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Request a passpoint icon file |filename| from the specified AP |bssid|. 770b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param bssid BSSID of the AP 771b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param fileName name of the icon file 772b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if request is sent successfully, false otherwise 773b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 774b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean requestIcon(String bssid, String fileName) { 775b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (bssid == null || fileName == null) { 776b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "Invalid arguments for Icon request."); 77761233efc46707ace6cb3a45dd84766f06df946afTomasz Wiszkowski return false; 778155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 779b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.initiateHs20IconQuery(bssid, fileName); 780155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 781155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande 782b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 783b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Get the currently configured network's WPS NFC token. 784b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 785b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Hex string corresponding to the WPS NFC token. 786b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 787ba3f5bc64ef27f2ec0d3eae3f53c633ea9e66268Amin Shaikh public String getCurrentNetworkWpsNfcConfigurationToken() { 788b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mSupplicantStaIfaceHal.getCurrentNetworkWpsNfcConfigurationToken(); 789155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande } 790b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 791b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Vendor HAL operations 792b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 793af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius /** 794af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius * Callback to notify vendor HAL death. 795af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius */ 796af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius public interface VendorHalDeathEventHandler { 797af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius /** 798af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius * Invoked when the vendor HAL dies. 799af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius */ 800af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius void onDeath(); 801af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius } 802b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 803d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius /** 804520fbe7db055661af039303c1081236c73b04abdRoshan Pius * Initializes the vendor HAL. This is just used to initialize the {@link HalDeviceManager}. 805520fbe7db055661af039303c1081236c73b04abdRoshan Pius */ 806af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius public boolean initializeVendorHal(VendorHalDeathEventHandler handler) { 807af0e32cfa2f7402c60b9df88a0d9bd19f421026cRoshan Pius return mWifiVendorHal.initialize(handler); 808520fbe7db055661af039303c1081236c73b04abdRoshan Pius } 809520fbe7db055661af039303c1081236c73b04abdRoshan Pius 810520fbe7db055661af039303c1081236c73b04abdRoshan Pius /** 811d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius * Bring up the Vendor HAL and configure for STA mode or AP mode. 812d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius * 813d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius * @param isStaMode true to start HAL in STA mode, false to start in AP mode. 814d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius */ 815d84fd37259c6e956d0f00c261f573dfa319acb91Roshan Pius public boolean startHal(boolean isStaMode) { 816b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startVendorHal(isStaMode); 8177ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde } 8187ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde 819b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 820b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stops the HAL 821b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 82218786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public void stopHal() { 823b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius mWifiVendorHal.stopVendorHal(); 8247ef73dd1b6e43c72b3841723504cd86dc402a134Vinit Deshapnde } 8257f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 826b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 827b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Tests whether the HAL is running or not 828b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 82918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean isHalStarted() { 830b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.isHalStarted(); 8317f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde } 8327f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 833062e3f39e37874fedc01f267de5f4cf7dbebe2b4Randy Pan // TODO: Change variable names to camel style. 834e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public static class ScanCapabilities { 835297c3acabe7a85eb87240fe3ccf772e57ce6aef7Mitchell Wills public int max_scan_cache_size; 836e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public int max_scan_buckets; 837e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public int max_ap_cache_per_scan; 838e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public int max_rssi_sample_size; 839297c3acabe7a85eb87240fe3ccf772e57ce6aef7Mitchell Wills public int max_scan_reporting_threshold; 840e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 841e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 842b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 843b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Gets the scan capabilities 844b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 845b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param capabilities object to be filled in 846b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success. false for failure 847b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 8486ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public boolean getBgScanCapabilities(ScanCapabilities capabilities) { 8496ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass return mWifiVendorHal.getBgScanCapabilities(capabilities); 850e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 851e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 852e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public static class ChannelSettings { 853712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int frequency; 854712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int dwell_time_ms; 855712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public boolean passive; 8567f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde } 8577f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 858e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public static class BucketSettings { 859712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int bucket; 860712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int band; 861712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int period_ms; 862712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int max_period_ms; 863712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int step_count; 864712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int report_events; 865712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int num_channels; 866712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public ChannelSettings[] channels; 867e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 8687f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 8696259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius /** 8706259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius * Network parameters for hidden networks to be scanned for. 8716259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius */ 8726259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius public static class HiddenNetwork { 8736259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius public String ssid; 8746259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius 8756259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius @Override 8766259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius public boolean equals(Object otherObj) { 8776259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius if (this == otherObj) { 8786259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius return true; 8796259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius } else if (otherObj == null || getClass() != otherObj.getClass()) { 8806259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius return false; 8816259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius } 8826259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius HiddenNetwork other = (HiddenNetwork) otherObj; 8836259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius return Objects.equals(ssid, other.ssid); 8846259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius } 885ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh 886ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh @Override 887ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh public int hashCode() { 888ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh return (ssid == null ? 0 : ssid.hashCode()); 889ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh } 8906259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius } 8916259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius 892e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde public static class ScanSettings { 893712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int base_period_ms; 894712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int max_ap_per_scan; 895712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int report_threshold_percent; 896712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int report_threshold_num_scans; 897712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public int num_buckets; 8986259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius /* Not used for bg scans. Only works for single scans. */ 8996259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius public HiddenNetwork[] hiddenNetworks; 900712ef6246834caeac3d5b06bea08e85d6b29cd7aMitchell Wills public BucketSettings[] buckets; 901e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 9027f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 90368cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang /** 9049bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Network parameters to start PNO scan. 9059bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 9069bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public static class PnoNetwork { 9079bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public String ssid; 9089bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public byte flags; 909ef3ea1092bc17673c0a85a845b053151b7c10e07Roshan Pius public byte auth_bit_field; 9101bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius 9111bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius @Override 9121bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius public boolean equals(Object otherObj) { 9131bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius if (this == otherObj) { 9141bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius return true; 9151bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius } else if (otherObj == null || getClass() != otherObj.getClass()) { 9161bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius return false; 9171bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius } 9181bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius PnoNetwork other = (PnoNetwork) otherObj; 9196259b630ddb59b642729a2d2113d81ed8e33a0e3Roshan Pius return ((Objects.equals(ssid, other.ssid)) && (flags == other.flags) 9201bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius && (auth_bit_field == other.auth_bit_field)); 9211bf983a4211f547593a60523e43112ecdb5c8997Roshan Pius } 922ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh 923ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh @Override 924ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh public int hashCode() { 925ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh int result = (ssid == null ? 0 : ssid.hashCode()); 926ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh result ^= ((int) flags * 31) + ((int) auth_bit_field << 8); 927ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh return result; 928ef1606e936204c56ffdae305f2f423ee3503fecdMehdi Alizadeh } 9299bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius } 9309bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius 9319bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius /** 9329bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Parameters to start PNO scan. This holds the list of networks which are going to used for 9339bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * PNO scan. 9349bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 9359bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public static class PnoSettings { 9369bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int min5GHzRssi; 9379bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int min24GHzRssi; 9389bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int initialScoreMax; 9399bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int currentConnectionBonus; 9409bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int sameNetworkBonus; 9419bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int secureBonus; 9429bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public int band5GHzBonus; 94304c453c2e07efc30b99528926f205740226f1c7bNingyuan Wang public int periodInMs; 944dcd877d6c143db557884993ea437e2a432cb0ba3Roshan Pius public boolean isConnected; 9459bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public PnoNetwork[] networkList; 9469bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius } 9479bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius 948b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande public static interface ScanEventHandler { 94963539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills /** 95063539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Called for each AP as it is found with the entire contents of the beacon/probe response. 95163539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Only called when WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT is specified. 95263539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills */ 953c9e6069eb941d282af213dc20b171877db6b567bMitchell Wills void onFullScanResult(ScanResult fullScanResult, int bucketsScanned); 95463539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills /** 95563539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Callback on an event during a gscan scan. 95663539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * See WifiNative.WIFI_SCAN_* for possible values. 95763539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills */ 95863539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills void onScanStatus(int event); 95963539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills /** 96063539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Called with the current cached scan results when gscan is paused. 96163539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills */ 96283a674a18c84ff4f01377bbfd8988699dec93bc2Vinit Deshpande void onScanPaused(WifiScanner.ScanData[] data); 96363539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills /** 96463539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills * Called with the current cached scan results when gscan is resumed. 96563539f1283899fbbf83ab90757961b4be51d5034Mitchell Wills */ 966b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande void onScanRestarted(); 967e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 968e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 9699bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius /** 9709bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Handler to notify the occurrence of various events during PNO scan. 9719bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 9729bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public interface PnoEventHandler { 9739bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius /** 9749bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Callback to notify when one of the shortlisted networks is found during PNO scan. 9759bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @param results List of Scan results received. 9769bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 9779bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius void onPnoNetworkFound(ScanResult[] results); 978063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius 979063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius /** 980063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius * Callback to notify when the PNO scan schedule fails. 981063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius */ 982063cfc7e3eef78fcbda24a66f0c473828b39c854Roshan Pius void onPnoScanFailed(); 9839bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius } 9849bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius 98571af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills public static final int WIFI_SCAN_RESULTS_AVAILABLE = 0; 98671af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills public static final int WIFI_SCAN_THRESHOLD_NUM_SCANS = 1; 98771af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills public static final int WIFI_SCAN_THRESHOLD_PERCENT = 2; 98871af8bb37fee5852ae458edabdef3b487d62a5b8Mitchell Wills public static final int WIFI_SCAN_FAILED = 3; 989b7cc309f06da8a18224057c21ba086f8550367d6Vinit Deshpande 990b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 991b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Starts a background scan. 992b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Any ongoing scan will be stopped first 993b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 994b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param settings to control the scan 995b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param eventHandler to call with the results 996b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success 997b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 9986ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public boolean startBgScan(ScanSettings settings, ScanEventHandler eventHandler) { 9996ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass return mWifiVendorHal.startBgScan(settings, eventHandler); 10007f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde } 10017f9a15d554f69311a0db43347d6473a7c4c46e2eVinit Deshapnde 1002b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1003b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stops any ongoing backgound scan 1004b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10056ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public void stopBgScan() { 10066ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass mWifiVendorHal.stopBgScan(); 1007b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande } 1008b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande 1009b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1010b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Pauses an ongoing backgound scan 1011b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10126ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public void pauseBgScan() { 10136ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass mWifiVendorHal.pauseBgScan(); 1014b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande } 1015b0b1d59786de7ff1fc98e31a16a7d710458bf549Vinit Deshpande 1016b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1017b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Restarts a paused scan 1018b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10196ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public void restartBgScan() { 10206ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass mWifiVendorHal.restartBgScan(); 1021e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 1022e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 1023b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1024b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Gets the latest scan results received. 1025b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 10266ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass public WifiScanner.ScanData[] getBgScanResults() { 10276ba8a37de432d957e10dd9cc74798758870d02e6Michael Plass return mWifiVendorHal.getBgScanResults(); 1028e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde } 1029e4e3750390bec0a849a9153348b7c21b2cc8b843Vinit Deshapnde 103018786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public WifiLinkLayerStats getWifiLinkLayerStats(String iface) { 1031b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getWifiLinkLayerStats(); 10325c08cc119b92af69997af194cc8b6d0111e37d31Andres Morales } 10335c08cc119b92af69997af194cc8b6d0111e37d31Andres Morales 1034b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1035b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Get the supported features 1036b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1037b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return bitmask defined by WifiManager.WIFI_FEATURE_* 1038b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 103918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public int getSupportedFeatureSet() { 1040b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getSupportedFeatureSet(); 1041a632d8a6edd350c7644b593b18eceaa5b368505bVinit Deshpande } 1042143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande 1043143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande public static interface RttEventHandler { 1044143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande void onRttResults(RttManager.RttResult[] result); 1045143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande } 1046143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande 1047b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1048b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Starts a new rtt request 1049b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1050b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param params RTT request params. Refer to {@link RttManager#RttParams}. 1051b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param handler Callback to be invoked to notify any results. 1052b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if the request was successful, false otherwise. 1053b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 105418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean requestRtt( 1055143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande RttManager.RttParams[] params, RttEventHandler handler) { 1056b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.requestRtt(params, handler); 1057143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande } 1058143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande 1059b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1060b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Cancels an outstanding rtt request 1061b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1062b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param params RTT request params. Refer to {@link RttManager#RttParams} 1063b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if there was an outstanding request and it was successfully cancelled 1064b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 106518786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean cancelRtt(RttManager.RttParams[] params) { 1066b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.cancelRtt(params); 1067143657392bf0702a155fe688171a5abbf4c86570Vinit Deshpande } 1068042c54bfd5144ce8e720585b2093796e7e28de5eVinit Deshpande 106968cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang /** 107068cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang * Enable RTT responder role on the device. Returns {@link ResponderConfig} if the responder 107168cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang * role is successfully enabled, {@code null} otherwise. 1072b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1073b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param timeoutSeconds timeout to use for the responder. 107468cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang */ 107568cb8c02b4ad079c54a2ffd4407da921d18c7af9Wei Wang @Nullable 1076b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public ResponderConfig enableRttResponder(int timeoutSeconds) { 1077b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.enableRttResponder(timeoutSeconds); 107812cf388ecf3b2aa5ba66ed680b931fa356ab75b5xinhe } 1079939177ff615062ec826601d536466875d8457375xinhe 1080b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1081b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Disable RTT responder role. Returns {@code true} if responder role is successfully disabled, 1082b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * {@code false} otherwise. 1083b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1084b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean disableRttResponder() { 1085b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.disableRttResponder(); 10866609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen } 10876609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen 1088b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1089b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set the MAC OUI during scanning. 1090b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * An OUI {Organizationally Unique Identifier} is a 24-bit number that 1091b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * uniquely identifies a vendor or manufacturer. 1092b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1093b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param oui OUI to set. 1094b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success 1095b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1096b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setScanningMacOui(byte[] oui) { 1097b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.setScanningMacOui(oui); 10986609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen } 10996609df5a9c14e4440c085567a27437a8cfc50f88Paul Jensen 1100b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1101b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Query the list of valid frequencies for the provided band. 1102b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * The result depends on the on the country code that has been set. 1103b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1104b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param band as specified by one of the WifiScanner.WIFI_BAND_* constants. 1105b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return frequencies vector of valid frequencies (MHz), or null for error. 1106b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @throws IllegalArgumentException if band is not recognized. 1107b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1108b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int [] getChannelsForBand(int band) { 1109b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getChannelsForBand(band); 1110939177ff615062ec826601d536466875d8457375xinhe } 1111939177ff615062ec826601d536466875d8457375xinhe 1112b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1113b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Indicates whether getChannelsForBand is supported. 1114b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1115b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true if it is. 1116b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1117b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean isGetChannelsForBandSupported() { 1118b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.isGetChannelsForBandSupported(); 1119d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1120d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1121b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1122b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * RTT (Round Trip Time) measurement capabilities of the device. 1123b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1124b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public RttManager.RttCapabilities getRttCapabilities() { 1125b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRttCapabilities(); 1126d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1127d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1128b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1129b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Get the APF (Android Packet Filter) capabilities of the device 1130b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1131b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public ApfCapabilities getApfCapabilities() { 1132b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getApfCapabilities(); 1133d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1134d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1135b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1136b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Installs an APF program on this iface, replacing any existing program. 1137b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1138b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param filter is the android packet filter program 1139b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success 1140b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1141b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean installPacketFilter(byte[] filter) { 1142b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.installPacketFilter(filter); 1143d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1144d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1145b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1146b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Set country code for this AP iface. 1147b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1148b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param countryCode - two-letter country code (as ISO 3166) 1149b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success 1150b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1151b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public boolean setCountryCodeHal(String countryCode) { 1152b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.setCountryCodeHal(countryCode); 1153d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe } 1154d57f630f6a7a5fca872d2b96fc4cce1905daee5dxinhe 1155a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle //--------------------------------------------------------------------------------- 1156a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle /* Wifi Logger commands/events */ 1157a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle public static interface WifiLoggerEventHandler { 11580bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande void onRingBufferData(RingBufferStatus status, byte[] buffer); 11590bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande void onWifiAlert(int errorCode, byte[] buffer); 1160a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle } 1161a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle 1162b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1163b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Registers the logger callback and enables alerts. 1164b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Ring buffer data collection is only triggered when |startLoggingRingBuffer| is invoked. 1165b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1166b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param handler Callback to be invoked. 1167b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 1168b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 116918786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean setLoggingEventHandler(WifiLoggerEventHandler handler) { 1170b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.setLoggingEventHandler(handler); 117103ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 117203ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1173b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1174b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Control debug data collection 1175b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1176b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param verboseLevel 0 to 3, inclusive. 0 stops logging. 1177b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param flags Ignored. 1178b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param maxInterval Maximum interval between reports; ignore if 0. 1179b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param minDataSize Minimum data size in buffer for report; ignore if 0. 1180b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param ringName Name of the ring for which data collection is to start. 1181b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 1182b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 118318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean startLoggingRingBuffer(int verboseLevel, int flags, int maxInterval, 118403ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe int minDataSize, String ringName){ 1185b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startLoggingRingBuffer( 1186b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius verboseLevel, flags, maxInterval, minDataSize, ringName); 118703ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 118803ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1189b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1190b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Logger features exposed. 1191b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * This is a no-op now, will always return -1. 1192b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1193b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 1194b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 119518786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public int getSupportedLoggerFeatureSet() { 1196b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getSupportedLoggerFeatureSet(); 119703ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 119803ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1199b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1200b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stops all logging and resets the logger callback. 1201b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * This stops both the alerts and ring buffer data collection. 1202b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 1203b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 120418786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean resetLogHandler() { 1205b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.resetLogHandler(); 1206b797893fc1966803d0c013faac42e6396a37a384xinhe } 1207b797893fc1966803d0c013faac42e6396a37a384xinhe 1208b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1209b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Vendor-provided wifi driver version string 1210b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1211b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return String returned from the HAL. 1212b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 121318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public String getDriverVersion() { 1214b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getDriverVersion(); 121503ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 121603ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1217b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1218b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Vendor-provided wifi firmware version string 1219b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1220b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return String returned from the HAL. 1221b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 122218786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public String getFirmwareVersion() { 1223b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getFirmwareVersion(); 122403ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 122503ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 12260bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande public static class RingBufferStatus{ 12270bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande String name; 12280bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int flag; 12290bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int ringBufferId; 12300bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int ringBufferByteSize; 12310bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int verboseLevel; 12320bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int writtenBytes; 12330bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int readBytes; 12340bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande int writtenRecords; 12350bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande 123653f278b6fed422a18d763b07216a21e96d9445f9Michael Plass // Bit masks for interpreting |flag| 123753f278b6fed422a18d763b07216a21e96d9445f9Michael Plass public static final int HAS_BINARY_ENTRIES = (1 << 0); 123853f278b6fed422a18d763b07216a21e96d9445f9Michael Plass public static final int HAS_ASCII_ENTRIES = (1 << 1); 123953f278b6fed422a18d763b07216a21e96d9445f9Michael Plass public static final int HAS_PER_PACKET_ENTRIES = (1 << 2); 124053f278b6fed422a18d763b07216a21e96d9445f9Michael Plass 12410bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande @Override 12420bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande public String toString() { 12430bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande return "name: " + name + " flag: " + flag + " ringBufferId: " + ringBufferId + 12440bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande " ringBufferByteSize: " +ringBufferByteSize + " verboseLevel: " +verboseLevel + 12450bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande " writtenBytes: " + writtenBytes + " readBytes: " + readBytes + 12460bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande " writtenRecords: " + writtenRecords; 12470bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande } 12480bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande } 12490bf150b2d69ec62df905bc6f8603437dc4caee1fVinit Deshpande 1250b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1251b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * API to get the status of all ring buffers supported by driver 1252b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 125318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public RingBufferStatus[] getRingBufferStatus() { 1254b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRingBufferStatus(); 125503ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 125603ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe 1257b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1258b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Indicates to driver that all the data has to be uploaded urgently 1259b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1260b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param ringName Name of the ring buffer requested. 1261b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true on success, false otherwise. 1262b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 126318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public boolean getRingBufferData(String ringName) { 1264b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRingBufferData(ringName); 126503ba4a5b108ab2bbdb5d0e7be46ac45c00a6d9ffxinhe } 1266127f7244183786e6ccae09e81eeccdac31973e69xinhe 1267b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1268b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Request vendor debug info from the firmware 1269b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1270b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Raw data obtained from the HAL. 1271b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 127218786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public byte[] getFwMemoryDump() { 1273b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getFwMemoryDump(); 1274a0d34d3626bd9631039a485d2d428b1b7de390e2Pierre Vandwalle } 1275dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle 1276b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1277b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Request vendor debug info from the driver 1278b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1279b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return Raw data obtained from the HAL. 1280b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1281d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal public byte[] getDriverStateDump() { 1282b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getDriverStateDump(); 1283d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal } 1284d0cb2fae195ebb9f658095667f3c7b7b8d69a204mukesh agrawal 1285dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle //--------------------------------------------------------------------------------- 128609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal /* Packet fate API */ 128709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 128809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal @Immutable 128909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal abstract static class FateReport { 1290eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final static int USEC_PER_MSEC = 1000; 1291eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // The driver timestamp is a 32-bit counter, in microseconds. This field holds the 1292eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // maximal value of a driver timestamp in milliseconds. 1293eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final static int MAX_DRIVER_TIMESTAMP_MSEC = (int) (0xffffffffL / 1000); 1294eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final static SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss.SSS"); 1295eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal 129609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal final byte mFate; 129709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal final long mDriverTimestampUSec; 129809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal final byte mFrameType; 129909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal final byte[] mFrameBytes; 1300eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long mEstimatedWallclockMSec; 130109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 130209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal FateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) { 130309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal mFate = fate; 130409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal mDriverTimestampUSec = driverTimestampUSec; 1305eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal mEstimatedWallclockMSec = 1306eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal convertDriverTimestampUSecToWallclockMSec(mDriverTimestampUSec); 130709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal mFrameType = frameType; 130809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal mFrameBytes = frameBytes; 130909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 13100fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 1311590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan public String toTableRowString() { 1312590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan StringWriter sw = new StringWriter(); 1313590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan PrintWriter pw = new PrintWriter(sw); 1314590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan FrameParser parser = new FrameParser(mFrameType, mFrameBytes); 1315eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal dateFormatter.setTimeZone(TimeZone.getDefault()); 1316eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal pw.format("%-15s %12s %-9s %-32s %-12s %-23s %s\n", 1317eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal mDriverTimestampUSec, 1318eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal dateFormatter.format(new Date(mEstimatedWallclockMSec)), 1319eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal directionToString(), fateToString(), parser.mMostSpecificProtocolString, 1320eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal parser.mTypeString, parser.mResultString); 1321590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan return sw.toString(); 1322590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan } 1323590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan 1324590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan public String toVerboseStringWithPiiAllowed() { 13250fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal StringWriter sw = new StringWriter(); 13260fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal PrintWriter pw = new PrintWriter(sw); 1327590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan FrameParser parser = new FrameParser(mFrameType, mFrameBytes); 13280fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame direction: %s\n", directionToString()); 13290fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame timestamp: %d\n", mDriverTimestampUSec); 13300fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame fate: %s\n", fateToString()); 13310fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame type: %s\n", frameTypeToString(mFrameType)); 1332590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan pw.format("Frame protocol: %s\n", parser.mMostSpecificProtocolString); 1333590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan pw.format("Frame protocol type: %s\n", parser.mTypeString); 13340fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.format("Frame length: %d\n", mFrameBytes.length); 13350fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.append("Frame bytes"); 1336590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan pw.append(HexDump.dumpHexString(mFrameBytes)); // potentially contains PII 13370fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal pw.append("\n"); 13380fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return sw.toString(); 13390fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 13400fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 1341590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan /* Returns a header to match the output of toTableRowString(). */ 1342590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan public static String getTableHeader() { 1343590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan StringWriter sw = new StringWriter(); 1344590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan PrintWriter pw = new PrintWriter(sw); 1345eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal pw.format("\n%-15s %-12s %-9s %-32s %-12s %-23s %s\n", 1346eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal "Time usec", "Walltime", "Direction", "Fate", "Protocol", "Type", "Result"); 1347eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal pw.format("%-15s %-12s %-9s %-32s %-12s %-23s %s\n", 1348eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal "---------", "--------", "---------", "----", "--------", "----", "------"); 1349590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan return sw.toString(); 1350590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan } 1351590f3fc2045389d5ef274c4b3bd6162d93b1a0acSamuel Tan 13520fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected abstract String directionToString(); 13530fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 13540fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected abstract String fateToString(); 13550fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 13560fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal private static String frameTypeToString(byte frameType) { 13570fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal switch (frameType) { 13580fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.FRAME_TYPE_UNKNOWN: 13590fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "unknown"; 13600fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.FRAME_TYPE_ETHERNET_II: 13610fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "data"; 13620fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.FRAME_TYPE_80211_MGMT: 13630fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "802.11 management"; 13640fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal default: 13650fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return Byte.toString(frameType); 13660fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 13670fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 1368eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal 1369eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal /** 1370eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal * Converts a driver timestamp to a wallclock time, based on the current 1371eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal * BOOTTIME to wallclock mapping. The driver timestamp is a 32-bit counter of 1372eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal * microseconds, with the same base as BOOTTIME. 1373eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal */ 1374eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal private static long convertDriverTimestampUSecToWallclockMSec(long driverTimestampUSec) { 1375eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long wallclockMillisNow = System.currentTimeMillis(); 1376eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long boottimeMillisNow = SystemClock.elapsedRealtime(); 1377eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long driverTimestampMillis = driverTimestampUSec / USEC_PER_MSEC; 1378eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal 1379eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal long boottimeTimestampMillis = boottimeMillisNow % MAX_DRIVER_TIMESTAMP_MSEC; 1380eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal if (boottimeTimestampMillis < driverTimestampMillis) { 1381eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // The 32-bit microsecond count has wrapped between the time that the driver 1382eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // recorded the packet, and the call to this function. Adjust the BOOTTIME 1383eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // timestamp, to compensate. 1384eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // 1385eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // Note that overflow is not a concern here, since the result is less than 1386eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // 2 * MAX_DRIVER_TIMESTAMP_MSEC. (Given the modulus operation above, 1387eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // boottimeTimestampMillis must be less than MAX_DRIVER_TIMESTAMP_MSEC.) And, since 1388eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // MAX_DRIVER_TIMESTAMP_MSEC is an int, 2 * MAX_DRIVER_TIMESTAMP_MSEC must fit 1389eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal // within a long. 1390eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal boottimeTimestampMillis += MAX_DRIVER_TIMESTAMP_MSEC; 1391eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal } 1392eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal 1393eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal final long millisSincePacketTimestamp = boottimeTimestampMillis - driverTimestampMillis; 1394eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal return wallclockMillisNow - millisSincePacketTimestamp; 1395eaf6303a081b4a7f2231b5053099da7a1c16b7bdmukesh agrawal } 139609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 139709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 139809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal /** 139909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal * Represents the fate information for one outbound packet. 140009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal */ 140109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal @Immutable 140209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal public static final class TxFateReport extends FateReport { 140309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal TxFateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) { 140409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal super(fate, driverTimestampUSec, frameType, frameBytes); 140509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 14060fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14070fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal @Override 14080fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected String directionToString() { 14090fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "TX"; 14100fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14110fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14120fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal @Override 14130fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected String fateToString() { 14140fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal switch (mFate) { 14150fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_ACKED: 14160fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "acked"; 14170fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_SENT: 14180fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "sent"; 14190fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_FW_QUEUED: 14200fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware queued"; 14210fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_FW_DROP_INVALID: 14220fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (invalid frame)"; 14230fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_FW_DROP_NOBUFS: 14240fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (no bufs)"; 14250fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_FW_DROP_OTHER: 14260fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (other)"; 14270fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_DRV_QUEUED: 14280fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver queued"; 14290fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_INVALID: 14300fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (invalid frame)"; 14310fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_NOBUFS: 14320fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (no bufs)"; 14330fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.TX_PKT_FATE_DRV_DROP_OTHER: 14340fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (other)"; 14350fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal default: 14360fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return Byte.toString(mFate); 14370fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14380fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 143909b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 144009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 144109b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal /** 144209b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal * Represents the fate information for one inbound packet. 144309b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal */ 144409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal @Immutable 144509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal public static final class RxFateReport extends FateReport { 144609b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal RxFateReport(byte fate, long driverTimestampUSec, byte frameType, byte[] frameBytes) { 144709b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal super(fate, driverTimestampUSec, frameType, frameBytes); 144809b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 14490fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14500fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal @Override 14510fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected String directionToString() { 14520fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "RX"; 14530fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14540fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14550fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal @Override 14560fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal protected String fateToString() { 14570fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal switch (mFate) { 14580fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_SUCCESS: 14590fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "success"; 14600fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_QUEUED: 14610fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware queued"; 14620fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_DROP_FILTER: 14630fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (filter)"; 14640fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_DROP_INVALID: 14650fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (invalid frame)"; 14660fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_DROP_NOBUFS: 14670fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (no bufs)"; 14680fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_FW_DROP_OTHER: 14690fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "firmware dropped (other)"; 14700fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_QUEUED: 14710fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver queued"; 14720fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_FILTER: 14730fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (filter)"; 14740fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_INVALID: 14750fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (invalid frame)"; 14760fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_NOBUFS: 14770fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (no bufs)"; 14780fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal case WifiLoggerHal.RX_PKT_FATE_DRV_DROP_OTHER: 14790fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return "driver dropped (other)"; 14800fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal default: 14810fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal return Byte.toString(mFate); 14820fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14830fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 148409b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal } 148509b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 14860fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal /** 14870fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal * Ask the HAL to enable packet fate monitoring. Fails unless HAL is started. 1488b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1489b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 14900fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal */ 14910fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal public boolean startPktFateMonitoring() { 1492b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startPktFateMonitoring(); 14930fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 14940fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 14950fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal /** 14960fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal * Fetch the most recent TX packet fates from the HAL. Fails unless HAL is started. 1497b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1498b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 14990fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal */ 15000fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal public boolean getTxPktFates(TxFateReport[] reportBufs) { 1501b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getTxPktFates(reportBufs); 15020fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 15030fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal 15040fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal /** 15050fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal * Fetch the most recent RX packet fates from the HAL. Fails unless HAL is started. 15060fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal */ 15070fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal public boolean getRxPktFates(RxFateReport[] reportBufs) { 1508b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRxPktFates(reportBufs); 15090fcb06473cbe2824e401a80c0520bb1c14ed8f41mukesh agrawal } 151009b1d0786d05436d524d7556c269e665a0962ee6mukesh agrawal 15115c3c06082b24f9ff0d479e82a63b52220c86598bRoshan Pius /** 15129bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Set the PNO settings & the network list in HAL to start PNO. 15139bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @param settings PNO settings and network list. 15149bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @param eventHandler Handler to receive notifications back during PNO scan. 15159bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @return true if success, false otherwise 15165c3c06082b24f9ff0d479e82a63b52220c86598bRoshan Pius */ 15179bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public boolean setPnoList(PnoSettings settings, PnoEventHandler eventHandler) { 1518b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "setPnoList not supported"); 1519b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return false; 1520dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle } 1521dd490cf1df37b70a8625dc4ec8e712f740dd1e4aPierre Vandwalle 15229bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius /** 15239bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * Reset the PNO settings in HAL to stop PNO. 15249bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius * @return true if success, false otherwise 15259bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius */ 15269bd01d6cb65ea96d6729d35a1fc43bb2bb40e3bdRoshan Pius public boolean resetPnoList() { 1527b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.e(mTAG, "resetPnoList not supported"); 1528b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return false; 1529d4c25fd76644d5490700ae69fada4669de5193a1Pierre Vandwalle } 1530d4c25fd76644d5490700ae69fada4669de5193a1Pierre Vandwalle 1531b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1532b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start sending the specified keep alive packets periodically. 1533b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1534b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param slot Integer used to identify each request. 1535b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param keepAlivePacket Raw packet contents to send. 1536b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param period Period to use for sending these packets. 1537b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return 0 for success, -1 for error 1538b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1539b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int startSendingOffloadedPacket(int slot, KeepalivePacketData keepAlivePacket, 1540b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius int period) { 15413bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham String[] macAddrStr = getMacAddress().split(":"); 15423bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham byte[] srcMac = new byte[6]; 1543520fbe7db055661af039303c1081236c73b04abdRoshan Pius for (int i = 0; i < 6; i++) { 15443bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham Integer hexVal = Integer.parseInt(macAddrStr[i], 16); 15453bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham srcMac[i] = hexVal.byteValue(); 15463bd22cebc41ed0786d0e7bd2970a634a8bb0093ePrerepa Viswanadham } 1547b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startSendingOffloadedPacket( 1548b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius slot, srcMac, keepAlivePacket, period); 1549c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham } 1550c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham 1551b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1552b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Stop sending the specified keep alive packets. 1553b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1554b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param slot id - same as startSendingOffloadedPacket call. 1555b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return 0 for success, -1 for error 1556b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1557b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public int stopSendingOffloadedPacket(int slot) { 1558b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.stopSendingOffloadedPacket(slot); 1559c55e88163b223db0ca6a99ed6ffe91845c30a576Prerepa Viswanadham } 1560aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham 1561aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham public static interface WifiRssiEventHandler { 1562aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham void onRssiThresholdBreached(byte curRssi); 1563aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham } 1564aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham 1565b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1566b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Start RSSI monitoring on the currently connected access point. 1567b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1568b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param maxRssi Maximum RSSI threshold. 1569b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param minRssi Minimum RSSI threshold. 1570b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param rssiEventHandler Called when RSSI goes above maxRssi or below minRssi 1571b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return 0 for success, -1 for failure 1572b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 157318786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public int startRssiMonitoring(byte maxRssi, byte minRssi, 1574b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius WifiRssiEventHandler rssiEventHandler) { 1575b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.startRssiMonitoring(maxRssi, minRssi, rssiEventHandler); 1576aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham } 1577aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham 157818786eca942042388748b0d98979f21c9dff4a89Mitchell Wills public int stopRssiMonitoring() { 1579b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.stopRssiMonitoring(); 1580aed5cb65d8eefb2eee56a29e33ac3cd8b03312e7Prerepa Viswanadham } 15815ea42964ba17901a8d724736b450ace6ed48880fPrerepa Viswanadham 15826bf6986d359556010638dfae332b585162f06520Roshan Pius /** 15836bf6986d359556010638dfae332b585162f06520Roshan Pius * Fetch the host wakeup reasons stats from wlan driver. 1584b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 15856bf6986d359556010638dfae332b585162f06520Roshan Pius * @return the |WifiWakeReasonAndCounts| object retrieved from the wlan driver. 15866bf6986d359556010638dfae332b585162f06520Roshan Pius */ 15876bf6986d359556010638dfae332b585162f06520Roshan Pius public WifiWakeReasonAndCounts getWlanWakeReasonCount() { 1588b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getWlanWakeReasonCount(); 15896bf6986d359556010638dfae332b585162f06520Roshan Pius } 15903dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline 1591b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1592b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Enable/Disable Neighbour discovery offload functionality in the firmware. 1593b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1594b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @param enabled true to enable, false to disable. 1595b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 1596b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 15973dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline public boolean configureNeighborDiscoveryOffload(boolean enabled) { 1598b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.configureNeighborDiscoveryOffload(enabled); 15993dd6f75ff2ab823bd0c14581f2e047c74916f16fErik Kline } 1600da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1601da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan // Firmware roaming control. 1602da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1603da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1604da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Class to retrieve firmware roaming capability parameters. 1605da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1606da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public static class RoamingCapabilities { 1607da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public int maxBlacklistSize; 1608da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public int maxWhitelistSize; 1609da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1610da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1611da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1612da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Query the firmware roaming capabilities. 1613b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return true for success, false otherwise. 1614da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1615da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public boolean getRoamingCapabilities(RoamingCapabilities capabilities) { 1616b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.getRoamingCapabilities(capabilities); 1617da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1618da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1619da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1620da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Macros for controlling firmware roaming. 1621da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1622da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public static final int DISABLE_FIRMWARE_ROAMING = 0; 1623da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public static final int ENABLE_FIRMWARE_ROAMING = 1; 1624da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1625da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1626da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Enable/disable firmware roaming. 1627b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * 1628b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * @return error code returned from HAL. 1629da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1630da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public int enableFirmwareRoaming(int state) { 1631b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.enableFirmwareRoaming(state); 1632da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1633da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1634da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1635da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Class for specifying the roaming configurations. 1636da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1637da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public static class RoamingConfig { 1638da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public ArrayList<String> blacklistBssids; 1639da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public ArrayList<String> whitelistSsids; 1640da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1641da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1642da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan /** 1643da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan * Set firmware roaming configurations. 1644da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan */ 1645da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan public boolean configureRoaming(RoamingConfig config) { 1646b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius Log.d(mTAG, "configureRoaming "); 1647b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.configureRoaming(config); 1648da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1649da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan 1650374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan /** 1651374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan * Reset firmware roaming configuration. 1652374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan */ 1653374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan public boolean resetRoamingConfiguration() { 1654b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // Pass in an empty RoamingConfig object which translates to zero size 1655b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius // blacklist and whitelist to reset the firmware roaming configuration. 1656b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return mWifiVendorHal.configureRoaming(new RoamingConfig()); 1657b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 1658b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 1659b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /******************************************************** 1660b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * JNI operations 1661b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius ********************************************************/ 1662b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /* Register native functions */ 1663b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius static { 1664b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /* Native functions are defined in libwifi-service.so */ 1665b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius System.loadLibrary("wifi-service"); 1666b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius registerNatives(); 1667b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 1668b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 1669b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private static native int registerNatives(); 1670b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /* kernel logging support */ 1671b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius private static native byte[] readKernelLogNative(); 1672b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius 1673b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius /** 1674b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius * Fetches the latest kernel logs. 1675b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius */ 1676b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius public synchronized String readKernelLog() { 1677b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius byte[] bytes = readKernelLogNative(); 1678b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius if (bytes != null) { 1679b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder(); 1680b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius try { 1681b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius CharBuffer decoded = decoder.decode(ByteBuffer.wrap(bytes)); 1682b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return decoded.toString(); 1683b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } catch (CharacterCodingException cce) { 1684b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return new String(bytes, StandardCharsets.ISO_8859_1); 1685b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius } 1686520fbe7db055661af039303c1081236c73b04abdRoshan Pius } else { 1687b8b3fb8228a1f90106bad8c59ce006b81ef7921cRoshan Pius return "*** failed to read kernel log ***"; 1688374f78d3841f7bf74543dc4d21db66d1d3472c3aRandy Pan } 1689da4958bd7409aaf26ead2b221754d4a5035f7bdfRandy Pan } 1690155b9d09ef9b8ead3ca617afdd91e74070d3f0cbVinit Deshpande} 1691