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