binder_(new ClientInterfaceBinder(this)) {
scan_utils_->SubscribeScanResultNotification(
interface_index_,
- std::bind(&ClientInterfaceImpl::OnScanResultsReady, this, _1, _2, _3));
+ std::bind(&ClientInterfaceImpl::OnScanResultsReady,
+ this,
+ _1, _2, _3, _4));
}
ClientInterfaceImpl::~ClientInterfaceImpl() {
void ClientInterfaceImpl::OnScanResultsReady(
uint32_t interface_index,
+ bool aborted,
std::vector<std::vector<uint8_t>>& ssids,
std::vector<uint32_t>& frequencies) {
+ if (aborted) {
+ LOG(ERROR) << "Scan aborted";
+ return;
+ }
vector<ScanResult> scan_results;
// TODO(nywang): Find a way to differentiate scan results for
// internel/external scan request. This is useful when location is
// There is another scan result notification: NL80211_CMD_SCHED_SCAN_RESULTS.
// which is used by PNO scan. Wificond is not going to handle that at this
// time.
- if (command == NL80211_CMD_NEW_SCAN_RESULTS) {
+ if (command == NL80211_CMD_NEW_SCAN_RESULTS ||
+ // Scan was aborted, for unspecified reasons.partial scan results may be
+ // available.
+ command == NL80211_CMD_SCAN_ABORTED) {
OnScanResultsReady(std::move(packet));
}
}
LOG(ERROR) << "Failed to get interface index from scan result notification";
return;
}
+ bool aborted = false;
+ if (packet->GetCommand() == NL80211_CMD_SCAN_ABORTED) {
+ aborted = true;
+ }
auto handler = on_scan_result_ready_handler_.find(if_index);
if (handler == on_scan_result_ready_handler_.end()) {
vector<vector<uint8_t>> ssids;
NL80211NestedAttr ssids_attr(0);
if (!packet->GetAttribute(NL80211_ATTR_SCAN_SSIDS, &ssids_attr)) {
- LOG(WARNING) << "Failed to get scan ssids from scan result notification";
+ if (!aborted) {
+ LOG(WARNING) << "Failed to get scan ssids from scan result notification";
+ }
} else {
if (!ssids_attr.GetListOfAttributeValues(&ssids)) {
return;
vector<uint32_t> freqs;
NL80211NestedAttr freqs_attr(0);
if (!packet->GetAttribute(NL80211_ATTR_SCAN_FREQUENCIES, &freqs_attr)) {
- LOG(WARNING) << "Failed to get scan freqs from scan result notification";
+ if (!aborted) {
+ LOG(WARNING) << "Failed to get scan freqs from scan result notification";
+ }
} else {
if (!freqs_attr.GetListOfAttributeValues(&freqs)) {
return;
}
}
// Run scan result notification handler.
- handler->second(if_index, ssids, freqs);
+ handler->second(if_index, aborted, ssids, freqs);
}
void NetlinkManager::SubscribeScanResultNotification(
// This describes a type of function handling scan results ready notification.
// |interface_index| is the index of interface which the scan results
// are from.
+// |aborted| is a boolean indicating if this scan request was aborted or not.
// |ssids| is a vector of scan ssids associated with the corresponding
// scan request.
// |frequencies| is a vector of scan frequencies associated with the
// corresponding scan request.
typedef std::function<void(
uint32_t interface_index,
+ bool aborted,
std::vector<std::vector<uint8_t>>& ssids,
std::vector<uint32_t>& frequencies)> OnScanResultsReadyHandler;