blob: 4e8321e8a017b5880ba667f2428ccc598f55a70e [file] [log] [blame]
Gabriel Birenf3262f92022-07-15 23:25:39 +00001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "wifi_legacy_hal.h"
18
19#include <android-base/logging.h>
20#include <cutils/properties.h>
21#include <net/if.h>
22
23#include <array>
24#include <chrono>
25
26#include "aidl_sync_util.h"
27#include "wifi_legacy_hal_stubs.h"
28
29namespace {
30// Constants ported over from the legacy HAL calling code
31// (com_android_server_wifi_WifiNative.cpp). This will all be thrown
32// away when this shim layer is replaced by the real vendor
33// implementation.
34static constexpr uint32_t kMaxVersionStringLength = 256;
35static constexpr uint32_t kMaxCachedGscanResults = 64;
36static constexpr uint32_t kMaxGscanFrequenciesForBand = 64;
37static constexpr uint32_t kLinkLayerStatsDataMpduSizeThreshold = 128;
38static constexpr uint32_t kMaxWakeReasonStatsArraySize = 32;
39static constexpr uint32_t kMaxRingBuffers = 10;
40static constexpr uint32_t kMaxWifiUsableChannels = 256;
41static constexpr uint32_t kMaxSupportedRadioCombinationsMatrixLength = 256;
42// Need a long timeout (1000ms) for chips that unload their driver.
43static constexpr uint32_t kMaxStopCompleteWaitMs = 1000;
44static constexpr char kDriverPropName[] = "wlan.driver.status";
45
46// Helper function to create a non-const char* for legacy Hal API's.
47std::vector<char> makeCharVec(const std::string& str) {
48 std::vector<char> vec(str.size() + 1);
49 vec.assign(str.begin(), str.end());
50 vec.push_back('\0');
51 return vec;
52}
53} // namespace
54
55namespace aidl {
56namespace android {
57namespace hardware {
58namespace wifi {
59namespace legacy_hal {
60
61// Legacy HAL functions accept "C" style function pointers, so use global
62// functions to pass to the legacy HAL function and store the corresponding
63// std::function methods to be invoked.
64//
65// Callback to be invoked once |stop| is complete
66std::function<void(wifi_handle handle)> on_stop_complete_internal_callback;
67void onAsyncStopComplete(wifi_handle handle) {
68 const auto lock = aidl_sync_util::acquireGlobalLock();
69 if (on_stop_complete_internal_callback) {
70 on_stop_complete_internal_callback(handle);
71 // Invalidate this callback since we don't want this firing again.
72 on_stop_complete_internal_callback = nullptr;
73 }
74}
75
76// Callback to be invoked for driver dump.
77std::function<void(char*, int)> on_driver_memory_dump_internal_callback;
78void onSyncDriverMemoryDump(char* buffer, int buffer_size) {
79 if (on_driver_memory_dump_internal_callback) {
80 on_driver_memory_dump_internal_callback(buffer, buffer_size);
81 }
82}
83
84// Callback to be invoked for firmware dump.
85std::function<void(char*, int)> on_firmware_memory_dump_internal_callback;
86void onSyncFirmwareMemoryDump(char* buffer, int buffer_size) {
87 if (on_firmware_memory_dump_internal_callback) {
88 on_firmware_memory_dump_internal_callback(buffer, buffer_size);
89 }
90}
91
92// Callback to be invoked for Gscan events.
93std::function<void(wifi_request_id, wifi_scan_event)> on_gscan_event_internal_callback;
94void onAsyncGscanEvent(wifi_request_id id, wifi_scan_event event) {
95 const auto lock = aidl_sync_util::acquireGlobalLock();
96 if (on_gscan_event_internal_callback) {
97 on_gscan_event_internal_callback(id, event);
98 }
99}
100
101// Callback to be invoked for Gscan full results.
102std::function<void(wifi_request_id, wifi_scan_result*, uint32_t)>
103 on_gscan_full_result_internal_callback;
104void onAsyncGscanFullResult(wifi_request_id id, wifi_scan_result* result,
105 uint32_t buckets_scanned) {
106 const auto lock = aidl_sync_util::acquireGlobalLock();
107 if (on_gscan_full_result_internal_callback) {
108 on_gscan_full_result_internal_callback(id, result, buckets_scanned);
109 }
110}
111
112// Callback to be invoked for link layer stats results.
113std::function<void((wifi_request_id, wifi_iface_stat*, int, wifi_radio_stat*))>
114 on_link_layer_stats_result_internal_callback;
115void onSyncLinkLayerStatsResult(wifi_request_id id, wifi_iface_stat* iface_stat, int num_radios,
116 wifi_radio_stat* radio_stat) {
117 if (on_link_layer_stats_result_internal_callback) {
118 on_link_layer_stats_result_internal_callback(id, iface_stat, num_radios, radio_stat);
119 }
120}
121
Mahesh KKV5f30d332022-10-26 14:07:44 -0700122// Callback to be invoked for Multi link layer stats results.
123std::function<void((wifi_request_id, wifi_iface_ml_stat*, int, wifi_radio_stat*))>
124 on_link_layer_ml_stats_result_internal_callback;
125void onSyncLinkLayerMlStatsResult(wifi_request_id id, wifi_iface_ml_stat* iface_ml_stat,
126 int num_radios, wifi_radio_stat* radio_stat) {
127 if (on_link_layer_ml_stats_result_internal_callback) {
128 on_link_layer_ml_stats_result_internal_callback(id, iface_ml_stat, num_radios, radio_stat);
129 }
130}
131
Gabriel Birenf3262f92022-07-15 23:25:39 +0000132// Callback to be invoked for rssi threshold breach.
133std::function<void((wifi_request_id, uint8_t*, int8_t))>
134 on_rssi_threshold_breached_internal_callback;
135void onAsyncRssiThresholdBreached(wifi_request_id id, uint8_t* bssid, int8_t rssi) {
136 const auto lock = aidl_sync_util::acquireGlobalLock();
137 if (on_rssi_threshold_breached_internal_callback) {
138 on_rssi_threshold_breached_internal_callback(id, bssid, rssi);
139 }
140}
141
142// Callback to be invoked for ring buffer data indication.
143std::function<void(char*, char*, int, wifi_ring_buffer_status*)>
144 on_ring_buffer_data_internal_callback;
145void onAsyncRingBufferData(char* ring_name, char* buffer, int buffer_size,
146 wifi_ring_buffer_status* status) {
147 const auto lock = aidl_sync_util::acquireGlobalLock();
148 if (on_ring_buffer_data_internal_callback) {
149 on_ring_buffer_data_internal_callback(ring_name, buffer, buffer_size, status);
150 }
151}
152
153// Callback to be invoked for error alert indication.
154std::function<void(wifi_request_id, char*, int, int)> on_error_alert_internal_callback;
155void onAsyncErrorAlert(wifi_request_id id, char* buffer, int buffer_size, int err_code) {
156 const auto lock = aidl_sync_util::acquireGlobalLock();
157 if (on_error_alert_internal_callback) {
158 on_error_alert_internal_callback(id, buffer, buffer_size, err_code);
159 }
160}
161
162// Callback to be invoked for radio mode change indication.
163std::function<void(wifi_request_id, uint32_t, wifi_mac_info*)>
164 on_radio_mode_change_internal_callback;
165void onAsyncRadioModeChange(wifi_request_id id, uint32_t num_macs, wifi_mac_info* mac_infos) {
166 const auto lock = aidl_sync_util::acquireGlobalLock();
167 if (on_radio_mode_change_internal_callback) {
168 on_radio_mode_change_internal_callback(id, num_macs, mac_infos);
169 }
170}
171
172// Callback to be invoked to report subsystem restart
173std::function<void(const char*)> on_subsystem_restart_internal_callback;
174void onAsyncSubsystemRestart(const char* error) {
175 const auto lock = aidl_sync_util::acquireGlobalLock();
176 if (on_subsystem_restart_internal_callback) {
177 on_subsystem_restart_internal_callback(error);
178 }
179}
180
181// Callback to be invoked for rtt results results.
182std::function<void(wifi_request_id, unsigned num_results, wifi_rtt_result* rtt_results[])>
183 on_rtt_results_internal_callback;
Sunil Ravif8fc2372022-11-10 18:37:41 +0000184std::function<void(wifi_request_id, unsigned num_results, wifi_rtt_result_v2* rtt_results_v2[])>
185 on_rtt_results_internal_callback_v2;
186
187void invalidateRttResultsCallbacks() {
188 on_rtt_results_internal_callback = nullptr;
189 on_rtt_results_internal_callback_v2 = nullptr;
190};
191
Gabriel Birenf3262f92022-07-15 23:25:39 +0000192void onAsyncRttResults(wifi_request_id id, unsigned num_results, wifi_rtt_result* rtt_results[]) {
193 const auto lock = aidl_sync_util::acquireGlobalLock();
194 if (on_rtt_results_internal_callback) {
195 on_rtt_results_internal_callback(id, num_results, rtt_results);
Sunil Ravif8fc2372022-11-10 18:37:41 +0000196 invalidateRttResultsCallbacks();
197 }
198}
199
200void onAsyncRttResultsV2(wifi_request_id id, unsigned num_results,
201 wifi_rtt_result_v2* rtt_results_v2[]) {
202 const auto lock = aidl_sync_util::acquireGlobalLock();
203 if (on_rtt_results_internal_callback_v2) {
204 on_rtt_results_internal_callback_v2(id, num_results, rtt_results_v2);
205 invalidateRttResultsCallbacks();
Gabriel Birenf3262f92022-07-15 23:25:39 +0000206 }
207}
208
209// Callbacks for the various NAN operations.
210// NOTE: These have very little conversions to perform before invoking the user
211// callbacks.
212// So, handle all of them here directly to avoid adding an unnecessary layer.
213std::function<void(transaction_id, const NanResponseMsg&)> on_nan_notify_response_user_callback;
214void onAsyncNanNotifyResponse(transaction_id id, NanResponseMsg* msg) {
215 const auto lock = aidl_sync_util::acquireGlobalLock();
216 if (on_nan_notify_response_user_callback && msg) {
217 on_nan_notify_response_user_callback(id, *msg);
218 }
219}
220
221std::function<void(const NanPublishRepliedInd&)> on_nan_event_publish_replied_user_callback;
222void onAsyncNanEventPublishReplied(NanPublishRepliedInd* /* event */) {
223 LOG(ERROR) << "onAsyncNanEventPublishReplied triggered";
224}
225
226std::function<void(const NanPublishTerminatedInd&)> on_nan_event_publish_terminated_user_callback;
227void onAsyncNanEventPublishTerminated(NanPublishTerminatedInd* event) {
228 const auto lock = aidl_sync_util::acquireGlobalLock();
229 if (on_nan_event_publish_terminated_user_callback && event) {
230 on_nan_event_publish_terminated_user_callback(*event);
231 }
232}
233
234std::function<void(const NanMatchInd&)> on_nan_event_match_user_callback;
235void onAsyncNanEventMatch(NanMatchInd* event) {
236 const auto lock = aidl_sync_util::acquireGlobalLock();
237 if (on_nan_event_match_user_callback && event) {
238 on_nan_event_match_user_callback(*event);
239 }
240}
241
242std::function<void(const NanMatchExpiredInd&)> on_nan_event_match_expired_user_callback;
243void onAsyncNanEventMatchExpired(NanMatchExpiredInd* event) {
244 const auto lock = aidl_sync_util::acquireGlobalLock();
245 if (on_nan_event_match_expired_user_callback && event) {
246 on_nan_event_match_expired_user_callback(*event);
247 }
248}
249
250std::function<void(const NanSubscribeTerminatedInd&)>
251 on_nan_event_subscribe_terminated_user_callback;
252void onAsyncNanEventSubscribeTerminated(NanSubscribeTerminatedInd* event) {
253 const auto lock = aidl_sync_util::acquireGlobalLock();
254 if (on_nan_event_subscribe_terminated_user_callback && event) {
255 on_nan_event_subscribe_terminated_user_callback(*event);
256 }
257}
258
259std::function<void(const NanFollowupInd&)> on_nan_event_followup_user_callback;
260void onAsyncNanEventFollowup(NanFollowupInd* event) {
261 const auto lock = aidl_sync_util::acquireGlobalLock();
262 if (on_nan_event_followup_user_callback && event) {
263 on_nan_event_followup_user_callback(*event);
264 }
265}
266
267std::function<void(const NanDiscEngEventInd&)> on_nan_event_disc_eng_event_user_callback;
268void onAsyncNanEventDiscEngEvent(NanDiscEngEventInd* event) {
269 const auto lock = aidl_sync_util::acquireGlobalLock();
270 if (on_nan_event_disc_eng_event_user_callback && event) {
271 on_nan_event_disc_eng_event_user_callback(*event);
272 }
273}
274
275std::function<void(const NanDisabledInd&)> on_nan_event_disabled_user_callback;
276void onAsyncNanEventDisabled(NanDisabledInd* event) {
277 const auto lock = aidl_sync_util::acquireGlobalLock();
278 if (on_nan_event_disabled_user_callback && event) {
279 on_nan_event_disabled_user_callback(*event);
280 }
281}
282
283std::function<void(const NanTCAInd&)> on_nan_event_tca_user_callback;
284void onAsyncNanEventTca(NanTCAInd* event) {
285 const auto lock = aidl_sync_util::acquireGlobalLock();
286 if (on_nan_event_tca_user_callback && event) {
287 on_nan_event_tca_user_callback(*event);
288 }
289}
290
291std::function<void(const NanBeaconSdfPayloadInd&)> on_nan_event_beacon_sdf_payload_user_callback;
292void onAsyncNanEventBeaconSdfPayload(NanBeaconSdfPayloadInd* event) {
293 const auto lock = aidl_sync_util::acquireGlobalLock();
294 if (on_nan_event_beacon_sdf_payload_user_callback && event) {
295 on_nan_event_beacon_sdf_payload_user_callback(*event);
296 }
297}
298
299std::function<void(const NanDataPathRequestInd&)> on_nan_event_data_path_request_user_callback;
300void onAsyncNanEventDataPathRequest(NanDataPathRequestInd* event) {
301 const auto lock = aidl_sync_util::acquireGlobalLock();
302 if (on_nan_event_data_path_request_user_callback && event) {
303 on_nan_event_data_path_request_user_callback(*event);
304 }
305}
306std::function<void(const NanDataPathConfirmInd&)> on_nan_event_data_path_confirm_user_callback;
307void onAsyncNanEventDataPathConfirm(NanDataPathConfirmInd* event) {
308 const auto lock = aidl_sync_util::acquireGlobalLock();
309 if (on_nan_event_data_path_confirm_user_callback && event) {
310 on_nan_event_data_path_confirm_user_callback(*event);
311 }
312}
313
314std::function<void(const NanDataPathEndInd&)> on_nan_event_data_path_end_user_callback;
315void onAsyncNanEventDataPathEnd(NanDataPathEndInd* event) {
316 const auto lock = aidl_sync_util::acquireGlobalLock();
317 if (on_nan_event_data_path_end_user_callback && event) {
318 on_nan_event_data_path_end_user_callback(*event);
319 }
320}
321
322std::function<void(const NanTransmitFollowupInd&)> on_nan_event_transmit_follow_up_user_callback;
323void onAsyncNanEventTransmitFollowUp(NanTransmitFollowupInd* event) {
324 const auto lock = aidl_sync_util::acquireGlobalLock();
325 if (on_nan_event_transmit_follow_up_user_callback && event) {
326 on_nan_event_transmit_follow_up_user_callback(*event);
327 }
328}
329
330std::function<void(const NanRangeRequestInd&)> on_nan_event_range_request_user_callback;
331void onAsyncNanEventRangeRequest(NanRangeRequestInd* event) {
332 const auto lock = aidl_sync_util::acquireGlobalLock();
333 if (on_nan_event_range_request_user_callback && event) {
334 on_nan_event_range_request_user_callback(*event);
335 }
336}
337
338std::function<void(const NanRangeReportInd&)> on_nan_event_range_report_user_callback;
339void onAsyncNanEventRangeReport(NanRangeReportInd* event) {
340 const auto lock = aidl_sync_util::acquireGlobalLock();
341 if (on_nan_event_range_report_user_callback && event) {
342 on_nan_event_range_report_user_callback(*event);
343 }
344}
345
346std::function<void(const NanDataPathScheduleUpdateInd&)> on_nan_event_schedule_update_user_callback;
347void onAsyncNanEventScheduleUpdate(NanDataPathScheduleUpdateInd* event) {
348 const auto lock = aidl_sync_util::acquireGlobalLock();
349 if (on_nan_event_schedule_update_user_callback && event) {
350 on_nan_event_schedule_update_user_callback(*event);
351 }
352}
353
Nate Jiang38e8db52022-12-02 17:30:27 -0800354std::function<void(const NanPairingRequestInd&)> on_nan_event_pairing_request_user_callback;
355void onAsyncNanEventPairingRequest(NanPairingRequestInd* event) {
356 const auto lock = aidl_sync_util::acquireGlobalLock();
357 if (on_nan_event_pairing_request_user_callback && event) {
358 on_nan_event_pairing_request_user_callback(*event);
359 }
360}
361
362std::function<void(const NanPairingConfirmInd&)> on_nan_event_pairing_confirm_user_callback;
363void onAsyncNanEventPairingConfirm(NanPairingConfirmInd* event) {
364 const auto lock = aidl_sync_util::acquireGlobalLock();
365 if (on_nan_event_pairing_confirm_user_callback && event) {
366 on_nan_event_pairing_confirm_user_callback(*event);
367 }
368}
369
370std::function<void(const NanBootstrappingRequestInd&)>
371 on_nan_event_bootstrapping_request_user_callback;
372void onAsyncNanEventBootstrappingRequest(NanBootstrappingRequestInd* event) {
373 const auto lock = aidl_sync_util::acquireGlobalLock();
374 if (on_nan_event_bootstrapping_request_user_callback && event) {
375 on_nan_event_bootstrapping_request_user_callback(*event);
376 }
377}
378
379std::function<void(const NanBootstrappingConfirmInd&)>
380 on_nan_event_bootstrapping_confirm_user_callback;
381void onAsyncNanEventBootstrappingConfirm(NanBootstrappingConfirmInd* event) {
382 const auto lock = aidl_sync_util::acquireGlobalLock();
383 if (on_nan_event_bootstrapping_confirm_user_callback && event) {
384 on_nan_event_bootstrapping_confirm_user_callback(*event);
385 }
386}
387
Gabriel Birenf3262f92022-07-15 23:25:39 +0000388// Callbacks for the various TWT operations.
389std::function<void(const TwtSetupResponse&)> on_twt_event_setup_response_callback;
390void onAsyncTwtEventSetupResponse(TwtSetupResponse* event) {
391 const auto lock = aidl_sync_util::acquireGlobalLock();
392 if (on_twt_event_setup_response_callback && event) {
393 on_twt_event_setup_response_callback(*event);
394 }
395}
396
397std::function<void(const TwtTeardownCompletion&)> on_twt_event_teardown_completion_callback;
398void onAsyncTwtEventTeardownCompletion(TwtTeardownCompletion* event) {
399 const auto lock = aidl_sync_util::acquireGlobalLock();
400 if (on_twt_event_teardown_completion_callback && event) {
401 on_twt_event_teardown_completion_callback(*event);
402 }
403}
404
405std::function<void(const TwtInfoFrameReceived&)> on_twt_event_info_frame_received_callback;
406void onAsyncTwtEventInfoFrameReceived(TwtInfoFrameReceived* event) {
407 const auto lock = aidl_sync_util::acquireGlobalLock();
408 if (on_twt_event_info_frame_received_callback && event) {
409 on_twt_event_info_frame_received_callback(*event);
410 }
411}
412
413std::function<void(const TwtDeviceNotify&)> on_twt_event_device_notify_callback;
414void onAsyncTwtEventDeviceNotify(TwtDeviceNotify* event) {
415 const auto lock = aidl_sync_util::acquireGlobalLock();
416 if (on_twt_event_device_notify_callback && event) {
417 on_twt_event_device_notify_callback(*event);
418 }
419}
420
421// Callback to report current CHRE NAN state
422std::function<void(chre_nan_rtt_state)> on_chre_nan_rtt_internal_callback;
423void onAsyncChreNanRttState(chre_nan_rtt_state state) {
424 const auto lock = aidl_sync_util::acquireGlobalLock();
425 if (on_chre_nan_rtt_internal_callback) {
426 on_chre_nan_rtt_internal_callback(state);
427 }
428}
429
430// Callback to report cached scan results
431std::function<void(wifi_cached_scan_report*)> on_cached_scan_results_internal_callback;
432void onSyncCachedScanResults(wifi_cached_scan_report* cache_report) {
433 if (on_cached_scan_results_internal_callback) {
434 on_cached_scan_results_internal_callback(cache_report);
435 }
436}
437
438// End of the free-standing "C" style callbacks.
439
440WifiLegacyHal::WifiLegacyHal(const std::weak_ptr<::android::wifi_system::InterfaceTool> iface_tool,
441 const wifi_hal_fn& fn, bool is_primary)
442 : global_func_table_(fn),
443 global_handle_(nullptr),
444 awaiting_event_loop_termination_(false),
445 is_started_(false),
446 iface_tool_(iface_tool),
447 is_primary_(is_primary) {}
448
449wifi_error WifiLegacyHal::initialize() {
450 LOG(DEBUG) << "Initialize legacy HAL";
451 // this now does nothing, since HAL function table is provided
452 // to the constructor
453 return WIFI_SUCCESS;
454}
455
456wifi_error WifiLegacyHal::start() {
457 // Ensure that we're starting in a good state.
458 CHECK(global_func_table_.wifi_initialize && !global_handle_ && iface_name_to_handle_.empty() &&
459 !awaiting_event_loop_termination_);
460 if (is_started_) {
461 LOG(DEBUG) << "Legacy HAL already started";
462 return WIFI_SUCCESS;
463 }
464 LOG(DEBUG) << "Waiting for the driver ready";
465 wifi_error status = global_func_table_.wifi_wait_for_driver_ready();
466 if (status == WIFI_ERROR_TIMED_OUT || status == WIFI_ERROR_UNKNOWN) {
467 LOG(ERROR) << "Failed or timed out awaiting driver ready";
468 return status;
469 }
470
471 if (is_primary_) {
472 property_set(kDriverPropName, "ok");
473
474 if (!iface_tool_.lock()->SetWifiUpState(true)) {
475 LOG(ERROR) << "Failed to set WiFi interface up";
476 return WIFI_ERROR_UNKNOWN;
477 }
478 }
479
480 LOG(DEBUG) << "Starting legacy HAL";
481 status = global_func_table_.wifi_initialize(&global_handle_);
482 if (status != WIFI_SUCCESS || !global_handle_) {
483 LOG(ERROR) << "Failed to retrieve global handle";
484 return status;
485 }
486 std::thread(&WifiLegacyHal::runEventLoop, this).detach();
487 status = retrieveIfaceHandles();
488 if (status != WIFI_SUCCESS || iface_name_to_handle_.empty()) {
489 LOG(ERROR) << "Failed to retrieve wlan interface handle";
490 return status;
491 }
492 LOG(DEBUG) << "Legacy HAL start complete";
493 is_started_ = true;
494 return WIFI_SUCCESS;
495}
496
497wifi_error WifiLegacyHal::stop(
498 /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
499 const std::function<void()>& on_stop_complete_user_callback) {
500 if (!is_started_) {
501 LOG(DEBUG) << "Legacy HAL already stopped";
502 on_stop_complete_user_callback();
503 return WIFI_SUCCESS;
504 }
505 LOG(DEBUG) << "Stopping legacy HAL";
506 on_stop_complete_internal_callback = [on_stop_complete_user_callback,
507 this](wifi_handle handle) {
508 CHECK_EQ(global_handle_, handle) << "Handle mismatch";
509 LOG(INFO) << "Legacy HAL stop complete callback received";
510 // Invalidate all the internal pointers now that the HAL is
511 // stopped.
512 invalidate();
513 if (is_primary_) iface_tool_.lock()->SetWifiUpState(false);
514 on_stop_complete_user_callback();
515 is_started_ = false;
516 };
517 awaiting_event_loop_termination_ = true;
518 global_func_table_.wifi_cleanup(global_handle_, onAsyncStopComplete);
519 const auto status =
520 stop_wait_cv_.wait_for(*lock, std::chrono::milliseconds(kMaxStopCompleteWaitMs),
521 [this] { return !awaiting_event_loop_termination_; });
522 if (!status) {
523 LOG(ERROR) << "Legacy HAL stop failed or timed out";
524 return WIFI_ERROR_UNKNOWN;
525 }
526 LOG(DEBUG) << "Legacy HAL stop complete";
527 return WIFI_SUCCESS;
528}
529
530bool WifiLegacyHal::isStarted() {
531 return is_started_;
532}
533
534wifi_error WifiLegacyHal::waitForDriverReady() {
535 return global_func_table_.wifi_wait_for_driver_ready();
536}
537
538std::pair<wifi_error, std::string> WifiLegacyHal::getDriverVersion(const std::string& iface_name) {
539 std::array<char, kMaxVersionStringLength> buffer;
540 buffer.fill(0);
541 wifi_error status = global_func_table_.wifi_get_driver_version(getIfaceHandle(iface_name),
542 buffer.data(), buffer.size());
543 return {status, buffer.data()};
544}
545
546std::pair<wifi_error, std::string> WifiLegacyHal::getFirmwareVersion(
547 const std::string& iface_name) {
548 std::array<char, kMaxVersionStringLength> buffer;
549 buffer.fill(0);
550 wifi_error status = global_func_table_.wifi_get_firmware_version(getIfaceHandle(iface_name),
551 buffer.data(), buffer.size());
552 return {status, buffer.data()};
553}
554
555std::pair<wifi_error, std::vector<uint8_t>> WifiLegacyHal::requestDriverMemoryDump(
556 const std::string& iface_name) {
557 std::vector<uint8_t> driver_dump;
558 on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer, int buffer_size) {
559 driver_dump.insert(driver_dump.end(), reinterpret_cast<uint8_t*>(buffer),
560 reinterpret_cast<uint8_t*>(buffer) + buffer_size);
561 };
562 wifi_error status = global_func_table_.wifi_get_driver_memory_dump(getIfaceHandle(iface_name),
563 {onSyncDriverMemoryDump});
564 on_driver_memory_dump_internal_callback = nullptr;
565 return {status, std::move(driver_dump)};
566}
567
568std::pair<wifi_error, std::vector<uint8_t>> WifiLegacyHal::requestFirmwareMemoryDump(
569 const std::string& iface_name) {
570 std::vector<uint8_t> firmware_dump;
571 on_firmware_memory_dump_internal_callback = [&firmware_dump](char* buffer, int buffer_size) {
572 firmware_dump.insert(firmware_dump.end(), reinterpret_cast<uint8_t*>(buffer),
573 reinterpret_cast<uint8_t*>(buffer) + buffer_size);
574 };
575 wifi_error status = global_func_table_.wifi_get_firmware_memory_dump(
576 getIfaceHandle(iface_name), {onSyncFirmwareMemoryDump});
577 on_firmware_memory_dump_internal_callback = nullptr;
578 return {status, std::move(firmware_dump)};
579}
580
581std::pair<wifi_error, uint64_t> WifiLegacyHal::getSupportedFeatureSet(
582 const std::string& iface_name) {
583 feature_set set = 0, chip_set = 0;
584 wifi_error status = WIFI_SUCCESS;
585
586 static_assert(sizeof(set) == sizeof(uint64_t),
587 "Some feature_flags can not be represented in output");
588 wifi_interface_handle iface_handle = getIfaceHandle(iface_name);
589
590 global_func_table_.wifi_get_chip_feature_set(
591 global_handle_, &chip_set); /* ignore error, chip_set will stay 0 */
592
593 if (iface_handle) {
594 status = global_func_table_.wifi_get_supported_feature_set(iface_handle, &set);
595 }
596 return {status, static_cast<uint64_t>(set | chip_set)};
597}
598
599std::pair<wifi_error, PacketFilterCapabilities> WifiLegacyHal::getPacketFilterCapabilities(
600 const std::string& iface_name) {
601 PacketFilterCapabilities caps;
602 wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities(
603 getIfaceHandle(iface_name), &caps.version, &caps.max_len);
604 return {status, caps};
605}
606
607wifi_error WifiLegacyHal::setPacketFilter(const std::string& iface_name,
608 const std::vector<uint8_t>& program) {
609 return global_func_table_.wifi_set_packet_filter(getIfaceHandle(iface_name), program.data(),
610 program.size());
611}
612
613std::pair<wifi_error, std::vector<uint8_t>> WifiLegacyHal::readApfPacketFilterData(
614 const std::string& iface_name) {
615 PacketFilterCapabilities caps;
616 wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities(
617 getIfaceHandle(iface_name), &caps.version, &caps.max_len);
618 if (status != WIFI_SUCCESS) {
619 return {status, {}};
620 }
621
622 // Size the buffer to read the entire program & work memory.
623 std::vector<uint8_t> buffer(caps.max_len);
624
625 status = global_func_table_.wifi_read_packet_filter(
626 getIfaceHandle(iface_name), /*src_offset=*/0, buffer.data(), buffer.size());
627 return {status, std::move(buffer)};
628}
629
630std::pair<wifi_error, wifi_gscan_capabilities> WifiLegacyHal::getGscanCapabilities(
631 const std::string& iface_name) {
632 wifi_gscan_capabilities caps;
633 wifi_error status =
634 global_func_table_.wifi_get_gscan_capabilities(getIfaceHandle(iface_name), &caps);
635 return {status, caps};
636}
637
638wifi_error WifiLegacyHal::startGscan(
639 const std::string& iface_name, wifi_request_id id, const wifi_scan_cmd_params& params,
640 const std::function<void(wifi_request_id)>& on_failure_user_callback,
641 const on_gscan_results_callback& on_results_user_callback,
642 const on_gscan_full_result_callback& on_full_result_user_callback) {
643 // If there is already an ongoing background scan, reject new scan requests.
644 if (on_gscan_event_internal_callback || on_gscan_full_result_internal_callback) {
645 return WIFI_ERROR_NOT_AVAILABLE;
646 }
647
648 // This callback will be used to either trigger |on_results_user_callback|
649 // or |on_failure_user_callback|.
650 on_gscan_event_internal_callback = [iface_name, on_failure_user_callback,
651 on_results_user_callback,
652 this](wifi_request_id id, wifi_scan_event event) {
653 switch (event) {
654 case WIFI_SCAN_RESULTS_AVAILABLE:
655 case WIFI_SCAN_THRESHOLD_NUM_SCANS:
656 case WIFI_SCAN_THRESHOLD_PERCENT: {
657 wifi_error status;
658 std::vector<wifi_cached_scan_results> cached_scan_results;
659 std::tie(status, cached_scan_results) = getGscanCachedResults(iface_name);
660 if (status == WIFI_SUCCESS) {
661 on_results_user_callback(id, cached_scan_results);
662 return;
663 }
664 FALLTHROUGH_INTENDED;
665 }
666 // Fall through if failed. Failure to retrieve cached scan
667 // results should trigger a background scan failure.
668 case WIFI_SCAN_FAILED:
669 on_failure_user_callback(id);
670 on_gscan_event_internal_callback = nullptr;
671 on_gscan_full_result_internal_callback = nullptr;
672 return;
673 }
674 LOG(FATAL) << "Unexpected gscan event received: " << event;
675 };
676
677 on_gscan_full_result_internal_callback = [on_full_result_user_callback](
678 wifi_request_id id, wifi_scan_result* result,
679 uint32_t buckets_scanned) {
680 if (result) {
681 on_full_result_user_callback(id, result, buckets_scanned);
682 }
683 };
684
685 wifi_scan_result_handler handler = {onAsyncGscanFullResult, onAsyncGscanEvent};
686 wifi_error status =
687 global_func_table_.wifi_start_gscan(id, getIfaceHandle(iface_name), params, handler);
688 if (status != WIFI_SUCCESS) {
689 on_gscan_event_internal_callback = nullptr;
690 on_gscan_full_result_internal_callback = nullptr;
691 }
692 return status;
693}
694
695wifi_error WifiLegacyHal::stopGscan(const std::string& iface_name, wifi_request_id id) {
696 // If there is no an ongoing background scan, reject stop requests.
697 // TODO(b/32337212): This needs to be handled by the HIDL object because we
698 // need to return the NOT_STARTED error code.
699 if (!on_gscan_event_internal_callback && !on_gscan_full_result_internal_callback) {
700 return WIFI_ERROR_NOT_AVAILABLE;
701 }
702 wifi_error status = global_func_table_.wifi_stop_gscan(id, getIfaceHandle(iface_name));
703 // If the request Id is wrong, don't stop the ongoing background scan. Any
704 // other error should be treated as the end of background scan.
705 if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
706 on_gscan_event_internal_callback = nullptr;
707 on_gscan_full_result_internal_callback = nullptr;
708 }
709 return status;
710}
711
712std::pair<wifi_error, std::vector<uint32_t>> WifiLegacyHal::getValidFrequenciesForBand(
713 const std::string& iface_name, wifi_band band) {
714 static_assert(sizeof(uint32_t) >= sizeof(wifi_channel),
715 "Wifi Channel cannot be represented in output");
716 std::vector<uint32_t> freqs;
717 freqs.resize(kMaxGscanFrequenciesForBand);
718 int32_t num_freqs = 0;
719 wifi_error status = global_func_table_.wifi_get_valid_channels(
720 getIfaceHandle(iface_name), band, freqs.size(),
721 reinterpret_cast<wifi_channel*>(freqs.data()), &num_freqs);
722 CHECK(num_freqs >= 0 && static_cast<uint32_t>(num_freqs) <= kMaxGscanFrequenciesForBand);
723 freqs.resize(num_freqs);
724 return {status, std::move(freqs)};
725}
726
727wifi_error WifiLegacyHal::setDfsFlag(const std::string& iface_name, bool dfs_on) {
728 return global_func_table_.wifi_set_nodfs_flag(getIfaceHandle(iface_name), dfs_on ? 0 : 1);
729}
730
731wifi_error WifiLegacyHal::enableLinkLayerStats(const std::string& iface_name, bool debug) {
732 wifi_link_layer_params params;
733 params.mpdu_size_threshold = kLinkLayerStatsDataMpduSizeThreshold;
734 params.aggressive_statistics_gathering = debug;
735 return global_func_table_.wifi_set_link_stats(getIfaceHandle(iface_name), params);
736}
737
738wifi_error WifiLegacyHal::disableLinkLayerStats(const std::string& iface_name) {
739 // TODO: Do we care about these responses?
740 uint32_t clear_mask_rsp;
741 uint8_t stop_rsp;
742 return global_func_table_.wifi_clear_link_stats(getIfaceHandle(iface_name), 0xFFFFFFFF,
743 &clear_mask_rsp, 1, &stop_rsp);
744}
745
Mahesh KKV5f30d332022-10-26 14:07:44 -0700746// Copies wifi_peer_info* to vector<WifiPeerInfo> and returns poiner to next element.
747wifi_peer_info* WifiLegacyHal::copyPeerInfo(wifi_peer_info* peer_ptr,
748 std::vector<WifiPeerInfo> peers) {
749 WifiPeerInfo peer;
750 peer.peer_info = *peer_ptr;
751 if (peer_ptr->num_rate > 0) {
752 // Copy the rate stats.
753 peer.rate_stats.assign(peer_ptr->rate_stats, peer_ptr->rate_stats + peer_ptr->num_rate);
754 }
755 peer.peer_info.num_rate = 0;
756 // Push peer info.
757 peers.push_back(peer);
758 // Return the address of next peer info.
759 return (wifi_peer_info*)((u8*)peer_ptr + sizeof(wifi_peer_info) +
760 (sizeof(wifi_rate_stat) * peer_ptr->num_rate));
761}
762// Copies wifi_link_stat* to vector<LinkStats> and returns poiner to next element.
763wifi_link_stat* WifiLegacyHal::copyLinkStat(wifi_link_stat* stat_ptr,
764 std::vector<LinkStats> stats) {
765 LinkStats linkStat;
766 linkStat.stat = *stat_ptr;
767 wifi_peer_info* l_peer_info_stats_ptr = stat_ptr->peer_info;
768 for (uint32_t i = 0; i < linkStat.stat.num_peers; i++) {
769 l_peer_info_stats_ptr = copyPeerInfo(l_peer_info_stats_ptr, linkStat.peers);
770 }
771 // Copied all peers to linkStat.peers.
772 linkStat.stat.num_peers = 0;
773 // Push link stat.
774 stats.push_back(linkStat);
775 // Read all peers, return the address of next wifi_link_stat.
776 return (wifi_link_stat*)l_peer_info_stats_ptr;
777}
778
779wifi_error WifiLegacyHal::getLinkLayerStats(const std::string& iface_name,
780 LinkLayerStats& link_stats,
781 LinkLayerMlStats& link_ml_stats) {
Gabriel Birenf3262f92022-07-15 23:25:39 +0000782 LinkLayerStats* link_stats_ptr = &link_stats;
Mahesh KKV5f30d332022-10-26 14:07:44 -0700783 link_stats_ptr->valid = false;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000784
785 on_link_layer_stats_result_internal_callback = [&link_stats_ptr](
786 wifi_request_id /* id */,
787 wifi_iface_stat* iface_stats_ptr,
788 int num_radios,
789 wifi_radio_stat* radio_stats_ptr) {
790 wifi_radio_stat* l_radio_stats_ptr;
791 wifi_peer_info* l_peer_info_stats_ptr;
Mahesh KKV5f30d332022-10-26 14:07:44 -0700792 link_stats_ptr->valid = true;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000793
794 if (iface_stats_ptr != nullptr) {
795 link_stats_ptr->iface = *iface_stats_ptr;
796 l_peer_info_stats_ptr = iface_stats_ptr->peer_info;
797 for (uint32_t i = 0; i < iface_stats_ptr->num_peers; i++) {
798 WifiPeerInfo peer;
799 peer.peer_info = *l_peer_info_stats_ptr;
800 if (l_peer_info_stats_ptr->num_rate > 0) {
801 /* Copy the rate stats */
802 peer.rate_stats.assign(
803 l_peer_info_stats_ptr->rate_stats,
804 l_peer_info_stats_ptr->rate_stats + l_peer_info_stats_ptr->num_rate);
805 }
806 peer.peer_info.num_rate = 0;
807 link_stats_ptr->peers.push_back(peer);
808 l_peer_info_stats_ptr =
809 (wifi_peer_info*)((u8*)l_peer_info_stats_ptr + sizeof(wifi_peer_info) +
810 (sizeof(wifi_rate_stat) *
811 l_peer_info_stats_ptr->num_rate));
812 }
813 link_stats_ptr->iface.num_peers = 0;
814 } else {
815 LOG(ERROR) << "Invalid iface stats in link layer stats";
816 }
817 if (num_radios <= 0 || radio_stats_ptr == nullptr) {
818 LOG(ERROR) << "Invalid radio stats in link layer stats";
819 return;
820 }
821 l_radio_stats_ptr = radio_stats_ptr;
822 for (int i = 0; i < num_radios; i++) {
823 LinkLayerRadioStats radio;
824
825 radio.stats = *l_radio_stats_ptr;
826 // Copy over the tx level array to the separate vector.
827 if (l_radio_stats_ptr->num_tx_levels > 0 &&
828 l_radio_stats_ptr->tx_time_per_levels != nullptr) {
829 radio.tx_time_per_levels.assign(
830 l_radio_stats_ptr->tx_time_per_levels,
831 l_radio_stats_ptr->tx_time_per_levels + l_radio_stats_ptr->num_tx_levels);
832 }
833 radio.stats.num_tx_levels = 0;
834 radio.stats.tx_time_per_levels = nullptr;
835 /* Copy over the channel stat to separate vector */
836 if (l_radio_stats_ptr->num_channels > 0) {
837 /* Copy the channel stats */
838 radio.channel_stats.assign(
839 l_radio_stats_ptr->channels,
840 l_radio_stats_ptr->channels + l_radio_stats_ptr->num_channels);
841 }
842 link_stats_ptr->radios.push_back(radio);
843 l_radio_stats_ptr =
844 (wifi_radio_stat*)((u8*)l_radio_stats_ptr + sizeof(wifi_radio_stat) +
845 (sizeof(wifi_channel_stat) *
846 l_radio_stats_ptr->num_channels));
847 }
848 };
849
Mahesh KKV5f30d332022-10-26 14:07:44 -0700850 LinkLayerMlStats* link_ml_stats_ptr = &link_ml_stats;
851 link_ml_stats_ptr->valid = false;
852
853 on_link_layer_ml_stats_result_internal_callback =
854 [this, &link_ml_stats_ptr](wifi_request_id /* id */,
855 wifi_iface_ml_stat* iface_ml_stats_ptr, int num_radios,
856 wifi_radio_stat* radio_stats_ptr) {
857 wifi_radio_stat* l_radio_stats_ptr;
858 wifi_link_stat* l_link_stat_ptr;
859 link_ml_stats_ptr->valid = true;
860
861 if (iface_ml_stats_ptr != nullptr && iface_ml_stats_ptr->num_links > 0) {
862 // Copy stats from wifi_iface_ml_stat to LinkLayerMlStats,
863 // - num_links * links[] to vector of links.
864 // - num_peers * peer_info[] to vector of links[i].peers.
865 link_ml_stats_ptr->iface = *iface_ml_stats_ptr;
866 l_link_stat_ptr = iface_ml_stats_ptr->links;
867 for (int l = 0; l < iface_ml_stats_ptr->num_links; ++l) {
868 l_link_stat_ptr = copyLinkStat(l_link_stat_ptr, link_ml_stats_ptr->links);
869 }
870 } else {
871 LOG(ERROR) << "Invalid iface stats in link layer stats";
872 }
873 if (num_radios <= 0 || radio_stats_ptr == nullptr) {
874 LOG(ERROR) << "Invalid radio stats in link layer stats";
875 return;
876 }
877 l_radio_stats_ptr = radio_stats_ptr;
878 for (int i = 0; i < num_radios; i++) {
879 LinkLayerRadioStats radio;
880
881 radio.stats = *l_radio_stats_ptr;
882 // Copy over the tx level array to the separate vector.
883 if (l_radio_stats_ptr->num_tx_levels > 0 &&
884 l_radio_stats_ptr->tx_time_per_levels != nullptr) {
885 radio.tx_time_per_levels.assign(l_radio_stats_ptr->tx_time_per_levels,
886 l_radio_stats_ptr->tx_time_per_levels +
887 l_radio_stats_ptr->num_tx_levels);
888 }
889 radio.stats.num_tx_levels = 0;
890 radio.stats.tx_time_per_levels = nullptr;
891 /* Copy over the channel stat to separate vector */
892 if (l_radio_stats_ptr->num_channels > 0) {
893 /* Copy the channel stats */
894 radio.channel_stats.assign(
895 l_radio_stats_ptr->channels,
896 l_radio_stats_ptr->channels + l_radio_stats_ptr->num_channels);
897 }
898 link_ml_stats_ptr->radios.push_back(radio);
899 l_radio_stats_ptr =
900 (wifi_radio_stat*)((u8*)l_radio_stats_ptr + sizeof(wifi_radio_stat) +
901 (sizeof(wifi_channel_stat) *
902 l_radio_stats_ptr->num_channels));
903 }
904 };
905
906 wifi_error status = global_func_table_.wifi_get_link_stats(
907 0, getIfaceHandle(iface_name),
908 {onSyncLinkLayerStatsResult, onSyncLinkLayerMlStatsResult});
Gabriel Birenf3262f92022-07-15 23:25:39 +0000909 on_link_layer_stats_result_internal_callback = nullptr;
Mahesh KKV5f30d332022-10-26 14:07:44 -0700910 on_link_layer_ml_stats_result_internal_callback = nullptr;
911
912 return status;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000913}
914
915wifi_error WifiLegacyHal::startRssiMonitoring(
916 const std::string& iface_name, wifi_request_id id, int8_t max_rssi, int8_t min_rssi,
917 const on_rssi_threshold_breached_callback& on_threshold_breached_user_callback) {
918 if (on_rssi_threshold_breached_internal_callback) {
919 return WIFI_ERROR_NOT_AVAILABLE;
920 }
921 on_rssi_threshold_breached_internal_callback = [on_threshold_breached_user_callback](
922 wifi_request_id id, uint8_t* bssid_ptr,
923 int8_t rssi) {
924 if (!bssid_ptr) {
925 return;
926 }
927 std::array<uint8_t, ETH_ALEN> bssid_arr;
928 // |bssid_ptr| pointer is assumed to have 6 bytes for the mac
929 // address.
930 std::copy(bssid_ptr, bssid_ptr + 6, std::begin(bssid_arr));
931 on_threshold_breached_user_callback(id, bssid_arr, rssi);
932 };
933 wifi_error status = global_func_table_.wifi_start_rssi_monitoring(
934 id, getIfaceHandle(iface_name), max_rssi, min_rssi, {onAsyncRssiThresholdBreached});
935 if (status != WIFI_SUCCESS) {
936 on_rssi_threshold_breached_internal_callback = nullptr;
937 }
938 return status;
939}
940
941wifi_error WifiLegacyHal::stopRssiMonitoring(const std::string& iface_name, wifi_request_id id) {
942 if (!on_rssi_threshold_breached_internal_callback) {
943 return WIFI_ERROR_NOT_AVAILABLE;
944 }
945 wifi_error status =
946 global_func_table_.wifi_stop_rssi_monitoring(id, getIfaceHandle(iface_name));
947 // If the request Id is wrong, don't stop the ongoing rssi monitoring. Any
948 // other error should be treated as the end of background scan.
949 if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
950 on_rssi_threshold_breached_internal_callback = nullptr;
951 }
952 return status;
953}
954
955std::pair<wifi_error, wifi_roaming_capabilities> WifiLegacyHal::getRoamingCapabilities(
956 const std::string& iface_name) {
957 wifi_roaming_capabilities caps;
958 wifi_error status =
959 global_func_table_.wifi_get_roaming_capabilities(getIfaceHandle(iface_name), &caps);
960 return {status, caps};
961}
962
963wifi_error WifiLegacyHal::configureRoaming(const std::string& iface_name,
964 const wifi_roaming_config& config) {
965 wifi_roaming_config config_internal = config;
966 return global_func_table_.wifi_configure_roaming(getIfaceHandle(iface_name), &config_internal);
967}
968
969wifi_error WifiLegacyHal::enableFirmwareRoaming(const std::string& iface_name,
970 fw_roaming_state_t state) {
971 return global_func_table_.wifi_enable_firmware_roaming(getIfaceHandle(iface_name), state);
972}
973
974wifi_error WifiLegacyHal::configureNdOffload(const std::string& iface_name, bool enable) {
975 return global_func_table_.wifi_configure_nd_offload(getIfaceHandle(iface_name), enable);
976}
977
978wifi_error WifiLegacyHal::startSendingOffloadedPacket(const std::string& iface_name, int32_t cmd_id,
979 uint16_t ether_type,
980 const std::vector<uint8_t>& ip_packet_data,
981 const std::array<uint8_t, 6>& src_address,
982 const std::array<uint8_t, 6>& dst_address,
983 int32_t period_in_ms) {
984 std::vector<uint8_t> ip_packet_data_internal(ip_packet_data);
985 std::vector<uint8_t> src_address_internal(src_address.data(),
986 src_address.data() + src_address.size());
987 std::vector<uint8_t> dst_address_internal(dst_address.data(),
988 dst_address.data() + dst_address.size());
989 return global_func_table_.wifi_start_sending_offloaded_packet(
990 cmd_id, getIfaceHandle(iface_name), ether_type, ip_packet_data_internal.data(),
991 ip_packet_data_internal.size(), src_address_internal.data(),
992 dst_address_internal.data(), period_in_ms);
993}
994
995wifi_error WifiLegacyHal::stopSendingOffloadedPacket(const std::string& iface_name,
996 uint32_t cmd_id) {
997 return global_func_table_.wifi_stop_sending_offloaded_packet(cmd_id,
998 getIfaceHandle(iface_name));
999}
1000
1001wifi_error WifiLegacyHal::selectTxPowerScenario(const std::string& iface_name,
1002 wifi_power_scenario scenario) {
1003 return global_func_table_.wifi_select_tx_power_scenario(getIfaceHandle(iface_name), scenario);
1004}
1005
1006wifi_error WifiLegacyHal::resetTxPowerScenario(const std::string& iface_name) {
1007 return global_func_table_.wifi_reset_tx_power_scenario(getIfaceHandle(iface_name));
1008}
1009
1010wifi_error WifiLegacyHal::setLatencyMode(const std::string& iface_name, wifi_latency_mode mode) {
1011 return global_func_table_.wifi_set_latency_mode(getIfaceHandle(iface_name), mode);
1012}
1013
1014wifi_error WifiLegacyHal::setThermalMitigationMode(wifi_thermal_mode mode,
1015 uint32_t completion_window) {
1016 return global_func_table_.wifi_set_thermal_mitigation_mode(global_handle_, mode,
1017 completion_window);
1018}
1019
1020wifi_error WifiLegacyHal::setDscpToAccessCategoryMapping(uint32_t start, uint32_t end,
1021 uint32_t access_category) {
1022 return global_func_table_.wifi_map_dscp_access_category(global_handle_, start, end,
1023 access_category);
1024}
1025
1026wifi_error WifiLegacyHal::resetDscpToAccessCategoryMapping() {
1027 return global_func_table_.wifi_reset_dscp_mapping(global_handle_);
1028}
1029
1030std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet(
1031 const std::string& iface_name) {
1032 uint32_t supported_feature_flags = 0;
1033 wifi_error status = WIFI_SUCCESS;
1034
1035 wifi_interface_handle iface_handle = getIfaceHandle(iface_name);
1036
1037 if (iface_handle) {
1038 status = global_func_table_.wifi_get_logger_supported_feature_set(iface_handle,
1039 &supported_feature_flags);
1040 }
1041 return {status, supported_feature_flags};
1042}
1043
1044wifi_error WifiLegacyHal::startPktFateMonitoring(const std::string& iface_name) {
1045 return global_func_table_.wifi_start_pkt_fate_monitoring(getIfaceHandle(iface_name));
1046}
1047
1048std::pair<wifi_error, std::vector<wifi_tx_report>> WifiLegacyHal::getTxPktFates(
1049 const std::string& iface_name) {
1050 std::vector<wifi_tx_report> tx_pkt_fates;
1051 tx_pkt_fates.resize(MAX_FATE_LOG_LEN);
1052 size_t num_fates = 0;
1053 wifi_error status = global_func_table_.wifi_get_tx_pkt_fates(
1054 getIfaceHandle(iface_name), tx_pkt_fates.data(), tx_pkt_fates.size(), &num_fates);
1055 CHECK(num_fates <= MAX_FATE_LOG_LEN);
1056 tx_pkt_fates.resize(num_fates);
1057 return {status, std::move(tx_pkt_fates)};
1058}
1059
1060std::pair<wifi_error, std::vector<wifi_rx_report>> WifiLegacyHal::getRxPktFates(
1061 const std::string& iface_name) {
1062 std::vector<wifi_rx_report> rx_pkt_fates;
1063 rx_pkt_fates.resize(MAX_FATE_LOG_LEN);
1064 size_t num_fates = 0;
1065 wifi_error status = global_func_table_.wifi_get_rx_pkt_fates(
1066 getIfaceHandle(iface_name), rx_pkt_fates.data(), rx_pkt_fates.size(), &num_fates);
1067 CHECK(num_fates <= MAX_FATE_LOG_LEN);
1068 rx_pkt_fates.resize(num_fates);
1069 return {status, std::move(rx_pkt_fates)};
1070}
1071
1072std::pair<wifi_error, WakeReasonStats> WifiLegacyHal::getWakeReasonStats(
1073 const std::string& iface_name) {
1074 WakeReasonStats stats;
1075 stats.cmd_event_wake_cnt.resize(kMaxWakeReasonStatsArraySize);
1076 stats.driver_fw_local_wake_cnt.resize(kMaxWakeReasonStatsArraySize);
1077
1078 // This legacy struct needs separate memory to store the variable sized wake
1079 // reason types.
1080 stats.wake_reason_cnt.cmd_event_wake_cnt =
1081 reinterpret_cast<int32_t*>(stats.cmd_event_wake_cnt.data());
1082 stats.wake_reason_cnt.cmd_event_wake_cnt_sz = stats.cmd_event_wake_cnt.size();
1083 stats.wake_reason_cnt.cmd_event_wake_cnt_used = 0;
1084 stats.wake_reason_cnt.driver_fw_local_wake_cnt =
1085 reinterpret_cast<int32_t*>(stats.driver_fw_local_wake_cnt.data());
1086 stats.wake_reason_cnt.driver_fw_local_wake_cnt_sz = stats.driver_fw_local_wake_cnt.size();
1087 stats.wake_reason_cnt.driver_fw_local_wake_cnt_used = 0;
1088
1089 wifi_error status = global_func_table_.wifi_get_wake_reason_stats(getIfaceHandle(iface_name),
1090 &stats.wake_reason_cnt);
1091
1092 CHECK(stats.wake_reason_cnt.cmd_event_wake_cnt_used >= 0 &&
1093 static_cast<uint32_t>(stats.wake_reason_cnt.cmd_event_wake_cnt_used) <=
1094 kMaxWakeReasonStatsArraySize);
1095 stats.cmd_event_wake_cnt.resize(stats.wake_reason_cnt.cmd_event_wake_cnt_used);
1096 stats.wake_reason_cnt.cmd_event_wake_cnt = nullptr;
1097
1098 CHECK(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used >= 0 &&
1099 static_cast<uint32_t>(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used) <=
1100 kMaxWakeReasonStatsArraySize);
1101 stats.driver_fw_local_wake_cnt.resize(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used);
1102 stats.wake_reason_cnt.driver_fw_local_wake_cnt = nullptr;
1103
1104 return {status, stats};
1105}
1106
1107wifi_error WifiLegacyHal::registerRingBufferCallbackHandler(
1108 const std::string& iface_name, const on_ring_buffer_data_callback& on_user_data_callback) {
1109 if (on_ring_buffer_data_internal_callback) {
1110 return WIFI_ERROR_NOT_AVAILABLE;
1111 }
1112 on_ring_buffer_data_internal_callback = [on_user_data_callback](
1113 char* ring_name, char* buffer, int buffer_size,
1114 wifi_ring_buffer_status* status) {
1115 if (status && buffer) {
1116 std::vector<uint8_t> buffer_vector(reinterpret_cast<uint8_t*>(buffer),
1117 reinterpret_cast<uint8_t*>(buffer) + buffer_size);
1118 on_user_data_callback(ring_name, buffer_vector, *status);
1119 }
1120 };
1121 wifi_error status = global_func_table_.wifi_set_log_handler(0, getIfaceHandle(iface_name),
1122 {onAsyncRingBufferData});
1123 if (status != WIFI_SUCCESS) {
1124 on_ring_buffer_data_internal_callback = nullptr;
1125 }
1126 return status;
1127}
1128
1129wifi_error WifiLegacyHal::deregisterRingBufferCallbackHandler(const std::string& iface_name) {
1130 if (!on_ring_buffer_data_internal_callback) {
1131 return WIFI_ERROR_NOT_AVAILABLE;
1132 }
1133 on_ring_buffer_data_internal_callback = nullptr;
1134 return global_func_table_.wifi_reset_log_handler(0, getIfaceHandle(iface_name));
1135}
1136
1137std::pair<wifi_error, std::vector<wifi_ring_buffer_status>> WifiLegacyHal::getRingBuffersStatus(
1138 const std::string& iface_name) {
1139 std::vector<wifi_ring_buffer_status> ring_buffers_status;
1140 ring_buffers_status.resize(kMaxRingBuffers);
1141 uint32_t num_rings = kMaxRingBuffers;
1142 wifi_error status = global_func_table_.wifi_get_ring_buffers_status(
1143 getIfaceHandle(iface_name), &num_rings, ring_buffers_status.data());
1144 CHECK(num_rings <= kMaxRingBuffers);
1145 ring_buffers_status.resize(num_rings);
1146 return {status, std::move(ring_buffers_status)};
1147}
1148
1149wifi_error WifiLegacyHal::startRingBufferLogging(const std::string& iface_name,
1150 const std::string& ring_name,
1151 uint32_t verbose_level, uint32_t max_interval_sec,
1152 uint32_t min_data_size) {
1153 return global_func_table_.wifi_start_logging(getIfaceHandle(iface_name), verbose_level, 0,
1154 max_interval_sec, min_data_size,
1155 makeCharVec(ring_name).data());
1156}
1157
1158wifi_error WifiLegacyHal::getRingBufferData(const std::string& iface_name,
1159 const std::string& ring_name) {
1160 return global_func_table_.wifi_get_ring_data(getIfaceHandle(iface_name),
1161 makeCharVec(ring_name).data());
1162}
1163
1164wifi_error WifiLegacyHal::registerErrorAlertCallbackHandler(
1165 const std::string& iface_name, const on_error_alert_callback& on_user_alert_callback) {
1166 if (on_error_alert_internal_callback) {
1167 return WIFI_ERROR_NOT_AVAILABLE;
1168 }
1169 on_error_alert_internal_callback = [on_user_alert_callback](wifi_request_id id, char* buffer,
1170 int buffer_size, int err_code) {
1171 if (buffer) {
1172 CHECK(id == 0);
1173 on_user_alert_callback(
1174 err_code,
1175 std::vector<uint8_t>(reinterpret_cast<uint8_t*>(buffer),
1176 reinterpret_cast<uint8_t*>(buffer) + buffer_size));
1177 }
1178 };
1179 wifi_error status = global_func_table_.wifi_set_alert_handler(0, getIfaceHandle(iface_name),
1180 {onAsyncErrorAlert});
1181 if (status != WIFI_SUCCESS) {
1182 on_error_alert_internal_callback = nullptr;
1183 }
1184 return status;
1185}
1186
1187wifi_error WifiLegacyHal::deregisterErrorAlertCallbackHandler(const std::string& iface_name) {
1188 if (!on_error_alert_internal_callback) {
1189 return WIFI_ERROR_NOT_AVAILABLE;
1190 }
1191 on_error_alert_internal_callback = nullptr;
1192 return global_func_table_.wifi_reset_alert_handler(0, getIfaceHandle(iface_name));
1193}
1194
1195wifi_error WifiLegacyHal::registerRadioModeChangeCallbackHandler(
1196 const std::string& iface_name,
1197 const on_radio_mode_change_callback& on_user_change_callback) {
1198 if (on_radio_mode_change_internal_callback) {
1199 return WIFI_ERROR_NOT_AVAILABLE;
1200 }
1201 on_radio_mode_change_internal_callback = [on_user_change_callback](
1202 wifi_request_id /* id */, uint32_t num_macs,
1203 wifi_mac_info* mac_infos_arr) {
1204 if (num_macs > 0 && mac_infos_arr) {
1205 std::vector<WifiMacInfo> mac_infos_vec;
1206 for (uint32_t i = 0; i < num_macs; i++) {
1207 WifiMacInfo mac_info;
1208 mac_info.wlan_mac_id = mac_infos_arr[i].wlan_mac_id;
1209 mac_info.mac_band = mac_infos_arr[i].mac_band;
1210 for (int32_t j = 0; j < mac_infos_arr[i].num_iface; j++) {
1211 WifiIfaceInfo iface_info;
1212 iface_info.name = mac_infos_arr[i].iface_info[j].iface_name;
1213 iface_info.channel = mac_infos_arr[i].iface_info[j].channel;
1214 mac_info.iface_infos.push_back(iface_info);
1215 }
1216 mac_infos_vec.push_back(mac_info);
1217 }
1218 on_user_change_callback(mac_infos_vec);
1219 }
1220 };
1221 wifi_error status = global_func_table_.wifi_set_radio_mode_change_handler(
1222 0, getIfaceHandle(iface_name), {onAsyncRadioModeChange});
1223 if (status != WIFI_SUCCESS) {
1224 on_radio_mode_change_internal_callback = nullptr;
1225 }
1226 return status;
1227}
1228
1229wifi_error WifiLegacyHal::registerSubsystemRestartCallbackHandler(
1230 const on_subsystem_restart_callback& on_restart_callback) {
1231 if (on_subsystem_restart_internal_callback) {
1232 return WIFI_ERROR_NOT_AVAILABLE;
1233 }
1234 on_subsystem_restart_internal_callback = [on_restart_callback](const char* error) {
1235 on_restart_callback(error);
1236 };
1237 wifi_error status = global_func_table_.wifi_set_subsystem_restart_handler(
1238 global_handle_, {onAsyncSubsystemRestart});
1239 if (status != WIFI_SUCCESS) {
1240 on_subsystem_restart_internal_callback = nullptr;
1241 }
1242 return status;
1243}
1244
1245wifi_error WifiLegacyHal::startRttRangeRequest(
1246 const std::string& iface_name, wifi_request_id id,
1247 const std::vector<wifi_rtt_config>& rtt_configs,
Sunil Ravif8fc2372022-11-10 18:37:41 +00001248 const on_rtt_results_callback& on_results_user_callback,
1249 const on_rtt_results_callback_v2& on_results_user_callback_v2) {
1250 if (on_rtt_results_internal_callback || on_rtt_results_internal_callback_v2) {
Gabriel Birenf3262f92022-07-15 23:25:39 +00001251 return WIFI_ERROR_NOT_AVAILABLE;
1252 }
1253
1254 on_rtt_results_internal_callback = [on_results_user_callback](wifi_request_id id,
1255 unsigned num_results,
1256 wifi_rtt_result* rtt_results[]) {
1257 if (num_results > 0 && !rtt_results) {
1258 LOG(ERROR) << "Unexpected nullptr in RTT results";
1259 return;
1260 }
1261 std::vector<const wifi_rtt_result*> rtt_results_vec;
1262 std::copy_if(rtt_results, rtt_results + num_results, back_inserter(rtt_results_vec),
1263 [](wifi_rtt_result* rtt_result) { return rtt_result != nullptr; });
1264 on_results_user_callback(id, rtt_results_vec);
1265 };
1266
Sunil Ravif8fc2372022-11-10 18:37:41 +00001267 on_rtt_results_internal_callback_v2 = [on_results_user_callback_v2](
1268 wifi_request_id id, unsigned num_results,
1269 wifi_rtt_result_v2* rtt_results_v2[]) {
1270 if (num_results > 0 && !rtt_results_v2) {
1271 LOG(ERROR) << "Unexpected nullptr in RTT results";
1272 return;
1273 }
1274 std::vector<const wifi_rtt_result_v2*> rtt_results_vec_v2;
1275 std::copy_if(rtt_results_v2, rtt_results_v2 + num_results,
1276 back_inserter(rtt_results_vec_v2),
1277 [](wifi_rtt_result_v2* rtt_result_v2) { return rtt_result_v2 != nullptr; });
1278 on_results_user_callback_v2(id, rtt_results_vec_v2);
1279 };
1280
Gabriel Birenf3262f92022-07-15 23:25:39 +00001281 std::vector<wifi_rtt_config> rtt_configs_internal(rtt_configs);
1282 wifi_error status = global_func_table_.wifi_rtt_range_request(
1283 id, getIfaceHandle(iface_name), rtt_configs.size(), rtt_configs_internal.data(),
Sunil Ravif8fc2372022-11-10 18:37:41 +00001284 {onAsyncRttResults, onAsyncRttResultsV2});
Gabriel Birenf3262f92022-07-15 23:25:39 +00001285 if (status != WIFI_SUCCESS) {
Sunil Ravif8fc2372022-11-10 18:37:41 +00001286 invalidateRttResultsCallbacks();
Gabriel Birenf3262f92022-07-15 23:25:39 +00001287 }
1288 return status;
1289}
1290
1291wifi_error WifiLegacyHal::cancelRttRangeRequest(
1292 const std::string& iface_name, wifi_request_id id,
1293 const std::vector<std::array<uint8_t, ETH_ALEN>>& mac_addrs) {
Sunil Ravif8fc2372022-11-10 18:37:41 +00001294 if (!on_rtt_results_internal_callback && !on_rtt_results_internal_callback_v2) {
Gabriel Birenf3262f92022-07-15 23:25:39 +00001295 return WIFI_ERROR_NOT_AVAILABLE;
1296 }
1297 static_assert(sizeof(mac_addr) == sizeof(std::array<uint8_t, ETH_ALEN>),
1298 "MAC address size mismatch");
1299 // TODO: How do we handle partial cancels (i.e only a subset of enabled mac
1300 // addressed are cancelled).
1301 std::vector<std::array<uint8_t, ETH_ALEN>> mac_addrs_internal(mac_addrs);
1302 wifi_error status = global_func_table_.wifi_rtt_range_cancel(
1303 id, getIfaceHandle(iface_name), mac_addrs.size(),
1304 reinterpret_cast<mac_addr*>(mac_addrs_internal.data()));
1305 // If the request Id is wrong, don't stop the ongoing range request. Any
1306 // other error should be treated as the end of rtt ranging.
1307 if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
Sunil Ravif8fc2372022-11-10 18:37:41 +00001308 invalidateRttResultsCallbacks();
Gabriel Birenf3262f92022-07-15 23:25:39 +00001309 }
1310 return status;
1311}
1312
1313std::pair<wifi_error, wifi_rtt_capabilities> WifiLegacyHal::getRttCapabilities(
1314 const std::string& iface_name) {
1315 wifi_rtt_capabilities rtt_caps;
1316 wifi_error status =
1317 global_func_table_.wifi_get_rtt_capabilities(getIfaceHandle(iface_name), &rtt_caps);
1318 return {status, rtt_caps};
1319}
1320
1321std::pair<wifi_error, wifi_rtt_responder> WifiLegacyHal::getRttResponderInfo(
1322 const std::string& iface_name) {
1323 wifi_rtt_responder rtt_responder;
1324 wifi_error status = global_func_table_.wifi_rtt_get_responder_info(getIfaceHandle(iface_name),
1325 &rtt_responder);
1326 return {status, rtt_responder};
1327}
1328
1329wifi_error WifiLegacyHal::enableRttResponder(const std::string& iface_name, wifi_request_id id,
1330 const wifi_channel_info& channel_hint,
1331 uint32_t max_duration_secs,
1332 const wifi_rtt_responder& info) {
1333 wifi_rtt_responder info_internal(info);
1334 return global_func_table_.wifi_enable_responder(id, getIfaceHandle(iface_name), channel_hint,
1335 max_duration_secs, &info_internal);
1336}
1337
1338wifi_error WifiLegacyHal::disableRttResponder(const std::string& iface_name, wifi_request_id id) {
1339 return global_func_table_.wifi_disable_responder(id, getIfaceHandle(iface_name));
1340}
1341
1342wifi_error WifiLegacyHal::setRttLci(const std::string& iface_name, wifi_request_id id,
1343 const wifi_lci_information& info) {
1344 wifi_lci_information info_internal(info);
1345 return global_func_table_.wifi_set_lci(id, getIfaceHandle(iface_name), &info_internal);
1346}
1347
1348wifi_error WifiLegacyHal::setRttLcr(const std::string& iface_name, wifi_request_id id,
1349 const wifi_lcr_information& info) {
1350 wifi_lcr_information info_internal(info);
1351 return global_func_table_.wifi_set_lcr(id, getIfaceHandle(iface_name), &info_internal);
1352}
1353
1354wifi_error WifiLegacyHal::nanRegisterCallbackHandlers(const std::string& iface_name,
1355 const NanCallbackHandlers& user_callbacks) {
1356 on_nan_notify_response_user_callback = user_callbacks.on_notify_response;
1357 on_nan_event_publish_terminated_user_callback = user_callbacks.on_event_publish_terminated;
1358 on_nan_event_match_user_callback = user_callbacks.on_event_match;
1359 on_nan_event_match_expired_user_callback = user_callbacks.on_event_match_expired;
1360 on_nan_event_subscribe_terminated_user_callback = user_callbacks.on_event_subscribe_terminated;
1361 on_nan_event_followup_user_callback = user_callbacks.on_event_followup;
1362 on_nan_event_disc_eng_event_user_callback = user_callbacks.on_event_disc_eng_event;
1363 on_nan_event_disabled_user_callback = user_callbacks.on_event_disabled;
1364 on_nan_event_tca_user_callback = user_callbacks.on_event_tca;
1365 on_nan_event_beacon_sdf_payload_user_callback = user_callbacks.on_event_beacon_sdf_payload;
1366 on_nan_event_data_path_request_user_callback = user_callbacks.on_event_data_path_request;
Nate Jiang38e8db52022-12-02 17:30:27 -08001367 on_nan_event_pairing_request_user_callback = user_callbacks.on_event_pairing_request;
1368 on_nan_event_pairing_confirm_user_callback = user_callbacks.on_event_pairing_confirm;
1369 on_nan_event_bootstrapping_request_user_callback =
1370 user_callbacks.on_event_bootstrapping_request;
1371 on_nan_event_bootstrapping_confirm_user_callback =
1372 user_callbacks.on_event_bootstrapping_confirm;
Gabriel Birenf3262f92022-07-15 23:25:39 +00001373 on_nan_event_data_path_confirm_user_callback = user_callbacks.on_event_data_path_confirm;
1374 on_nan_event_data_path_end_user_callback = user_callbacks.on_event_data_path_end;
1375 on_nan_event_transmit_follow_up_user_callback = user_callbacks.on_event_transmit_follow_up;
1376 on_nan_event_range_request_user_callback = user_callbacks.on_event_range_request;
1377 on_nan_event_range_report_user_callback = user_callbacks.on_event_range_report;
1378 on_nan_event_schedule_update_user_callback = user_callbacks.on_event_schedule_update;
1379
Nate Jiang38e8db52022-12-02 17:30:27 -08001380 return global_func_table_.wifi_nan_register_handler(getIfaceHandle(iface_name),
1381 {onAsyncNanNotifyResponse,
1382 onAsyncNanEventPublishReplied,
1383 onAsyncNanEventPublishTerminated,
1384 onAsyncNanEventMatch,
1385 onAsyncNanEventMatchExpired,
1386 onAsyncNanEventSubscribeTerminated,
1387 onAsyncNanEventFollowup,
1388 onAsyncNanEventDiscEngEvent,
1389 onAsyncNanEventDisabled,
1390 onAsyncNanEventTca,
1391 onAsyncNanEventBeaconSdfPayload,
1392 onAsyncNanEventDataPathRequest,
1393 onAsyncNanEventDataPathConfirm,
1394 onAsyncNanEventDataPathEnd,
1395 onAsyncNanEventTransmitFollowUp,
1396 onAsyncNanEventRangeRequest,
1397 onAsyncNanEventRangeReport,
1398 onAsyncNanEventScheduleUpdate,
1399 onAsyncNanEventPairingRequest,
1400 onAsyncNanEventPairingConfirm,
1401 onAsyncNanEventBootstrappingRequest,
1402 onAsyncNanEventBootstrappingConfirm});
Gabriel Birenf3262f92022-07-15 23:25:39 +00001403}
1404
1405wifi_error WifiLegacyHal::nanEnableRequest(const std::string& iface_name, transaction_id id,
1406 const NanEnableRequest& msg) {
1407 NanEnableRequest msg_internal(msg);
1408 return global_func_table_.wifi_nan_enable_request(id, getIfaceHandle(iface_name),
1409 &msg_internal);
1410}
1411
1412wifi_error WifiLegacyHal::nanDisableRequest(const std::string& iface_name, transaction_id id) {
1413 return global_func_table_.wifi_nan_disable_request(id, getIfaceHandle(iface_name));
1414}
1415
1416wifi_error WifiLegacyHal::nanPublishRequest(const std::string& iface_name, transaction_id id,
1417 const NanPublishRequest& msg) {
1418 NanPublishRequest msg_internal(msg);
1419 return global_func_table_.wifi_nan_publish_request(id, getIfaceHandle(iface_name),
1420 &msg_internal);
1421}
1422
1423wifi_error WifiLegacyHal::nanPublishCancelRequest(const std::string& iface_name, transaction_id id,
1424 const NanPublishCancelRequest& msg) {
1425 NanPublishCancelRequest msg_internal(msg);
1426 return global_func_table_.wifi_nan_publish_cancel_request(id, getIfaceHandle(iface_name),
1427 &msg_internal);
1428}
1429
1430wifi_error WifiLegacyHal::nanSubscribeRequest(const std::string& iface_name, transaction_id id,
1431 const NanSubscribeRequest& msg) {
1432 NanSubscribeRequest msg_internal(msg);
1433 return global_func_table_.wifi_nan_subscribe_request(id, getIfaceHandle(iface_name),
1434 &msg_internal);
1435}
1436
1437wifi_error WifiLegacyHal::nanSubscribeCancelRequest(const std::string& iface_name,
1438 transaction_id id,
1439 const NanSubscribeCancelRequest& msg) {
1440 NanSubscribeCancelRequest msg_internal(msg);
1441 return global_func_table_.wifi_nan_subscribe_cancel_request(id, getIfaceHandle(iface_name),
1442 &msg_internal);
1443}
1444
1445wifi_error WifiLegacyHal::nanTransmitFollowupRequest(const std::string& iface_name,
1446 transaction_id id,
1447 const NanTransmitFollowupRequest& msg) {
1448 NanTransmitFollowupRequest msg_internal(msg);
1449 return global_func_table_.wifi_nan_transmit_followup_request(id, getIfaceHandle(iface_name),
1450 &msg_internal);
1451}
1452
1453wifi_error WifiLegacyHal::nanStatsRequest(const std::string& iface_name, transaction_id id,
1454 const NanStatsRequest& msg) {
1455 NanStatsRequest msg_internal(msg);
1456 return global_func_table_.wifi_nan_stats_request(id, getIfaceHandle(iface_name), &msg_internal);
1457}
1458
1459wifi_error WifiLegacyHal::nanConfigRequest(const std::string& iface_name, transaction_id id,
1460 const NanConfigRequest& msg) {
1461 NanConfigRequest msg_internal(msg);
1462 return global_func_table_.wifi_nan_config_request(id, getIfaceHandle(iface_name),
1463 &msg_internal);
1464}
1465
1466wifi_error WifiLegacyHal::nanTcaRequest(const std::string& iface_name, transaction_id id,
1467 const NanTCARequest& msg) {
1468 NanTCARequest msg_internal(msg);
1469 return global_func_table_.wifi_nan_tca_request(id, getIfaceHandle(iface_name), &msg_internal);
1470}
1471
1472wifi_error WifiLegacyHal::nanBeaconSdfPayloadRequest(const std::string& iface_name,
1473 transaction_id id,
1474 const NanBeaconSdfPayloadRequest& msg) {
1475 NanBeaconSdfPayloadRequest msg_internal(msg);
1476 return global_func_table_.wifi_nan_beacon_sdf_payload_request(id, getIfaceHandle(iface_name),
1477 &msg_internal);
1478}
1479
1480std::pair<wifi_error, NanVersion> WifiLegacyHal::nanGetVersion() {
1481 NanVersion version;
1482 wifi_error status = global_func_table_.wifi_nan_get_version(global_handle_, &version);
1483 return {status, version};
1484}
1485
1486wifi_error WifiLegacyHal::nanGetCapabilities(const std::string& iface_name, transaction_id id) {
1487 return global_func_table_.wifi_nan_get_capabilities(id, getIfaceHandle(iface_name));
1488}
1489
1490wifi_error WifiLegacyHal::nanDataInterfaceCreate(const std::string& iface_name, transaction_id id,
1491 const std::string& data_iface_name) {
1492 return global_func_table_.wifi_nan_data_interface_create(id, getIfaceHandle(iface_name),
1493 makeCharVec(data_iface_name).data());
1494}
1495
1496wifi_error WifiLegacyHal::nanDataInterfaceDelete(const std::string& iface_name, transaction_id id,
1497 const std::string& data_iface_name) {
1498 return global_func_table_.wifi_nan_data_interface_delete(id, getIfaceHandle(iface_name),
1499 makeCharVec(data_iface_name).data());
1500}
1501
1502wifi_error WifiLegacyHal::nanDataRequestInitiator(const std::string& iface_name, transaction_id id,
1503 const NanDataPathInitiatorRequest& msg) {
1504 NanDataPathInitiatorRequest msg_internal(msg);
1505 return global_func_table_.wifi_nan_data_request_initiator(id, getIfaceHandle(iface_name),
1506 &msg_internal);
1507}
1508
1509wifi_error WifiLegacyHal::nanDataIndicationResponse(const std::string& iface_name,
1510 transaction_id id,
1511 const NanDataPathIndicationResponse& msg) {
1512 NanDataPathIndicationResponse msg_internal(msg);
1513 return global_func_table_.wifi_nan_data_indication_response(id, getIfaceHandle(iface_name),
1514 &msg_internal);
1515}
1516
Nate Jiang38e8db52022-12-02 17:30:27 -08001517wifi_error WifiLegacyHal::nanPairingRequest(const std::string& iface_name, transaction_id id,
1518 const NanPairingRequest& msg) {
1519 NanPairingRequest msg_internal(msg);
1520 return global_func_table_.wifi_nan_pairing_request(id, getIfaceHandle(iface_name),
1521 &msg_internal);
1522}
1523
1524wifi_error WifiLegacyHal::nanPairingIndicationResponse(const std::string& iface_name,
1525 transaction_id id,
1526 const NanPairingIndicationResponse& msg) {
1527 NanPairingIndicationResponse msg_internal(msg);
1528 return global_func_table_.wifi_nan_pairing_indication_response(id, getIfaceHandle(iface_name),
1529 &msg_internal);
1530}
1531
1532wifi_error WifiLegacyHal::nanBootstrappingRequest(const std::string& iface_name, transaction_id id,
1533 const NanBootstrappingRequest& msg) {
1534 NanBootstrappingRequest msg_internal(msg);
1535 return global_func_table_.wifi_nan_bootstrapping_request(id, getIfaceHandle(iface_name),
1536 &msg_internal);
1537}
1538
1539wifi_error WifiLegacyHal::nanBootstrappingIndicationResponse(
1540 const std::string& iface_name, transaction_id id,
1541 const NanBootstrappingIndicationResponse& msg) {
1542 NanBootstrappingIndicationResponse msg_internal(msg);
1543 return global_func_table_.wifi_nan_bootstrapping_indication_response(
1544 id, getIfaceHandle(iface_name), &msg_internal);
1545}
1546
Gabriel Birenf3262f92022-07-15 23:25:39 +00001547typedef struct {
1548 u8 num_ndp_instances;
1549 NanDataPathId ndp_instance_id;
1550} NanDataPathEndSingleNdpIdRequest;
1551
1552wifi_error WifiLegacyHal::nanDataEnd(const std::string& iface_name, transaction_id id,
1553 uint32_t ndpInstanceId) {
1554 NanDataPathEndSingleNdpIdRequest msg;
1555 msg.num_ndp_instances = 1;
1556 msg.ndp_instance_id = ndpInstanceId;
1557 wifi_error status = global_func_table_.wifi_nan_data_end(id, getIfaceHandle(iface_name),
1558 (NanDataPathEndRequest*)&msg);
1559 return status;
1560}
1561
Nate Jiangbae6fdd2023-02-10 17:16:40 -08001562wifi_error WifiLegacyHal::nanPairingEnd(const std::string& iface_name, transaction_id id,
1563 uint32_t pairingId) {
1564 NanPairingEndRequest msg;
1565 msg.pairing_instance_id = pairingId;
1566 wifi_error status =
1567 global_func_table_.wifi_nan_pairing_end(id, getIfaceHandle(iface_name), &msg);
1568 return status;
1569}
1570
Phill Hayers02a97242022-12-15 16:05:14 +00001571wifi_error WifiLegacyHal::nanSuspendRequest(const std::string& iface_name, transaction_id id,
1572 const NanSuspendRequest& msg) {
1573 NanSuspendRequest msg_internal(msg);
1574 wifi_error status = global_func_table_.wifi_nan_suspend_request(id, getIfaceHandle(iface_name),
1575 &msg_internal);
1576 return status;
1577}
1578
1579wifi_error WifiLegacyHal::nanResumeRequest(const std::string& iface_name, transaction_id id,
1580 const NanResumeRequest& msg) {
1581 NanResumeRequest msg_internal(msg);
1582 wifi_error status = global_func_table_.wifi_nan_resume_request(id, getIfaceHandle(iface_name),
1583 &msg_internal);
1584 return status;
1585}
1586
Gabriel Birenf3262f92022-07-15 23:25:39 +00001587wifi_error WifiLegacyHal::setCountryCode(const std::string& iface_name,
1588 const std::array<uint8_t, 2> code) {
1589 std::string code_str(code.data(), code.data() + code.size());
1590 return global_func_table_.wifi_set_country_code(getIfaceHandle(iface_name), code_str.c_str());
1591}
1592
1593wifi_error WifiLegacyHal::retrieveIfaceHandles() {
1594 wifi_interface_handle* iface_handles = nullptr;
1595 int num_iface_handles = 0;
1596 wifi_error status =
1597 global_func_table_.wifi_get_ifaces(global_handle_, &num_iface_handles, &iface_handles);
1598 if (status != WIFI_SUCCESS) {
1599 LOG(ERROR) << "Failed to enumerate interface handles";
1600 return status;
1601 }
1602 iface_name_to_handle_.clear();
1603 for (int i = 0; i < num_iface_handles; ++i) {
1604 std::array<char, IFNAMSIZ> iface_name_arr = {};
1605 status = global_func_table_.wifi_get_iface_name(iface_handles[i], iface_name_arr.data(),
1606 iface_name_arr.size());
1607 if (status != WIFI_SUCCESS) {
1608 LOG(WARNING) << "Failed to get interface handle name";
1609 continue;
1610 }
1611 // Assuming the interface name is null terminated since the legacy HAL
1612 // API does not return a size.
1613 std::string iface_name(iface_name_arr.data());
1614 LOG(INFO) << "Adding interface handle for " << iface_name;
1615 iface_name_to_handle_[iface_name] = iface_handles[i];
1616 }
1617 return WIFI_SUCCESS;
1618}
1619
1620wifi_interface_handle WifiLegacyHal::getIfaceHandle(const std::string& iface_name) {
1621 const auto iface_handle_iter = iface_name_to_handle_.find(iface_name);
1622 if (iface_handle_iter == iface_name_to_handle_.end()) {
1623 LOG(ERROR) << "Unknown iface name: " << iface_name;
1624 return nullptr;
1625 }
1626 return iface_handle_iter->second;
1627}
1628
1629void WifiLegacyHal::runEventLoop() {
1630 LOG(DEBUG) << "Starting legacy HAL event loop";
1631 global_func_table_.wifi_event_loop(global_handle_);
1632 const auto lock = aidl_sync_util::acquireGlobalLock();
1633 if (!awaiting_event_loop_termination_) {
1634 LOG(FATAL) << "Legacy HAL event loop terminated, but HAL was not stopping";
1635 }
1636 LOG(DEBUG) << "Legacy HAL event loop terminated";
1637 awaiting_event_loop_termination_ = false;
1638 stop_wait_cv_.notify_one();
1639}
1640
1641std::pair<wifi_error, std::vector<wifi_cached_scan_results>> WifiLegacyHal::getGscanCachedResults(
1642 const std::string& iface_name) {
1643 std::vector<wifi_cached_scan_results> cached_scan_results;
1644 cached_scan_results.resize(kMaxCachedGscanResults);
1645 int32_t num_results = 0;
1646 wifi_error status = global_func_table_.wifi_get_cached_gscan_results(
1647 getIfaceHandle(iface_name), true /* always flush */, cached_scan_results.size(),
1648 cached_scan_results.data(), &num_results);
1649 CHECK(num_results >= 0 && static_cast<uint32_t>(num_results) <= kMaxCachedGscanResults);
1650 cached_scan_results.resize(num_results);
1651 // Check for invalid IE lengths in these cached scan results and correct it.
1652 for (auto& cached_scan_result : cached_scan_results) {
1653 int num_scan_results = cached_scan_result.num_results;
1654 for (int i = 0; i < num_scan_results; i++) {
1655 auto& scan_result = cached_scan_result.results[i];
1656 if (scan_result.ie_length > 0) {
1657 LOG(DEBUG) << "Cached scan result has non-zero IE length " << scan_result.ie_length;
1658 scan_result.ie_length = 0;
1659 }
1660 }
1661 }
1662 return {status, std::move(cached_scan_results)};
1663}
1664
1665wifi_error WifiLegacyHal::createVirtualInterface(const std::string& ifname,
1666 wifi_interface_type iftype) {
1667 // Create the interface if it doesn't exist. If interface already exist,
1668 // Vendor Hal should return WIFI_SUCCESS.
1669 wifi_error status = global_func_table_.wifi_virtual_interface_create(global_handle_,
1670 ifname.c_str(), iftype);
1671 return handleVirtualInterfaceCreateOrDeleteStatus(ifname, status);
1672}
1673
1674wifi_error WifiLegacyHal::deleteVirtualInterface(const std::string& ifname) {
1675 // Delete the interface if it was created dynamically.
1676 wifi_error status =
1677 global_func_table_.wifi_virtual_interface_delete(global_handle_, ifname.c_str());
1678 return handleVirtualInterfaceCreateOrDeleteStatus(ifname, status);
1679}
1680
1681wifi_error WifiLegacyHal::handleVirtualInterfaceCreateOrDeleteStatus(const std::string& ifname,
1682 wifi_error status) {
1683 if (status == WIFI_SUCCESS) {
1684 // refresh list of handlers now.
1685 status = retrieveIfaceHandles();
1686 } else if (status == WIFI_ERROR_NOT_SUPPORTED) {
1687 // Vendor hal does not implement this API. Such vendor implementations
1688 // are expected to create / delete interface by other means.
1689
1690 // check if interface exists.
1691 if (if_nametoindex(ifname.c_str())) {
1692 status = retrieveIfaceHandles();
1693 }
1694 }
1695 return status;
1696}
1697
1698wifi_error WifiLegacyHal::getSupportedIfaceName(uint32_t iface_type, std::string& ifname) {
1699 std::array<char, IFNAMSIZ> buffer;
1700
1701 wifi_error res = global_func_table_.wifi_get_supported_iface_name(
1702 global_handle_, (uint32_t)iface_type, buffer.data(), buffer.size());
1703 if (res == WIFI_SUCCESS) ifname = buffer.data();
1704
1705 return res;
1706}
1707
1708wifi_error WifiLegacyHal::multiStaSetPrimaryConnection(const std::string& ifname) {
1709 return global_func_table_.wifi_multi_sta_set_primary_connection(global_handle_,
1710 getIfaceHandle(ifname));
1711}
1712
1713wifi_error WifiLegacyHal::multiStaSetUseCase(wifi_multi_sta_use_case use_case) {
1714 return global_func_table_.wifi_multi_sta_set_use_case(global_handle_, use_case);
1715}
1716
1717wifi_error WifiLegacyHal::setCoexUnsafeChannels(
1718 std::vector<wifi_coex_unsafe_channel> unsafe_channels, uint32_t restrictions) {
1719 return global_func_table_.wifi_set_coex_unsafe_channels(global_handle_, unsafe_channels.size(),
1720 unsafe_channels.data(), restrictions);
1721}
1722
1723wifi_error WifiLegacyHal::setVoipMode(const std::string& iface_name, wifi_voip_mode mode) {
1724 return global_func_table_.wifi_set_voip_mode(getIfaceHandle(iface_name), mode);
1725}
1726
1727wifi_error WifiLegacyHal::twtRegisterHandler(const std::string& iface_name,
1728 const TwtCallbackHandlers& user_callbacks) {
1729 on_twt_event_setup_response_callback = user_callbacks.on_setup_response;
1730 on_twt_event_teardown_completion_callback = user_callbacks.on_teardown_completion;
1731 on_twt_event_info_frame_received_callback = user_callbacks.on_info_frame_received;
1732 on_twt_event_device_notify_callback = user_callbacks.on_device_notify;
1733
1734 return global_func_table_.wifi_twt_register_handler(
1735 getIfaceHandle(iface_name),
1736 {onAsyncTwtEventSetupResponse, onAsyncTwtEventTeardownCompletion,
1737 onAsyncTwtEventInfoFrameReceived, onAsyncTwtEventDeviceNotify});
1738}
1739
1740std::pair<wifi_error, TwtCapabilitySet> WifiLegacyHal::twtGetCapability(
1741 const std::string& iface_name) {
1742 TwtCapabilitySet capSet;
1743 wifi_error status =
1744 global_func_table_.wifi_twt_get_capability(getIfaceHandle(iface_name), &capSet);
1745 return {status, capSet};
1746}
1747
1748wifi_error WifiLegacyHal::twtSetupRequest(const std::string& iface_name,
1749 const TwtSetupRequest& msg) {
1750 TwtSetupRequest msgInternal(msg);
1751 return global_func_table_.wifi_twt_setup_request(getIfaceHandle(iface_name), &msgInternal);
1752}
1753
1754wifi_error WifiLegacyHal::twtTearDownRequest(const std::string& iface_name,
1755 const TwtTeardownRequest& msg) {
1756 TwtTeardownRequest msgInternal(msg);
1757 return global_func_table_.wifi_twt_teardown_request(getIfaceHandle(iface_name), &msgInternal);
1758}
1759
1760wifi_error WifiLegacyHal::twtInfoFrameRequest(const std::string& iface_name,
1761 const TwtInfoFrameRequest& msg) {
1762 TwtInfoFrameRequest msgInternal(msg);
1763 return global_func_table_.wifi_twt_info_frame_request(getIfaceHandle(iface_name), &msgInternal);
1764}
1765
1766std::pair<wifi_error, TwtStats> WifiLegacyHal::twtGetStats(const std::string& iface_name,
1767 uint8_t configId) {
1768 TwtStats stats;
1769 wifi_error status =
1770 global_func_table_.wifi_twt_get_stats(getIfaceHandle(iface_name), configId, &stats);
1771 return {status, stats};
1772}
1773
1774wifi_error WifiLegacyHal::twtClearStats(const std::string& iface_name, uint8_t configId) {
1775 return global_func_table_.wifi_twt_clear_stats(getIfaceHandle(iface_name), configId);
1776}
1777
Ye Jiao50274f72023-01-17 14:53:22 +08001778wifi_error WifiLegacyHal::setScanMode(const std::string& iface_name, bool enable) {
1779 return global_func_table_.wifi_set_scan_mode(iface_name.c_str(), enable);
1780}
1781
Gabriel Birenf3262f92022-07-15 23:25:39 +00001782wifi_error WifiLegacyHal::setDtimConfig(const std::string& iface_name, uint32_t multiplier) {
1783 return global_func_table_.wifi_set_dtim_config(getIfaceHandle(iface_name), multiplier);
1784}
1785
1786std::pair<wifi_error, std::vector<wifi_usable_channel>> WifiLegacyHal::getUsableChannels(
1787 uint32_t band_mask, uint32_t iface_mode_mask, uint32_t filter_mask) {
1788 std::vector<wifi_usable_channel> channels;
1789 channels.resize(kMaxWifiUsableChannels);
1790 uint32_t size = 0;
1791 wifi_error status = global_func_table_.wifi_get_usable_channels(
1792 global_handle_, band_mask, iface_mode_mask, filter_mask, channels.size(), &size,
1793 reinterpret_cast<wifi_usable_channel*>(channels.data()));
1794 CHECK(size >= 0 && size <= kMaxWifiUsableChannels);
1795 channels.resize(size);
1796 return {status, std::move(channels)};
1797}
1798
1799wifi_error WifiLegacyHal::triggerSubsystemRestart() {
1800 return global_func_table_.wifi_trigger_subsystem_restart(global_handle_);
1801}
1802
1803wifi_error WifiLegacyHal::setIndoorState(bool isIndoor) {
1804 return global_func_table_.wifi_set_indoor_state(global_handle_, isIndoor);
1805}
1806
1807std::pair<wifi_error, wifi_radio_combination_matrix*>
1808WifiLegacyHal::getSupportedRadioCombinationsMatrix() {
1809 char* buffer = new char[kMaxSupportedRadioCombinationsMatrixLength];
1810 std::fill(buffer, buffer + kMaxSupportedRadioCombinationsMatrixLength, 0);
1811 uint32_t size = 0;
1812 wifi_radio_combination_matrix* radio_combination_matrix_ptr =
1813 reinterpret_cast<wifi_radio_combination_matrix*>(buffer);
1814 wifi_error status = global_func_table_.wifi_get_supported_radio_combinations_matrix(
1815 global_handle_, kMaxSupportedRadioCombinationsMatrixLength, &size,
1816 radio_combination_matrix_ptr);
1817 CHECK(size >= 0 && size <= kMaxSupportedRadioCombinationsMatrixLength);
1818 return {status, radio_combination_matrix_ptr};
1819}
1820
1821wifi_error WifiLegacyHal::chreNanRttRequest(const std::string& iface_name, bool enable) {
1822 if (enable)
1823 return global_func_table_.wifi_nan_rtt_chre_enable_request(0, getIfaceHandle(iface_name),
1824 NULL);
1825 else
1826 return global_func_table_.wifi_nan_rtt_chre_disable_request(0, getIfaceHandle(iface_name));
1827}
1828
1829wifi_error WifiLegacyHal::chreRegisterHandler(const std::string& iface_name,
1830 const ChreCallbackHandlers& handler) {
1831 if (on_chre_nan_rtt_internal_callback) {
1832 return WIFI_ERROR_NOT_AVAILABLE;
1833 }
1834
1835 on_chre_nan_rtt_internal_callback = handler.on_wifi_chre_nan_rtt_state;
1836
1837 wifi_error status = global_func_table_.wifi_chre_register_handler(getIfaceHandle(iface_name),
1838 {onAsyncChreNanRttState});
1839 if (status != WIFI_SUCCESS) {
1840 on_chre_nan_rtt_internal_callback = nullptr;
1841 }
1842 return status;
1843}
1844
1845wifi_error WifiLegacyHal::enableWifiTxPowerLimits(const std::string& iface_name, bool enable) {
1846 return global_func_table_.wifi_enable_tx_power_limits(getIfaceHandle(iface_name), enable);
1847}
1848
1849wifi_error WifiLegacyHal::getWifiCachedScanResults(
1850 const std::string& iface_name, const CachedScanResultsCallbackHandlers& handler) {
1851 on_cached_scan_results_internal_callback = handler.on_cached_scan_results;
1852
1853 wifi_error status = global_func_table_.wifi_get_cached_scan_results(getIfaceHandle(iface_name),
1854 {onSyncCachedScanResults});
1855
1856 on_cached_scan_results_internal_callback = nullptr;
1857 return status;
1858}
1859
Mahesh KKVc84d3772022-12-02 16:53:28 -08001860std::pair<wifi_error, wifi_chip_capabilities> WifiLegacyHal::getWifiChipCapabilities() {
1861 wifi_chip_capabilities chip_capabilities;
1862 wifi_error status =
1863 global_func_table_.wifi_get_chip_capabilities(global_handle_, &chip_capabilities);
1864 return {status, chip_capabilities};
1865}
1866
Shuibing Daie5fbcab2022-12-19 15:37:19 -08001867wifi_error WifiLegacyHal::enableStaChannelForPeerNetwork(uint32_t channelCategoryEnableFlag) {
1868 return global_func_table_.wifi_enable_sta_channel_for_peer_network(global_handle_,
1869 channelCategoryEnableFlag);
1870}
1871
maheshkkva8aba172023-02-13 12:33:26 -08001872wifi_error WifiLegacyHal::setMloMode(wifi_mlo_mode mode) {
1873 return global_func_table_.wifi_set_mlo_mode(global_handle_, mode);
1874}
1875
Gabriel Birenf3262f92022-07-15 23:25:39 +00001876void WifiLegacyHal::invalidate() {
1877 global_handle_ = nullptr;
1878 iface_name_to_handle_.clear();
1879 on_driver_memory_dump_internal_callback = nullptr;
1880 on_firmware_memory_dump_internal_callback = nullptr;
1881 on_gscan_event_internal_callback = nullptr;
1882 on_gscan_full_result_internal_callback = nullptr;
1883 on_link_layer_stats_result_internal_callback = nullptr;
Mahesh KKV5f30d332022-10-26 14:07:44 -07001884 on_link_layer_ml_stats_result_internal_callback = nullptr;
Gabriel Birenf3262f92022-07-15 23:25:39 +00001885 on_rssi_threshold_breached_internal_callback = nullptr;
1886 on_ring_buffer_data_internal_callback = nullptr;
1887 on_error_alert_internal_callback = nullptr;
1888 on_radio_mode_change_internal_callback = nullptr;
1889 on_subsystem_restart_internal_callback = nullptr;
Sunil Ravif8fc2372022-11-10 18:37:41 +00001890 invalidateRttResultsCallbacks();
Gabriel Birenf3262f92022-07-15 23:25:39 +00001891 on_nan_notify_response_user_callback = nullptr;
1892 on_nan_event_publish_terminated_user_callback = nullptr;
1893 on_nan_event_match_user_callback = nullptr;
1894 on_nan_event_match_expired_user_callback = nullptr;
1895 on_nan_event_subscribe_terminated_user_callback = nullptr;
1896 on_nan_event_followup_user_callback = nullptr;
1897 on_nan_event_disc_eng_event_user_callback = nullptr;
1898 on_nan_event_disabled_user_callback = nullptr;
1899 on_nan_event_tca_user_callback = nullptr;
1900 on_nan_event_beacon_sdf_payload_user_callback = nullptr;
1901 on_nan_event_data_path_request_user_callback = nullptr;
Nate Jiang38e8db52022-12-02 17:30:27 -08001902 on_nan_event_pairing_request_user_callback = nullptr;
1903 on_nan_event_pairing_confirm_user_callback = nullptr;
1904 on_nan_event_bootstrapping_request_user_callback = nullptr;
1905 on_nan_event_bootstrapping_confirm_user_callback = nullptr;
Gabriel Birenf3262f92022-07-15 23:25:39 +00001906 on_nan_event_data_path_confirm_user_callback = nullptr;
1907 on_nan_event_data_path_end_user_callback = nullptr;
1908 on_nan_event_transmit_follow_up_user_callback = nullptr;
1909 on_nan_event_range_request_user_callback = nullptr;
1910 on_nan_event_range_report_user_callback = nullptr;
1911 on_nan_event_schedule_update_user_callback = nullptr;
1912 on_twt_event_setup_response_callback = nullptr;
1913 on_twt_event_teardown_completion_callback = nullptr;
1914 on_twt_event_info_frame_received_callback = nullptr;
1915 on_twt_event_device_notify_callback = nullptr;
1916 on_chre_nan_rtt_internal_callback = nullptr;
1917}
1918
1919} // namespace legacy_hal
1920} // namespace wifi
1921} // namespace hardware
1922} // namespace android
1923} // namespace aidl