From 64187ec9e8b48b4de5565e8ae1dbf2f2f3e859bd Mon Sep 17 00:00:00 2001 From: Sohani Rao Date: Tue, 11 Jul 2017 18:06:17 -0700 Subject: [PATCH] Wifficond: Implement API to get PNO scan results Implement getPnoScanResults() API to return scan results from the interface that completed the scheduled PNO scans in disconnected mode most recently. Bug: 63148974 Test: Unit tests, sanity test and on-device tests Change-Id: Ife9f890faa7cdbc34da83708f59eae7398e76109 --- aidl/android/net/wifi/IWifiScannerImpl.aidl | 6 +++++- scanning/scanner_impl.cpp | 21 +++++++++++++++++++++ scanning/scanner_impl.h | 8 +++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/aidl/android/net/wifi/IWifiScannerImpl.aidl b/aidl/android/net/wifi/IWifiScannerImpl.aidl index da0ca2d..e83b79c 100644 --- a/aidl/android/net/wifi/IWifiScannerImpl.aidl +++ b/aidl/android/net/wifi/IWifiScannerImpl.aidl @@ -35,9 +35,13 @@ interface IWifiScannerImpl { // Returrns null on failure. @nullable int[] getAvailableDFSChannels(); - // Get the latest scan results from kernel. + // Get the latest single scan results from kernel. NativeScanResult[] getScanResults(); + // Get the latest pno scan results from the interface which has most recently + // completed disconnected mode PNO scans + NativeScanResult[] getPnoScanResults(); + // Request a single scan using a SingleScanSettings parcelable object. boolean scan(in SingleScanSettings scanSettings); diff --git a/scanning/scanner_impl.cpp b/scanning/scanner_impl.cpp index e9ff517..308811a 100644 --- a/scanning/scanner_impl.cpp +++ b/scanning/scanner_impl.cpp @@ -56,6 +56,8 @@ ScannerImpl::ScannerImpl(uint32_t wiphy_index, uint32_t interface_index, scan_started_(false), pno_scan_started_(false), offload_scan_supported_(false), + pno_scan_running_over_offload_(false), + pno_scan_results_from_offload_(false), wiphy_index_(wiphy_index), interface_index_(interface_index), scan_capabilities_(scan_capabilities), @@ -166,6 +168,23 @@ Status ScannerImpl::getScanResults(vector* out_scan_results) { return Status::ok(); } +Status ScannerImpl::getPnoScanResults( + vector* out_scan_results) { + if (!CheckIsValid()) { + return Status::ok(); + } + if (pno_scan_results_from_offload_) { + if (!offload_scan_manager_->getScanResults(out_scan_results)) { + LOG(ERROR) << "Failed to get scan results via Offload HAL"; + } + } else { + if (!scan_utils_->GetScanResult(interface_index_, out_scan_results)) { + LOG(ERROR) << "Failed to get scan results via NL80211"; + } + } + return Status::ok(); +} + Status ScannerImpl::scan(const SingleScanSettings& scan_settings, bool* out_success) { if (!CheckIsValid()) { @@ -214,6 +233,7 @@ Status ScannerImpl::scan(const SingleScanSettings& scan_settings, Status ScannerImpl::startPnoScan(const PnoSettings& pno_settings, bool* out_success) { pno_settings_ = pno_settings; + pno_scan_results_from_offload_ = false; if (offload_scan_supported_ && StartPnoScanOffload(pno_settings)) { // scanning over offload succeeded *out_success = true; @@ -485,6 +505,7 @@ void ScannerImpl::OnOffloadScanResult() { return; } LOG(INFO) << "Offload Scan results received"; + pno_scan_results_from_offload_ = true; if (pno_scan_event_handler_ != nullptr) { pno_scan_event_handler_->OnPnoNetworkFound(); } else { diff --git a/scanning/scanner_impl.h b/scanning/scanner_impl.h index e97e967..ff1d50f 100644 --- a/scanning/scanner_impl.h +++ b/scanning/scanner_impl.h @@ -54,10 +54,15 @@ class ScannerImpl : public android::net::wifi::BnWifiScannerImpl { // Returns a vector of available frequencies for DFS channels. ::android::binder::Status getAvailableDFSChannels( ::std::unique_ptr<::std::vector>* out_frequencies) override; - // Get the latest scan results from kernel. + // Get the latest single scan results from kernel. ::android::binder::Status getScanResults( std::vector* out_scan_results) override; + // Get the latest pno scan results from the interface that most recently + // completed PNO scans + ::android::binder::Status getPnoScanResults( + std::vector* + out_scan_results) override; ::android::binder::Status scan( const ::com::android::server::wifi::wificond::SingleScanSettings& scan_settings, @@ -108,6 +113,7 @@ class ScannerImpl : public android::net::wifi::BnWifiScannerImpl { bool pno_scan_started_; bool offload_scan_supported_; bool pno_scan_running_over_offload_; + bool pno_scan_results_from_offload_; ::com::android::server::wifi::wificond::PnoSettings pno_settings_; const uint32_t wiphy_index_; -- 2.11.0