This CL addresses the following issues in handling of Offload HAL scan
results from the Offload HAL service
- Make cached scan results member variable a pointer so that the memory
for the vector can be allocated on the heap
- When an Async Error occurs in the Offload HAL service, switch to
performing PNO scans over netlink instead of letting it decide again.
- OffloadScanUtils convertToNativeScanResults() now needs to take in a
pointer to the vector that will store the scan results for retrieval.
- Populate tsf field fo the scanResult so that it doesn't get filtered
out by the framework
- Add logging to scan stats
Bug:
63148974
Test: Unit tests, on-device testing for ensuring we connect to an
available access point from screen off disconnected mode.
Change-Id: Ida507d857faa8ea6dbee362cf0116f8ca858963f
wifi_offload_callback_(nullptr),
death_recipient_(nullptr),
offload_status_(OffloadScanManager::kError),
+ cached_scan_results_(new std::vector<NativeScanResult>()),
service_available_(false),
offload_service_utils_(utils),
offload_callback_handlers_(new OffloadCallbackHandlersImpl(this)),
}
*reason_code = OffloadScanManager::kNone;
- /* Clear up the scan cache every time a new scan is requested */
- cached_scan_results_.clear();
return true;
}
bool OffloadScanManager::getScanResults(
std::vector<NativeScanResult>* out_scan_results) {
- for (auto scan_result : cached_scan_results_) {
+ for (auto scan_result : *cached_scan_results_) {
out_scan_results->push_back(scan_result);
}
return true;
if (wifi_offload_hal_ != nullptr) {
wifi_offload_hal_->unlinkToDeath(death_recipient_);
}
+ delete cached_scan_results_;
}
void OffloadScanManager::ReportScanResults(
const vector<ScanResult>& scanResult) {
- cached_scan_results_ =
- OffloadScanUtils::convertToNativeScanResults(scanResult);
+ cached_scan_results_->clear();
+ if (!OffloadScanUtils::convertToNativeScanResults(scanResult,
+ cached_scan_results_)) {
+ LOG(WARNING) << "Unable to convert scan results to native format";
+ return;
+ }
if (event_callback_ != nullptr) {
event_callback_->OnOffloadScanResult();
} else {
android::sp<OffloadCallback> wifi_offload_callback_;
android::sp<OffloadDeathRecipient> death_recipient_;
StatusCode offload_status_;
- std::vector<::com::android::server::wifi::wificond::NativeScanResult>
+ std::vector<::com::android::server::wifi::wificond::NativeScanResult>*
cached_scan_results_;
bool service_available_;
#include "wificond/scanning/offload/offload_scan_utils.h"
#include <android-base/logging.h>
+#include <utils/Timers.h>
#include "wificond/scanning/offload/scan_stats.h"
#include "wificond/scanning/scan_result.h"
namespace android {
namespace wificond {
-vector<NativeScanResult> OffloadScanUtils::convertToNativeScanResults(
- const vector<ScanResult>& scan_result) {
- vector<NativeScanResult> native_scan_result;
- native_scan_result.reserve(scan_result.size());
+bool OffloadScanUtils::convertToNativeScanResults(
+ const vector<ScanResult>& scan_result,
+ vector<NativeScanResult>* native_scan_result) {
+ if (native_scan_result == nullptr) return false;
for (size_t i = 0; i < scan_result.size(); i++) {
NativeScanResult single_scan_result;
single_scan_result.ssid.assign(scan_result[i].networkInfo.ssid.begin(),
}
single_scan_result.frequency = scan_result[i].frequency;
single_scan_result.signal_mbm = scan_result[i].rssi;
- single_scan_result.tsf = scan_result[i].tsf;
+ single_scan_result.tsf = systemTime(SYSTEM_TIME_MONOTONIC) / 1000;
single_scan_result.capability = scan_result[i].capability;
single_scan_result.associated = false;
- native_scan_result.emplace_back(single_scan_result);
+ native_scan_result->push_back(std::move(single_scan_result));
}
- return native_scan_result;
+ return true;
}
ScanParam OffloadScanUtils::createScanParam(
// Provides utility methods for Offload Scan Manager
class OffloadScanUtils {
public:
- static std::vector<::com::android::server::wifi::wificond::NativeScanResult>
- convertToNativeScanResults(
- const std::vector<android::hardware::wifi::offload::V1_0::ScanResult>&);
+ static bool convertToNativeScanResults(
+ const std::vector<android::hardware::wifi::offload::V1_0::ScanResult>&,
+ std::vector<::com::android::server::wifi::wificond::NativeScanResult>*);
static android::hardware::wifi::offload::V1_0::ScanParam createScanParam(
const std::vector<std::vector<uint8_t>>& ssid_list,
const std::vector<uint32_t>& frequency_list, uint32_t scan_interval_ms);
: num_scans_requested_by_wifi_(0),
num_scans_serviced_by_wifi_(0),
subscription_duration_ms_(0),
+ scan_duration_ms_(0),
num_channels_scanned_(0),
time_stamp_(0) {}
return ::android::OK;
}
+void NativeScanStats::DebugLog() {
+ LOG(INFO) << "num_scans_requested_by_wifi=" << num_scans_requested_by_wifi_;
+ LOG(INFO) << "num_scans_serviced_by_wifi=" << num_scans_serviced_by_wifi_;
+ LOG(INFO) << "subscription_duration=" << subscription_duration_ms_;
+ LOG(INFO) << "scan_duration_ms_=" << scan_duration_ms_;
+ LOG(INFO) << "num_channels_scanned=" << num_channels_scanned_;
+ for (size_t i = 0; i < histogram_channels_.size(); i++) {
+ if (histogram_channels_[i] > 0) {
+ LOG(INFO) << "Channel=" << i << " ScannedTimes="
+ << static_cast<uint32_t>(histogram_channels_[i]);
+ }
+ }
+}
+
} // namespace wificond
} // namespace wifi
} // namespace server
bool operator==(const NativeScanStats&) const;
::android::status_t writeToParcel(::android::Parcel* parcel) const override;
::android::status_t readFromParcel(const ::android::Parcel* parcel) override;
+ void DebugLog();
uint32_t num_scans_requested_by_wifi_;
uint32_t num_scans_serviced_by_wifi_;
void ScannerImpl::OnOffloadError(
OffloadScanCallbackInterface::AsyncErrorReason error_code) {
- bool success;
if (!pno_scan_running_over_offload_) {
// Ignore irrelevant error notifications
LOG(WARNING) << "Offload HAL Async Error occured but Offload HAL is not "
return;
}
LOG(ERROR) << "Offload Service Async Failure error_code=" << error_code;
- // Stop scans over Offload HAL and request them over netlink
- stopPnoScan(&success);
- if (success) {
- LOG(INFO) << "Pno scans stopped";
- }
switch (error_code) {
case OffloadScanCallbackInterface::AsyncErrorReason::BINDER_DEATH:
+ LOG(ERROR) << "Binder death";
if (pno_scan_event_handler_ != nullptr) {
pno_scan_event_handler_->OnPnoScanOverOffloadFailed(
net::wifi::IPnoScanEvent::PNO_SCAN_OVER_OFFLOAD_BINDER_FAILURE);
}
break;
case OffloadScanCallbackInterface::AsyncErrorReason::REMOTE_FAILURE:
+ LOG(ERROR) << "Remote failure";
if (pno_scan_event_handler_ != nullptr) {
pno_scan_event_handler_->OnPnoScanOverOffloadFailed(
net::wifi::IPnoScanEvent::PNO_SCAN_OVER_OFFLOAD_REMOTE_FAILURE);
LOG(WARNING) << "Invalid Error code";
break;
}
- startPnoScan(pno_settings_, &success);
+ bool success;
+ // Stop scans over Offload HAL and request them over netlink
+ stopPnoScan(&success);
+ if (success) {
+ LOG(INFO) << "Pno scans stopped";
+ }
+ // Restart PNO scans over netlink interface
+ success = StartPnoScanDefault(pno_settings_);
if (success) {
LOG(INFO) << "Pno scans restarted";
}
};
TEST_F(OffloadScanUtilsTest, verifyConversion) {
- vector<NativeScanResult> native_scan_results =
- OffloadScanUtils::convertToNativeScanResults(dummy_scan_results_);
+ vector<NativeScanResult> native_scan_results;
+ EXPECT_TRUE(OffloadScanUtils::convertToNativeScanResults(
+ dummy_scan_results_, &native_scan_results));
EXPECT_EQ(native_scan_results.size(), dummy_scan_results_.size());
for (size_t i = 0; i < native_scan_results.size(); i++) {
EXPECT_EQ(native_scan_results[i].frequency,
dummy_scan_results_[i].frequency);
- EXPECT_EQ(native_scan_results[i].tsf, dummy_scan_results_[i].tsf);
EXPECT_EQ(native_scan_results[i].signal_mbm, dummy_scan_results_[i].rssi);
EXPECT_EQ(native_scan_results[i].ssid.size(),
dummy_scan_results_[i].networkInfo.ssid.size());