Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 <array> |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 18 | #include <chrono> |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 19 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 20 | #include <android-base/logging.h> |
Ahmed ElArabawy | 7153e81 | 2018-06-05 11:09:39 -0700 | [diff] [blame] | 21 | #include <cutils/properties.h> |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 22 | |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 23 | #include "hidl_sync_util.h" |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 24 | #include "wifi_legacy_hal.h" |
Roshan Pius | e73a506 | 2016-12-12 08:53:34 -0800 | [diff] [blame] | 25 | #include "wifi_legacy_hal_stubs.h" |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 26 | |
Roshan Pius | 32fc12e | 2017-01-25 17:44:42 -0800 | [diff] [blame] | 27 | namespace { |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 28 | // Constants ported over from the legacy HAL calling code |
| 29 | // (com_android_server_wifi_WifiNative.cpp). This will all be thrown |
| 30 | // away when this shim layer is replaced by the real vendor |
| 31 | // implementation. |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 32 | static constexpr uint32_t kMaxVersionStringLength = 256; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 33 | static constexpr uint32_t kMaxCachedGscanResults = 64; |
| 34 | static constexpr uint32_t kMaxGscanFrequenciesForBand = 64; |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 35 | static constexpr uint32_t kLinkLayerStatsDataMpduSizeThreshold = 128; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 36 | static constexpr uint32_t kMaxWakeReasonStatsArraySize = 32; |
| 37 | static constexpr uint32_t kMaxRingBuffers = 10; |
Roshan Pius | 9bd4e6b | 2017-09-29 15:04:33 -0700 | [diff] [blame] | 38 | static constexpr uint32_t kMaxStopCompleteWaitMs = 100; |
Ahmed ElArabawy | 7153e81 | 2018-06-05 11:09:39 -0700 | [diff] [blame] | 39 | static constexpr char kDriverPropName[] = "wlan.driver.status"; |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 40 | |
Roshan Pius | 32fc12e | 2017-01-25 17:44:42 -0800 | [diff] [blame] | 41 | // Helper function to create a non-const char* for legacy Hal API's. |
| 42 | std::vector<char> makeCharVec(const std::string& str) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 43 | std::vector<char> vec(str.size() + 1); |
| 44 | vec.assign(str.begin(), str.end()); |
| 45 | vec.push_back('\0'); |
| 46 | return vec; |
Roshan Pius | 32fc12e | 2017-01-25 17:44:42 -0800 | [diff] [blame] | 47 | } |
| 48 | } // namespace |
| 49 | |
| 50 | namespace android { |
| 51 | namespace hardware { |
| 52 | namespace wifi { |
Ahmed ElArabawy | f501a98 | 2019-07-23 15:02:22 -0700 | [diff] [blame] | 53 | namespace V1_4 { |
Roshan Pius | 32fc12e | 2017-01-25 17:44:42 -0800 | [diff] [blame] | 54 | namespace implementation { |
| 55 | namespace legacy_hal { |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 56 | // Legacy HAL functions accept "C" style function pointers, so use global |
| 57 | // functions to pass to the legacy HAL function and store the corresponding |
| 58 | // std::function methods to be invoked. |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 59 | // |
| 60 | // Callback to be invoked once |stop| is complete |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 61 | std::function<void(wifi_handle handle)> on_stop_complete_internal_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 62 | void onAsyncStopComplete(wifi_handle handle) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 63 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 64 | if (on_stop_complete_internal_callback) { |
| 65 | on_stop_complete_internal_callback(handle); |
| 66 | // Invalidate this callback since we don't want this firing again. |
| 67 | on_stop_complete_internal_callback = nullptr; |
| 68 | } |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 69 | } |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 70 | |
| 71 | // Callback to be invoked for driver dump. |
| 72 | std::function<void(char*, int)> on_driver_memory_dump_internal_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 73 | void onSyncDriverMemoryDump(char* buffer, int buffer_size) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 74 | if (on_driver_memory_dump_internal_callback) { |
| 75 | on_driver_memory_dump_internal_callback(buffer, buffer_size); |
| 76 | } |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | // Callback to be invoked for firmware dump. |
| 80 | std::function<void(char*, int)> on_firmware_memory_dump_internal_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 81 | void onSyncFirmwareMemoryDump(char* buffer, int buffer_size) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 82 | if (on_firmware_memory_dump_internal_callback) { |
| 83 | on_firmware_memory_dump_internal_callback(buffer, buffer_size); |
| 84 | } |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 85 | } |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 86 | |
| 87 | // Callback to be invoked for Gscan events. |
| 88 | std::function<void(wifi_request_id, wifi_scan_event)> |
| 89 | on_gscan_event_internal_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 90 | void onAsyncGscanEvent(wifi_request_id id, wifi_scan_event event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 91 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 92 | if (on_gscan_event_internal_callback) { |
| 93 | on_gscan_event_internal_callback(id, event); |
| 94 | } |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | // Callback to be invoked for Gscan full results. |
| 98 | std::function<void(wifi_request_id, wifi_scan_result*, uint32_t)> |
| 99 | on_gscan_full_result_internal_callback; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 100 | void onAsyncGscanFullResult(wifi_request_id id, wifi_scan_result* result, |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 101 | uint32_t buckets_scanned) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 102 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 103 | if (on_gscan_full_result_internal_callback) { |
| 104 | on_gscan_full_result_internal_callback(id, result, buckets_scanned); |
| 105 | } |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 108 | // Callback to be invoked for link layer stats results. |
| 109 | std::function<void((wifi_request_id, wifi_iface_stat*, int, wifi_radio_stat*))> |
| 110 | on_link_layer_stats_result_internal_callback; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 111 | void onSyncLinkLayerStatsResult(wifi_request_id id, wifi_iface_stat* iface_stat, |
| 112 | int num_radios, wifi_radio_stat* radio_stat) { |
| 113 | if (on_link_layer_stats_result_internal_callback) { |
| 114 | on_link_layer_stats_result_internal_callback(id, iface_stat, num_radios, |
| 115 | radio_stat); |
| 116 | } |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 119 | // Callback to be invoked for rssi threshold breach. |
| 120 | std::function<void((wifi_request_id, uint8_t*, int8_t))> |
| 121 | on_rssi_threshold_breached_internal_callback; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 122 | void onAsyncRssiThresholdBreached(wifi_request_id id, uint8_t* bssid, |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 123 | int8_t rssi) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 124 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 125 | if (on_rssi_threshold_breached_internal_callback) { |
| 126 | on_rssi_threshold_breached_internal_callback(id, bssid, rssi); |
| 127 | } |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 128 | } |
| 129 | |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 130 | // Callback to be invoked for ring buffer data indication. |
| 131 | std::function<void(char*, char*, int, wifi_ring_buffer_status*)> |
| 132 | on_ring_buffer_data_internal_callback; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 133 | void onAsyncRingBufferData(char* ring_name, char* buffer, int buffer_size, |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 134 | wifi_ring_buffer_status* status) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 135 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 136 | if (on_ring_buffer_data_internal_callback) { |
| 137 | on_ring_buffer_data_internal_callback(ring_name, buffer, buffer_size, |
| 138 | status); |
| 139 | } |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 142 | // Callback to be invoked for error alert indication. |
| 143 | std::function<void(wifi_request_id, char*, int, int)> |
| 144 | on_error_alert_internal_callback; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 145 | void onAsyncErrorAlert(wifi_request_id id, char* buffer, int buffer_size, |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 146 | int err_code) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 147 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 148 | if (on_error_alert_internal_callback) { |
| 149 | on_error_alert_internal_callback(id, buffer, buffer_size, err_code); |
| 150 | } |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 151 | } |
| 152 | |
Roshan Pius | 01f0877 | 2018-01-22 17:56:06 -0800 | [diff] [blame] | 153 | // Callback to be invoked for radio mode change indication. |
| 154 | std::function<void(wifi_request_id, uint32_t, wifi_mac_info*)> |
| 155 | on_radio_mode_change_internal_callback; |
| 156 | void onAsyncRadioModeChange(wifi_request_id id, uint32_t num_macs, |
| 157 | wifi_mac_info* mac_infos) { |
| 158 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 159 | if (on_radio_mode_change_internal_callback) { |
| 160 | on_radio_mode_change_internal_callback(id, num_macs, mac_infos); |
| 161 | } |
| 162 | } |
| 163 | |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 164 | // Callback to be invoked for rtt results results. |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 165 | std::function<void(wifi_request_id, unsigned num_results, |
| 166 | wifi_rtt_result* rtt_results[])> |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 167 | on_rtt_results_internal_callback; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 168 | void onAsyncRttResults(wifi_request_id id, unsigned num_results, |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 169 | wifi_rtt_result* rtt_results[]) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 170 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 171 | if (on_rtt_results_internal_callback) { |
| 172 | on_rtt_results_internal_callback(id, num_results, rtt_results); |
| 173 | on_rtt_results_internal_callback = nullptr; |
| 174 | } |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 177 | // Callbacks for the various NAN operations. |
| 178 | // NOTE: These have very little conversions to perform before invoking the user |
| 179 | // callbacks. |
| 180 | // So, handle all of them here directly to avoid adding an unnecessary layer. |
| 181 | std::function<void(transaction_id, const NanResponseMsg&)> |
| 182 | on_nan_notify_response_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 183 | void onAysncNanNotifyResponse(transaction_id id, NanResponseMsg* msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 184 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 185 | if (on_nan_notify_response_user_callback && msg) { |
| 186 | on_nan_notify_response_user_callback(id, *msg); |
| 187 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 188 | } |
| 189 | |
Etan Cohen | 20925b0 | 2017-04-04 13:00:14 -0700 | [diff] [blame] | 190 | std::function<void(const NanPublishRepliedInd&)> |
| 191 | on_nan_event_publish_replied_user_callback; |
| 192 | void onAysncNanEventPublishReplied(NanPublishRepliedInd* /* event */) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 193 | LOG(ERROR) << "onAysncNanEventPublishReplied triggered"; |
Etan Cohen | 20925b0 | 2017-04-04 13:00:14 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 196 | std::function<void(const NanPublishTerminatedInd&)> |
| 197 | on_nan_event_publish_terminated_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 198 | void onAysncNanEventPublishTerminated(NanPublishTerminatedInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 199 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 200 | if (on_nan_event_publish_terminated_user_callback && event) { |
| 201 | on_nan_event_publish_terminated_user_callback(*event); |
| 202 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | std::function<void(const NanMatchInd&)> on_nan_event_match_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 206 | void onAysncNanEventMatch(NanMatchInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 207 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 208 | if (on_nan_event_match_user_callback && event) { |
| 209 | on_nan_event_match_user_callback(*event); |
| 210 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | std::function<void(const NanMatchExpiredInd&)> |
| 214 | on_nan_event_match_expired_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 215 | void onAysncNanEventMatchExpired(NanMatchExpiredInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 216 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 217 | if (on_nan_event_match_expired_user_callback && event) { |
| 218 | on_nan_event_match_expired_user_callback(*event); |
| 219 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | std::function<void(const NanSubscribeTerminatedInd&)> |
| 223 | on_nan_event_subscribe_terminated_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 224 | void onAysncNanEventSubscribeTerminated(NanSubscribeTerminatedInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 225 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 226 | if (on_nan_event_subscribe_terminated_user_callback && event) { |
| 227 | on_nan_event_subscribe_terminated_user_callback(*event); |
| 228 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | std::function<void(const NanFollowupInd&)> on_nan_event_followup_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 232 | void onAysncNanEventFollowup(NanFollowupInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 233 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 234 | if (on_nan_event_followup_user_callback && event) { |
| 235 | on_nan_event_followup_user_callback(*event); |
| 236 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | std::function<void(const NanDiscEngEventInd&)> |
| 240 | on_nan_event_disc_eng_event_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 241 | void onAysncNanEventDiscEngEvent(NanDiscEngEventInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 242 | const auto lock = hidl_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 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | std::function<void(const NanDisabledInd&)> on_nan_event_disabled_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 249 | void onAysncNanEventDisabled(NanDisabledInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 250 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 251 | if (on_nan_event_disabled_user_callback && event) { |
| 252 | on_nan_event_disabled_user_callback(*event); |
| 253 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | std::function<void(const NanTCAInd&)> on_nan_event_tca_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 257 | void onAysncNanEventTca(NanTCAInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 258 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 259 | if (on_nan_event_tca_user_callback && event) { |
| 260 | on_nan_event_tca_user_callback(*event); |
| 261 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | std::function<void(const NanBeaconSdfPayloadInd&)> |
| 265 | on_nan_event_beacon_sdf_payload_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 266 | void onAysncNanEventBeaconSdfPayload(NanBeaconSdfPayloadInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 267 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 268 | if (on_nan_event_beacon_sdf_payload_user_callback && event) { |
| 269 | on_nan_event_beacon_sdf_payload_user_callback(*event); |
| 270 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | std::function<void(const NanDataPathRequestInd&)> |
| 274 | on_nan_event_data_path_request_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 275 | void onAysncNanEventDataPathRequest(NanDataPathRequestInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 276 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 277 | if (on_nan_event_data_path_request_user_callback && event) { |
| 278 | on_nan_event_data_path_request_user_callback(*event); |
| 279 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 280 | } |
| 281 | std::function<void(const NanDataPathConfirmInd&)> |
| 282 | on_nan_event_data_path_confirm_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 283 | void onAysncNanEventDataPathConfirm(NanDataPathConfirmInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 284 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 285 | if (on_nan_event_data_path_confirm_user_callback && event) { |
| 286 | on_nan_event_data_path_confirm_user_callback(*event); |
| 287 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | std::function<void(const NanDataPathEndInd&)> |
| 291 | on_nan_event_data_path_end_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 292 | void onAysncNanEventDataPathEnd(NanDataPathEndInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 293 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 294 | if (on_nan_event_data_path_end_user_callback && event) { |
| 295 | on_nan_event_data_path_end_user_callback(*event); |
| 296 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | std::function<void(const NanTransmitFollowupInd&)> |
| 300 | on_nan_event_transmit_follow_up_user_callback; |
Roshan Pius | 091e1c1 | 2017-01-30 16:40:50 -0800 | [diff] [blame] | 301 | void onAysncNanEventTransmitFollowUp(NanTransmitFollowupInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 302 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 303 | if (on_nan_event_transmit_follow_up_user_callback && event) { |
| 304 | on_nan_event_transmit_follow_up_user_callback(*event); |
| 305 | } |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 306 | } |
Etan Cohen | c190f93 | 2017-02-17 13:06:55 -0800 | [diff] [blame] | 307 | |
| 308 | std::function<void(const NanRangeRequestInd&)> |
| 309 | on_nan_event_range_request_user_callback; |
| 310 | void onAysncNanEventRangeRequest(NanRangeRequestInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 311 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 312 | if (on_nan_event_range_request_user_callback && event) { |
| 313 | on_nan_event_range_request_user_callback(*event); |
| 314 | } |
Etan Cohen | c190f93 | 2017-02-17 13:06:55 -0800 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | std::function<void(const NanRangeReportInd&)> |
| 318 | on_nan_event_range_report_user_callback; |
| 319 | void onAysncNanEventRangeReport(NanRangeReportInd* event) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 320 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 321 | if (on_nan_event_range_report_user_callback && event) { |
| 322 | on_nan_event_range_report_user_callback(*event); |
| 323 | } |
Etan Cohen | c190f93 | 2017-02-17 13:06:55 -0800 | [diff] [blame] | 324 | } |
Etan Cohen | 1bf15f1 | 2017-12-12 16:15:16 -0800 | [diff] [blame] | 325 | |
| 326 | std::function<void(const NanDataPathScheduleUpdateInd&)> |
| 327 | on_nan_event_schedule_update_user_callback; |
| 328 | void onAsyncNanEventScheduleUpdate(NanDataPathScheduleUpdateInd* event) { |
| 329 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 330 | if (on_nan_event_schedule_update_user_callback && event) { |
| 331 | on_nan_event_schedule_update_user_callback(*event); |
| 332 | } |
| 333 | } |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 334 | // End of the free-standing "C" style callbacks. |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 335 | |
Roshan Pius | c885df0 | 2019-05-21 14:49:05 -0700 | [diff] [blame] | 336 | WifiLegacyHal::WifiLegacyHal( |
| 337 | const std::weak_ptr<wifi_system::InterfaceTool> iface_tool) |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 338 | : global_handle_(nullptr), |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 339 | awaiting_event_loop_termination_(false), |
Roshan Pius | c885df0 | 2019-05-21 14:49:05 -0700 | [diff] [blame] | 340 | is_started_(false), |
| 341 | iface_tool_(iface_tool) {} |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 342 | |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 343 | wifi_error WifiLegacyHal::initialize() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 344 | LOG(DEBUG) << "Initialize legacy HAL"; |
| 345 | // TODO: Add back the HAL Tool if we need to. All we need from the HAL tool |
| 346 | // for now is this function call which we can directly call. |
| 347 | if (!initHalFuncTableWithStubs(&global_func_table_)) { |
| 348 | LOG(ERROR) |
| 349 | << "Failed to initialize legacy hal function table with stubs"; |
| 350 | return WIFI_ERROR_UNKNOWN; |
| 351 | } |
| 352 | wifi_error status = init_wifi_vendor_hal_func_table(&global_func_table_); |
| 353 | if (status != WIFI_SUCCESS) { |
| 354 | LOG(ERROR) << "Failed to initialize legacy hal function table"; |
| 355 | } |
| 356 | return status; |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | wifi_error WifiLegacyHal::start() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 360 | // Ensure that we're starting in a good state. |
| 361 | CHECK(global_func_table_.wifi_initialize && !global_handle_ && |
| 362 | iface_name_to_handle_.empty() && !awaiting_event_loop_termination_); |
| 363 | if (is_started_) { |
| 364 | LOG(DEBUG) << "Legacy HAL already started"; |
| 365 | return WIFI_SUCCESS; |
| 366 | } |
Ahmed ElArabawy | c101815 | 2018-03-02 14:35:04 -0800 | [diff] [blame] | 367 | LOG(DEBUG) << "Waiting for the driver ready"; |
| 368 | wifi_error status = global_func_table_.wifi_wait_for_driver_ready(); |
| 369 | if (status == WIFI_ERROR_TIMED_OUT) { |
| 370 | LOG(ERROR) << "Timed out awaiting driver ready"; |
| 371 | return status; |
| 372 | } |
Ahmed ElArabawy | 7153e81 | 2018-06-05 11:09:39 -0700 | [diff] [blame] | 373 | property_set(kDriverPropName, "ok"); |
| 374 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 375 | LOG(DEBUG) << "Starting legacy HAL"; |
Roshan Pius | c885df0 | 2019-05-21 14:49:05 -0700 | [diff] [blame] | 376 | if (!iface_tool_.lock()->SetWifiUpState(true)) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 377 | LOG(ERROR) << "Failed to set WiFi interface up"; |
| 378 | return WIFI_ERROR_UNKNOWN; |
| 379 | } |
Ahmed ElArabawy | c101815 | 2018-03-02 14:35:04 -0800 | [diff] [blame] | 380 | status = global_func_table_.wifi_initialize(&global_handle_); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 381 | if (status != WIFI_SUCCESS || !global_handle_) { |
| 382 | LOG(ERROR) << "Failed to retrieve global handle"; |
| 383 | return status; |
| 384 | } |
| 385 | std::thread(&WifiLegacyHal::runEventLoop, this).detach(); |
| 386 | status = retrieveIfaceHandles(); |
| 387 | if (status != WIFI_SUCCESS || iface_name_to_handle_.empty()) { |
| 388 | LOG(ERROR) << "Failed to retrieve wlan interface handle"; |
| 389 | return status; |
| 390 | } |
| 391 | LOG(DEBUG) << "Legacy HAL start complete"; |
| 392 | is_started_ = true; |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 393 | return WIFI_SUCCESS; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | wifi_error WifiLegacyHal::stop( |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 397 | /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock, |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 398 | const std::function<void()>& on_stop_complete_user_callback) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 399 | if (!is_started_) { |
| 400 | LOG(DEBUG) << "Legacy HAL already stopped"; |
| 401 | on_stop_complete_user_callback(); |
| 402 | return WIFI_SUCCESS; |
| 403 | } |
| 404 | LOG(DEBUG) << "Stopping legacy HAL"; |
| 405 | on_stop_complete_internal_callback = [on_stop_complete_user_callback, |
| 406 | this](wifi_handle handle) { |
| 407 | CHECK_EQ(global_handle_, handle) << "Handle mismatch"; |
| 408 | LOG(INFO) << "Legacy HAL stop complete callback received"; |
| 409 | // Invalidate all the internal pointers now that the HAL is |
| 410 | // stopped. |
| 411 | invalidate(); |
Roshan Pius | c885df0 | 2019-05-21 14:49:05 -0700 | [diff] [blame] | 412 | iface_tool_.lock()->SetWifiUpState(false); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 413 | on_stop_complete_user_callback(); |
| 414 | is_started_ = false; |
| 415 | }; |
| 416 | awaiting_event_loop_termination_ = true; |
| 417 | global_func_table_.wifi_cleanup(global_handle_, onAsyncStopComplete); |
| 418 | const auto status = stop_wait_cv_.wait_for( |
| 419 | *lock, std::chrono::milliseconds(kMaxStopCompleteWaitMs), |
| 420 | [this] { return !awaiting_event_loop_termination_; }); |
| 421 | if (!status) { |
| 422 | LOG(ERROR) << "Legacy HAL stop failed or timed out"; |
| 423 | return WIFI_ERROR_UNKNOWN; |
| 424 | } |
| 425 | LOG(DEBUG) << "Legacy HAL stop complete"; |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 426 | return WIFI_SUCCESS; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 427 | } |
| 428 | |
Ahmed ElArabawy | 4822938 | 2019-02-07 22:04:53 -0800 | [diff] [blame] | 429 | bool WifiLegacyHal::isStarted() { return is_started_; } |
| 430 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 431 | std::pair<wifi_error, std::string> WifiLegacyHal::getDriverVersion( |
| 432 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 433 | std::array<char, kMaxVersionStringLength> buffer; |
| 434 | buffer.fill(0); |
| 435 | wifi_error status = global_func_table_.wifi_get_driver_version( |
| 436 | getIfaceHandle(iface_name), buffer.data(), buffer.size()); |
| 437 | return {status, buffer.data()}; |
Roshan Pius | 4b26c83 | 2016-10-03 12:49:58 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 440 | std::pair<wifi_error, std::string> WifiLegacyHal::getFirmwareVersion( |
| 441 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 442 | std::array<char, kMaxVersionStringLength> buffer; |
| 443 | buffer.fill(0); |
| 444 | wifi_error status = global_func_table_.wifi_get_firmware_version( |
| 445 | getIfaceHandle(iface_name), buffer.data(), buffer.size()); |
| 446 | return {status, buffer.data()}; |
Roshan Pius | 4b26c83 | 2016-10-03 12:49:58 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 449 | std::pair<wifi_error, std::vector<uint8_t>> |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 450 | WifiLegacyHal::requestDriverMemoryDump(const std::string& iface_name) { |
| 451 | std::vector<uint8_t> driver_dump; |
| 452 | on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer, |
| 453 | int buffer_size) { |
| 454 | driver_dump.insert(driver_dump.end(), |
| 455 | reinterpret_cast<uint8_t*>(buffer), |
| 456 | reinterpret_cast<uint8_t*>(buffer) + buffer_size); |
| 457 | }; |
| 458 | wifi_error status = global_func_table_.wifi_get_driver_memory_dump( |
| 459 | getIfaceHandle(iface_name), {onSyncDriverMemoryDump}); |
| 460 | on_driver_memory_dump_internal_callback = nullptr; |
| 461 | return {status, std::move(driver_dump)}; |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 462 | } |
| 463 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 464 | std::pair<wifi_error, std::vector<uint8_t>> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 465 | WifiLegacyHal::requestFirmwareMemoryDump(const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 466 | std::vector<uint8_t> firmware_dump; |
| 467 | on_firmware_memory_dump_internal_callback = |
| 468 | [&firmware_dump](char* buffer, int buffer_size) { |
| 469 | firmware_dump.insert( |
| 470 | firmware_dump.end(), reinterpret_cast<uint8_t*>(buffer), |
| 471 | reinterpret_cast<uint8_t*>(buffer) + buffer_size); |
| 472 | }; |
| 473 | wifi_error status = global_func_table_.wifi_get_firmware_memory_dump( |
| 474 | getIfaceHandle(iface_name), {onSyncFirmwareMemoryDump}); |
| 475 | on_firmware_memory_dump_internal_callback = nullptr; |
| 476 | return {status, std::move(firmware_dump)}; |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 479 | std::pair<wifi_error, uint32_t> WifiLegacyHal::getSupportedFeatureSet( |
| 480 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 481 | feature_set set; |
Ahmed ElArabawy | 95e36b7 | 2019-11-15 21:24:53 +0000 | [diff] [blame^] | 482 | static_assert(sizeof(set) == sizeof(uint64_t), |
Roshan Pius | 200a17d | 2017-11-01 13:03:35 -0700 | [diff] [blame] | 483 | "Some feature_flags can not be represented in output"); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 484 | wifi_error status = global_func_table_.wifi_get_supported_feature_set( |
| 485 | getIfaceHandle(iface_name), &set); |
| 486 | return {status, static_cast<uint32_t>(set)}; |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | std::pair<wifi_error, PacketFilterCapabilities> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 490 | WifiLegacyHal::getPacketFilterCapabilities(const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 491 | PacketFilterCapabilities caps; |
| 492 | wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities( |
| 493 | getIfaceHandle(iface_name), &caps.version, &caps.max_len); |
| 494 | return {status, caps}; |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 495 | } |
| 496 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 497 | wifi_error WifiLegacyHal::setPacketFilter(const std::string& iface_name, |
| 498 | const std::vector<uint8_t>& program) { |
| 499 | return global_func_table_.wifi_set_packet_filter( |
| 500 | getIfaceHandle(iface_name), program.data(), program.size()); |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 501 | } |
| 502 | |
Bernie Innocenti | 7e6f71a | 2018-03-07 00:17:50 +0900 | [diff] [blame] | 503 | std::pair<wifi_error, std::vector<uint8_t>> |
| 504 | WifiLegacyHal::readApfPacketFilterData(const std::string& iface_name) { |
Bernie Innocenti | 7e6f71a | 2018-03-07 00:17:50 +0900 | [diff] [blame] | 505 | PacketFilterCapabilities caps; |
| 506 | wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities( |
| 507 | getIfaceHandle(iface_name), &caps.version, &caps.max_len); |
| 508 | if (status != WIFI_SUCCESS) { |
| 509 | return {status, {}}; |
| 510 | } |
| 511 | |
| 512 | // Size the buffer to read the entire program & work memory. |
| 513 | std::vector<uint8_t> buffer(caps.max_len); |
| 514 | |
| 515 | status = global_func_table_.wifi_read_packet_filter( |
| 516 | getIfaceHandle(iface_name), /*src_offset=*/0, buffer.data(), |
| 517 | buffer.size()); |
| 518 | return {status, move(buffer)}; |
| 519 | } |
| 520 | |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 521 | std::pair<wifi_error, wifi_gscan_capabilities> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 522 | WifiLegacyHal::getGscanCapabilities(const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 523 | wifi_gscan_capabilities caps; |
| 524 | wifi_error status = global_func_table_.wifi_get_gscan_capabilities( |
| 525 | getIfaceHandle(iface_name), &caps); |
| 526 | return {status, caps}; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | wifi_error WifiLegacyHal::startGscan( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 530 | const std::string& iface_name, wifi_request_id id, |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 531 | const wifi_scan_cmd_params& params, |
| 532 | const std::function<void(wifi_request_id)>& on_failure_user_callback, |
| 533 | const on_gscan_results_callback& on_results_user_callback, |
| 534 | const on_gscan_full_result_callback& on_full_result_user_callback) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 535 | // If there is already an ongoing background scan, reject new scan requests. |
| 536 | if (on_gscan_event_internal_callback || |
| 537 | on_gscan_full_result_internal_callback) { |
| 538 | return WIFI_ERROR_NOT_AVAILABLE; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 539 | } |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 540 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 541 | // This callback will be used to either trigger |on_results_user_callback| |
| 542 | // or |on_failure_user_callback|. |
| 543 | on_gscan_event_internal_callback = |
| 544 | [iface_name, on_failure_user_callback, on_results_user_callback, this]( |
| 545 | wifi_request_id id, wifi_scan_event event) { |
| 546 | switch (event) { |
| 547 | case WIFI_SCAN_RESULTS_AVAILABLE: |
| 548 | case WIFI_SCAN_THRESHOLD_NUM_SCANS: |
| 549 | case WIFI_SCAN_THRESHOLD_PERCENT: { |
| 550 | wifi_error status; |
| 551 | std::vector<wifi_cached_scan_results> cached_scan_results; |
| 552 | std::tie(status, cached_scan_results) = |
| 553 | getGscanCachedResults(iface_name); |
| 554 | if (status == WIFI_SUCCESS) { |
| 555 | on_results_user_callback(id, cached_scan_results); |
| 556 | return; |
| 557 | } |
Tomasz Wasilczyk | b424da7 | 2018-11-15 11:52:57 -0800 | [diff] [blame] | 558 | FALLTHROUGH_INTENDED; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 559 | } |
| 560 | // Fall through if failed. Failure to retrieve cached scan |
| 561 | // results should trigger a background scan failure. |
| 562 | case WIFI_SCAN_FAILED: |
| 563 | on_failure_user_callback(id); |
| 564 | on_gscan_event_internal_callback = nullptr; |
| 565 | on_gscan_full_result_internal_callback = nullptr; |
| 566 | return; |
| 567 | } |
| 568 | LOG(FATAL) << "Unexpected gscan event received: " << event; |
| 569 | }; |
| 570 | |
| 571 | on_gscan_full_result_internal_callback = [on_full_result_user_callback]( |
| 572 | wifi_request_id id, |
| 573 | wifi_scan_result* result, |
| 574 | uint32_t buckets_scanned) { |
| 575 | if (result) { |
| 576 | on_full_result_user_callback(id, result, buckets_scanned); |
| 577 | } |
| 578 | }; |
| 579 | |
| 580 | wifi_scan_result_handler handler = {onAsyncGscanFullResult, |
| 581 | onAsyncGscanEvent}; |
| 582 | wifi_error status = global_func_table_.wifi_start_gscan( |
| 583 | id, getIfaceHandle(iface_name), params, handler); |
| 584 | if (status != WIFI_SUCCESS) { |
| 585 | on_gscan_event_internal_callback = nullptr; |
| 586 | on_gscan_full_result_internal_callback = nullptr; |
| 587 | } |
| 588 | return status; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 589 | } |
| 590 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 591 | wifi_error WifiLegacyHal::stopGscan(const std::string& iface_name, |
| 592 | wifi_request_id id) { |
| 593 | // If there is no an ongoing background scan, reject stop requests. |
| 594 | // TODO(b/32337212): This needs to be handled by the HIDL object because we |
| 595 | // need to return the NOT_STARTED error code. |
| 596 | if (!on_gscan_event_internal_callback && |
| 597 | !on_gscan_full_result_internal_callback) { |
| 598 | return WIFI_ERROR_NOT_AVAILABLE; |
| 599 | } |
| 600 | wifi_error status = |
| 601 | global_func_table_.wifi_stop_gscan(id, getIfaceHandle(iface_name)); |
| 602 | // If the request Id is wrong, don't stop the ongoing background scan. Any |
| 603 | // other error should be treated as the end of background scan. |
| 604 | if (status != WIFI_ERROR_INVALID_REQUEST_ID) { |
| 605 | on_gscan_event_internal_callback = nullptr; |
| 606 | on_gscan_full_result_internal_callback = nullptr; |
| 607 | } |
| 608 | return status; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | std::pair<wifi_error, std::vector<uint32_t>> |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 612 | WifiLegacyHal::getValidFrequenciesForBand(const std::string& iface_name, |
| 613 | wifi_band band) { |
| 614 | static_assert(sizeof(uint32_t) >= sizeof(wifi_channel), |
| 615 | "Wifi Channel cannot be represented in output"); |
| 616 | std::vector<uint32_t> freqs; |
| 617 | freqs.resize(kMaxGscanFrequenciesForBand); |
| 618 | int32_t num_freqs = 0; |
| 619 | wifi_error status = global_func_table_.wifi_get_valid_channels( |
| 620 | getIfaceHandle(iface_name), band, freqs.size(), |
| 621 | reinterpret_cast<wifi_channel*>(freqs.data()), &num_freqs); |
| 622 | CHECK(num_freqs >= 0 && |
| 623 | static_cast<uint32_t>(num_freqs) <= kMaxGscanFrequenciesForBand); |
| 624 | freqs.resize(num_freqs); |
| 625 | return {status, std::move(freqs)}; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 626 | } |
| 627 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 628 | wifi_error WifiLegacyHal::setDfsFlag(const std::string& iface_name, |
| 629 | bool dfs_on) { |
| 630 | return global_func_table_.wifi_set_nodfs_flag(getIfaceHandle(iface_name), |
| 631 | dfs_on ? 0 : 1); |
Roshan Pius | 08d1df4 | 2017-04-19 23:11:07 -0700 | [diff] [blame] | 632 | } |
| 633 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 634 | wifi_error WifiLegacyHal::enableLinkLayerStats(const std::string& iface_name, |
| 635 | bool debug) { |
| 636 | wifi_link_layer_params params; |
| 637 | params.mpdu_size_threshold = kLinkLayerStatsDataMpduSizeThreshold; |
| 638 | params.aggressive_statistics_gathering = debug; |
| 639 | return global_func_table_.wifi_set_link_stats(getIfaceHandle(iface_name), |
| 640 | params); |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 641 | } |
| 642 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 643 | wifi_error WifiLegacyHal::disableLinkLayerStats(const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 644 | // TODO: Do we care about these responses? |
| 645 | uint32_t clear_mask_rsp; |
| 646 | uint8_t stop_rsp; |
| 647 | return global_func_table_.wifi_clear_link_stats( |
| 648 | getIfaceHandle(iface_name), 0xFFFFFFFF, &clear_mask_rsp, 1, &stop_rsp); |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 649 | } |
| 650 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 651 | std::pair<wifi_error, LinkLayerStats> WifiLegacyHal::getLinkLayerStats( |
| 652 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 653 | LinkLayerStats link_stats{}; |
| 654 | LinkLayerStats* link_stats_ptr = &link_stats; |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 655 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 656 | on_link_layer_stats_result_internal_callback = |
| 657 | [&link_stats_ptr](wifi_request_id /* id */, |
| 658 | wifi_iface_stat* iface_stats_ptr, int num_radios, |
| 659 | wifi_radio_stat* radio_stats_ptr) { |
Sunil Ravi | b0343e7 | 2018-11-13 15:52:00 -0800 | [diff] [blame] | 660 | wifi_radio_stat* l_radio_stats_ptr; |
| 661 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 662 | if (iface_stats_ptr != nullptr) { |
| 663 | link_stats_ptr->iface = *iface_stats_ptr; |
| 664 | link_stats_ptr->iface.num_peers = 0; |
| 665 | } else { |
| 666 | LOG(ERROR) << "Invalid iface stats in link layer stats"; |
| 667 | } |
| 668 | if (num_radios <= 0 || radio_stats_ptr == nullptr) { |
| 669 | LOG(ERROR) << "Invalid radio stats in link layer stats"; |
| 670 | return; |
| 671 | } |
Sunil Ravi | b0343e7 | 2018-11-13 15:52:00 -0800 | [diff] [blame] | 672 | l_radio_stats_ptr = radio_stats_ptr; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 673 | for (int i = 0; i < num_radios; i++) { |
| 674 | LinkLayerRadioStats radio; |
Sunil Ravi | b0343e7 | 2018-11-13 15:52:00 -0800 | [diff] [blame] | 675 | |
| 676 | radio.stats = *l_radio_stats_ptr; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 677 | // Copy over the tx level array to the separate vector. |
Sunil Ravi | b0343e7 | 2018-11-13 15:52:00 -0800 | [diff] [blame] | 678 | if (l_radio_stats_ptr->num_tx_levels > 0 && |
| 679 | l_radio_stats_ptr->tx_time_per_levels != nullptr) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 680 | radio.tx_time_per_levels.assign( |
Sunil Ravi | b0343e7 | 2018-11-13 15:52:00 -0800 | [diff] [blame] | 681 | l_radio_stats_ptr->tx_time_per_levels, |
| 682 | l_radio_stats_ptr->tx_time_per_levels + |
| 683 | l_radio_stats_ptr->num_tx_levels); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 684 | } |
| 685 | radio.stats.num_tx_levels = 0; |
| 686 | radio.stats.tx_time_per_levels = nullptr; |
Sunil Ravi | b0343e7 | 2018-11-13 15:52:00 -0800 | [diff] [blame] | 687 | /* Copy over the channel stat to separate vector */ |
| 688 | if (l_radio_stats_ptr->num_channels > 0) { |
| 689 | /* Copy the channel stats */ |
| 690 | radio.channel_stats.assign( |
| 691 | l_radio_stats_ptr->channels, |
| 692 | l_radio_stats_ptr->channels + |
| 693 | l_radio_stats_ptr->num_channels); |
| 694 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 695 | link_stats_ptr->radios.push_back(radio); |
Sunil Ravi | b0343e7 | 2018-11-13 15:52:00 -0800 | [diff] [blame] | 696 | l_radio_stats_ptr = |
| 697 | (wifi_radio_stat*)((u8*)l_radio_stats_ptr + |
| 698 | sizeof(wifi_radio_stat) + |
| 699 | (sizeof(wifi_channel_stat) * |
| 700 | l_radio_stats_ptr->num_channels)); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 701 | } |
| 702 | }; |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 703 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 704 | wifi_error status = global_func_table_.wifi_get_link_stats( |
| 705 | 0, getIfaceHandle(iface_name), {onSyncLinkLayerStatsResult}); |
| 706 | on_link_layer_stats_result_internal_callback = nullptr; |
| 707 | return {status, link_stats}; |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 708 | } |
| 709 | |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 710 | wifi_error WifiLegacyHal::startRssiMonitoring( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 711 | const std::string& iface_name, wifi_request_id id, int8_t max_rssi, |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 712 | int8_t min_rssi, |
| 713 | const on_rssi_threshold_breached_callback& |
| 714 | on_threshold_breached_user_callback) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 715 | if (on_rssi_threshold_breached_internal_callback) { |
| 716 | return WIFI_ERROR_NOT_AVAILABLE; |
| 717 | } |
| 718 | on_rssi_threshold_breached_internal_callback = |
| 719 | [on_threshold_breached_user_callback](wifi_request_id id, |
| 720 | uint8_t* bssid_ptr, int8_t rssi) { |
| 721 | if (!bssid_ptr) { |
| 722 | return; |
| 723 | } |
| 724 | std::array<uint8_t, 6> bssid_arr; |
| 725 | // |bssid_ptr| pointer is assumed to have 6 bytes for the mac |
| 726 | // address. |
| 727 | std::copy(bssid_ptr, bssid_ptr + 6, std::begin(bssid_arr)); |
| 728 | on_threshold_breached_user_callback(id, bssid_arr, rssi); |
| 729 | }; |
| 730 | wifi_error status = global_func_table_.wifi_start_rssi_monitoring( |
| 731 | id, getIfaceHandle(iface_name), max_rssi, min_rssi, |
| 732 | {onAsyncRssiThresholdBreached}); |
| 733 | if (status != WIFI_SUCCESS) { |
| 734 | on_rssi_threshold_breached_internal_callback = nullptr; |
| 735 | } |
| 736 | return status; |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 737 | } |
| 738 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 739 | wifi_error WifiLegacyHal::stopRssiMonitoring(const std::string& iface_name, |
| 740 | wifi_request_id id) { |
| 741 | if (!on_rssi_threshold_breached_internal_callback) { |
| 742 | return WIFI_ERROR_NOT_AVAILABLE; |
| 743 | } |
| 744 | wifi_error status = global_func_table_.wifi_stop_rssi_monitoring( |
| 745 | id, getIfaceHandle(iface_name)); |
| 746 | // If the request Id is wrong, don't stop the ongoing rssi monitoring. Any |
| 747 | // other error should be treated as the end of background scan. |
| 748 | if (status != WIFI_ERROR_INVALID_REQUEST_ID) { |
| 749 | on_rssi_threshold_breached_internal_callback = nullptr; |
| 750 | } |
| 751 | return status; |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 752 | } |
| 753 | |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 754 | std::pair<wifi_error, wifi_roaming_capabilities> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 755 | WifiLegacyHal::getRoamingCapabilities(const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 756 | wifi_roaming_capabilities caps; |
| 757 | wifi_error status = global_func_table_.wifi_get_roaming_capabilities( |
| 758 | getIfaceHandle(iface_name), &caps); |
| 759 | return {status, caps}; |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 760 | } |
| 761 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 762 | wifi_error WifiLegacyHal::configureRoaming(const std::string& iface_name, |
| 763 | const wifi_roaming_config& config) { |
| 764 | wifi_roaming_config config_internal = config; |
| 765 | return global_func_table_.wifi_configure_roaming(getIfaceHandle(iface_name), |
| 766 | &config_internal); |
Roshan Pius | af727c0 | 2017-01-11 15:37:25 -0800 | [diff] [blame] | 767 | } |
| 768 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 769 | wifi_error WifiLegacyHal::enableFirmwareRoaming(const std::string& iface_name, |
| 770 | fw_roaming_state_t state) { |
| 771 | return global_func_table_.wifi_enable_firmware_roaming( |
| 772 | getIfaceHandle(iface_name), state); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 773 | } |
| 774 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 775 | wifi_error WifiLegacyHal::configureNdOffload(const std::string& iface_name, |
| 776 | bool enable) { |
| 777 | return global_func_table_.wifi_configure_nd_offload( |
| 778 | getIfaceHandle(iface_name), enable); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 779 | } |
| 780 | |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 781 | wifi_error WifiLegacyHal::startSendingOffloadedPacket( |
Ahmed ElArabawy | ffbad18 | 2019-03-05 17:38:06 -0800 | [diff] [blame] | 782 | const std::string& iface_name, uint32_t cmd_id, uint16_t ether_type, |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 783 | const std::vector<uint8_t>& ip_packet_data, |
| 784 | const std::array<uint8_t, 6>& src_address, |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 785 | const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms) { |
| 786 | std::vector<uint8_t> ip_packet_data_internal(ip_packet_data); |
| 787 | std::vector<uint8_t> src_address_internal( |
| 788 | src_address.data(), src_address.data() + src_address.size()); |
| 789 | std::vector<uint8_t> dst_address_internal( |
| 790 | dst_address.data(), dst_address.data() + dst_address.size()); |
| 791 | return global_func_table_.wifi_start_sending_offloaded_packet( |
Ahmed ElArabawy | ffbad18 | 2019-03-05 17:38:06 -0800 | [diff] [blame] | 792 | cmd_id, getIfaceHandle(iface_name), ether_type, |
| 793 | ip_packet_data_internal.data(), ip_packet_data_internal.size(), |
| 794 | src_address_internal.data(), dst_address_internal.data(), period_in_ms); |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 795 | } |
| 796 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 797 | wifi_error WifiLegacyHal::stopSendingOffloadedPacket( |
| 798 | const std::string& iface_name, uint32_t cmd_id) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 799 | return global_func_table_.wifi_stop_sending_offloaded_packet( |
| 800 | cmd_id, getIfaceHandle(iface_name)); |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 801 | } |
| 802 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 803 | wifi_error WifiLegacyHal::setScanningMacOui(const std::string& iface_name, |
| 804 | const std::array<uint8_t, 3>& oui) { |
| 805 | std::vector<uint8_t> oui_internal(oui.data(), oui.data() + oui.size()); |
| 806 | return global_func_table_.wifi_set_scanning_mac_oui( |
| 807 | getIfaceHandle(iface_name), oui_internal.data()); |
Roshan Pius | 795bb81 | 2017-02-01 13:09:08 -0800 | [diff] [blame] | 808 | } |
| 809 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 810 | wifi_error WifiLegacyHal::selectTxPowerScenario(const std::string& iface_name, |
| 811 | wifi_power_scenario scenario) { |
| 812 | return global_func_table_.wifi_select_tx_power_scenario( |
| 813 | getIfaceHandle(iface_name), scenario); |
Roshan Pius | 8184d21 | 2017-07-11 08:59:29 -0700 | [diff] [blame] | 814 | } |
| 815 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 816 | wifi_error WifiLegacyHal::resetTxPowerScenario(const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 817 | return global_func_table_.wifi_reset_tx_power_scenario( |
| 818 | getIfaceHandle(iface_name)); |
Roshan Pius | 8184d21 | 2017-07-11 08:59:29 -0700 | [diff] [blame] | 819 | } |
| 820 | |
Ahmed ElArabawy | eaf8240 | 2018-10-26 09:46:04 -0700 | [diff] [blame] | 821 | wifi_error WifiLegacyHal::setLatencyMode(const std::string& iface_name, |
| 822 | wifi_latency_mode mode) { |
| 823 | return global_func_table_.wifi_set_latency_mode(getIfaceHandle(iface_name), |
| 824 | mode); |
| 825 | } |
| 826 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 827 | std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet( |
| 828 | const std::string& iface_name) { |
Roshan Pius | 200a17d | 2017-11-01 13:03:35 -0700 | [diff] [blame] | 829 | uint32_t supported_feature_flags; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 830 | wifi_error status = |
| 831 | global_func_table_.wifi_get_logger_supported_feature_set( |
Roshan Pius | 200a17d | 2017-11-01 13:03:35 -0700 | [diff] [blame] | 832 | getIfaceHandle(iface_name), &supported_feature_flags); |
| 833 | return {status, supported_feature_flags}; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 834 | } |
| 835 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 836 | wifi_error WifiLegacyHal::startPktFateMonitoring( |
| 837 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 838 | return global_func_table_.wifi_start_pkt_fate_monitoring( |
| 839 | getIfaceHandle(iface_name)); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 840 | } |
| 841 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 842 | std::pair<wifi_error, std::vector<wifi_tx_report>> WifiLegacyHal::getTxPktFates( |
| 843 | const std::string& iface_name) { |
| 844 | std::vector<wifi_tx_report> tx_pkt_fates; |
| 845 | tx_pkt_fates.resize(MAX_FATE_LOG_LEN); |
| 846 | size_t num_fates = 0; |
| 847 | wifi_error status = global_func_table_.wifi_get_tx_pkt_fates( |
| 848 | getIfaceHandle(iface_name), tx_pkt_fates.data(), tx_pkt_fates.size(), |
| 849 | &num_fates); |
| 850 | CHECK(num_fates <= MAX_FATE_LOG_LEN); |
| 851 | tx_pkt_fates.resize(num_fates); |
| 852 | return {status, std::move(tx_pkt_fates)}; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 853 | } |
| 854 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 855 | std::pair<wifi_error, std::vector<wifi_rx_report>> WifiLegacyHal::getRxPktFates( |
| 856 | const std::string& iface_name) { |
| 857 | std::vector<wifi_rx_report> rx_pkt_fates; |
| 858 | rx_pkt_fates.resize(MAX_FATE_LOG_LEN); |
| 859 | size_t num_fates = 0; |
| 860 | wifi_error status = global_func_table_.wifi_get_rx_pkt_fates( |
| 861 | getIfaceHandle(iface_name), rx_pkt_fates.data(), rx_pkt_fates.size(), |
| 862 | &num_fates); |
| 863 | CHECK(num_fates <= MAX_FATE_LOG_LEN); |
| 864 | rx_pkt_fates.resize(num_fates); |
| 865 | return {status, std::move(rx_pkt_fates)}; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 866 | } |
| 867 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 868 | std::pair<wifi_error, WakeReasonStats> WifiLegacyHal::getWakeReasonStats( |
| 869 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 870 | WakeReasonStats stats; |
| 871 | stats.cmd_event_wake_cnt.resize(kMaxWakeReasonStatsArraySize); |
| 872 | stats.driver_fw_local_wake_cnt.resize(kMaxWakeReasonStatsArraySize); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 873 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 874 | // This legacy struct needs separate memory to store the variable sized wake |
| 875 | // reason types. |
| 876 | stats.wake_reason_cnt.cmd_event_wake_cnt = |
| 877 | reinterpret_cast<int32_t*>(stats.cmd_event_wake_cnt.data()); |
| 878 | stats.wake_reason_cnt.cmd_event_wake_cnt_sz = |
| 879 | stats.cmd_event_wake_cnt.size(); |
| 880 | stats.wake_reason_cnt.cmd_event_wake_cnt_used = 0; |
| 881 | stats.wake_reason_cnt.driver_fw_local_wake_cnt = |
| 882 | reinterpret_cast<int32_t*>(stats.driver_fw_local_wake_cnt.data()); |
| 883 | stats.wake_reason_cnt.driver_fw_local_wake_cnt_sz = |
| 884 | stats.driver_fw_local_wake_cnt.size(); |
| 885 | stats.wake_reason_cnt.driver_fw_local_wake_cnt_used = 0; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 886 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 887 | wifi_error status = global_func_table_.wifi_get_wake_reason_stats( |
| 888 | getIfaceHandle(iface_name), &stats.wake_reason_cnt); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 889 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 890 | CHECK( |
| 891 | stats.wake_reason_cnt.cmd_event_wake_cnt_used >= 0 && |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 892 | static_cast<uint32_t>(stats.wake_reason_cnt.cmd_event_wake_cnt_used) <= |
| 893 | kMaxWakeReasonStatsArraySize); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 894 | stats.cmd_event_wake_cnt.resize( |
| 895 | stats.wake_reason_cnt.cmd_event_wake_cnt_used); |
| 896 | stats.wake_reason_cnt.cmd_event_wake_cnt = nullptr; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 897 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 898 | CHECK(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used >= 0 && |
| 899 | static_cast<uint32_t>( |
| 900 | stats.wake_reason_cnt.driver_fw_local_wake_cnt_used) <= |
| 901 | kMaxWakeReasonStatsArraySize); |
| 902 | stats.driver_fw_local_wake_cnt.resize( |
| 903 | stats.wake_reason_cnt.driver_fw_local_wake_cnt_used); |
| 904 | stats.wake_reason_cnt.driver_fw_local_wake_cnt = nullptr; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 905 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 906 | return {status, stats}; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 907 | } |
| 908 | |
| 909 | wifi_error WifiLegacyHal::registerRingBufferCallbackHandler( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 910 | const std::string& iface_name, |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 911 | const on_ring_buffer_data_callback& on_user_data_callback) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 912 | if (on_ring_buffer_data_internal_callback) { |
| 913 | return WIFI_ERROR_NOT_AVAILABLE; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 914 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 915 | on_ring_buffer_data_internal_callback = |
| 916 | [on_user_data_callback](char* ring_name, char* buffer, int buffer_size, |
| 917 | wifi_ring_buffer_status* status) { |
| 918 | if (status && buffer) { |
| 919 | std::vector<uint8_t> buffer_vector( |
| 920 | reinterpret_cast<uint8_t*>(buffer), |
| 921 | reinterpret_cast<uint8_t*>(buffer) + buffer_size); |
| 922 | on_user_data_callback(ring_name, buffer_vector, *status); |
| 923 | } |
| 924 | }; |
| 925 | wifi_error status = global_func_table_.wifi_set_log_handler( |
| 926 | 0, getIfaceHandle(iface_name), {onAsyncRingBufferData}); |
| 927 | if (status != WIFI_SUCCESS) { |
| 928 | on_ring_buffer_data_internal_callback = nullptr; |
| 929 | } |
| 930 | return status; |
Roshan Pius | adc87cb | 2016-12-14 18:02:56 -0800 | [diff] [blame] | 931 | } |
| 932 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 933 | wifi_error WifiLegacyHal::deregisterRingBufferCallbackHandler( |
| 934 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 935 | if (!on_ring_buffer_data_internal_callback) { |
| 936 | return WIFI_ERROR_NOT_AVAILABLE; |
| 937 | } |
| 938 | on_ring_buffer_data_internal_callback = nullptr; |
| 939 | return global_func_table_.wifi_reset_log_handler( |
| 940 | 0, getIfaceHandle(iface_name)); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | std::pair<wifi_error, std::vector<wifi_ring_buffer_status>> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 944 | WifiLegacyHal::getRingBuffersStatus(const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 945 | std::vector<wifi_ring_buffer_status> ring_buffers_status; |
| 946 | ring_buffers_status.resize(kMaxRingBuffers); |
| 947 | uint32_t num_rings = kMaxRingBuffers; |
| 948 | wifi_error status = global_func_table_.wifi_get_ring_buffers_status( |
| 949 | getIfaceHandle(iface_name), &num_rings, ring_buffers_status.data()); |
| 950 | CHECK(num_rings <= kMaxRingBuffers); |
| 951 | ring_buffers_status.resize(num_rings); |
| 952 | return {status, std::move(ring_buffers_status)}; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 953 | } |
| 954 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 955 | wifi_error WifiLegacyHal::startRingBufferLogging(const std::string& iface_name, |
| 956 | const std::string& ring_name, |
| 957 | uint32_t verbose_level, |
| 958 | uint32_t max_interval_sec, |
| 959 | uint32_t min_data_size) { |
| 960 | return global_func_table_.wifi_start_logging( |
| 961 | getIfaceHandle(iface_name), verbose_level, 0, max_interval_sec, |
| 962 | min_data_size, makeCharVec(ring_name).data()); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 963 | } |
| 964 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 965 | wifi_error WifiLegacyHal::getRingBufferData(const std::string& iface_name, |
| 966 | const std::string& ring_name) { |
| 967 | return global_func_table_.wifi_get_ring_data(getIfaceHandle(iface_name), |
| 968 | makeCharVec(ring_name).data()); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 969 | } |
| 970 | |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 971 | wifi_error WifiLegacyHal::registerErrorAlertCallbackHandler( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 972 | const std::string& iface_name, |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 973 | const on_error_alert_callback& on_user_alert_callback) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 974 | if (on_error_alert_internal_callback) { |
| 975 | return WIFI_ERROR_NOT_AVAILABLE; |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 976 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 977 | on_error_alert_internal_callback = [on_user_alert_callback]( |
| 978 | wifi_request_id id, char* buffer, |
| 979 | int buffer_size, int err_code) { |
| 980 | if (buffer) { |
| 981 | CHECK(id == 0); |
| 982 | on_user_alert_callback( |
| 983 | err_code, |
| 984 | std::vector<uint8_t>( |
| 985 | reinterpret_cast<uint8_t*>(buffer), |
| 986 | reinterpret_cast<uint8_t*>(buffer) + buffer_size)); |
| 987 | } |
| 988 | }; |
| 989 | wifi_error status = global_func_table_.wifi_set_alert_handler( |
| 990 | 0, getIfaceHandle(iface_name), {onAsyncErrorAlert}); |
| 991 | if (status != WIFI_SUCCESS) { |
| 992 | on_error_alert_internal_callback = nullptr; |
| 993 | } |
| 994 | return status; |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 995 | } |
| 996 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 997 | wifi_error WifiLegacyHal::deregisterErrorAlertCallbackHandler( |
| 998 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 999 | if (!on_error_alert_internal_callback) { |
| 1000 | return WIFI_ERROR_NOT_AVAILABLE; |
| 1001 | } |
| 1002 | on_error_alert_internal_callback = nullptr; |
| 1003 | return global_func_table_.wifi_reset_alert_handler( |
| 1004 | 0, getIfaceHandle(iface_name)); |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 1005 | } |
| 1006 | |
Roshan Pius | 01f0877 | 2018-01-22 17:56:06 -0800 | [diff] [blame] | 1007 | wifi_error WifiLegacyHal::registerRadioModeChangeCallbackHandler( |
| 1008 | const std::string& iface_name, |
| 1009 | const on_radio_mode_change_callback& on_user_change_callback) { |
| 1010 | if (on_radio_mode_change_internal_callback) { |
| 1011 | return WIFI_ERROR_NOT_AVAILABLE; |
| 1012 | } |
| 1013 | on_radio_mode_change_internal_callback = [on_user_change_callback]( |
| 1014 | wifi_request_id /* id */, |
| 1015 | uint32_t num_macs, |
| 1016 | wifi_mac_info* mac_infos_arr) { |
| 1017 | if (num_macs > 0 && mac_infos_arr) { |
| 1018 | std::vector<WifiMacInfo> mac_infos_vec; |
| 1019 | for (uint32_t i = 0; i < num_macs; i++) { |
| 1020 | WifiMacInfo mac_info; |
| 1021 | mac_info.wlan_mac_id = mac_infos_arr[i].wlan_mac_id; |
| 1022 | mac_info.mac_band = mac_infos_arr[i].mac_band; |
| 1023 | for (int32_t j = 0; j < mac_infos_arr[i].num_iface; j++) { |
| 1024 | WifiIfaceInfo iface_info; |
| 1025 | iface_info.name = mac_infos_arr[i].iface_info[j].iface_name; |
| 1026 | iface_info.channel = mac_infos_arr[i].iface_info[j].channel; |
| 1027 | mac_info.iface_infos.push_back(iface_info); |
| 1028 | } |
| 1029 | mac_infos_vec.push_back(mac_info); |
| 1030 | } |
| 1031 | on_user_change_callback(mac_infos_vec); |
| 1032 | } |
| 1033 | }; |
| 1034 | wifi_error status = global_func_table_.wifi_set_radio_mode_change_handler( |
| 1035 | 0, getIfaceHandle(iface_name), {onAsyncRadioModeChange}); |
| 1036 | if (status != WIFI_SUCCESS) { |
| 1037 | on_radio_mode_change_internal_callback = nullptr; |
| 1038 | } |
| 1039 | return status; |
| 1040 | } |
| 1041 | |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1042 | wifi_error WifiLegacyHal::startRttRangeRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1043 | const std::string& iface_name, wifi_request_id id, |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1044 | const std::vector<wifi_rtt_config>& rtt_configs, |
| 1045 | const on_rtt_results_callback& on_results_user_callback) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1046 | if (on_rtt_results_internal_callback) { |
| 1047 | return WIFI_ERROR_NOT_AVAILABLE; |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1048 | } |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1049 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1050 | on_rtt_results_internal_callback = |
| 1051 | [on_results_user_callback](wifi_request_id id, unsigned num_results, |
| 1052 | wifi_rtt_result* rtt_results[]) { |
| 1053 | if (num_results > 0 && !rtt_results) { |
| 1054 | LOG(ERROR) << "Unexpected nullptr in RTT results"; |
| 1055 | return; |
| 1056 | } |
| 1057 | std::vector<const wifi_rtt_result*> rtt_results_vec; |
| 1058 | std::copy_if(rtt_results, rtt_results + num_results, |
| 1059 | back_inserter(rtt_results_vec), |
| 1060 | [](wifi_rtt_result* rtt_result) { |
| 1061 | return rtt_result != nullptr; |
| 1062 | }); |
| 1063 | on_results_user_callback(id, rtt_results_vec); |
| 1064 | }; |
| 1065 | |
| 1066 | std::vector<wifi_rtt_config> rtt_configs_internal(rtt_configs); |
| 1067 | wifi_error status = global_func_table_.wifi_rtt_range_request( |
| 1068 | id, getIfaceHandle(iface_name), rtt_configs.size(), |
| 1069 | rtt_configs_internal.data(), {onAsyncRttResults}); |
| 1070 | if (status != WIFI_SUCCESS) { |
| 1071 | on_rtt_results_internal_callback = nullptr; |
| 1072 | } |
| 1073 | return status; |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | wifi_error WifiLegacyHal::cancelRttRangeRequest( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1077 | const std::string& iface_name, wifi_request_id id, |
| 1078 | const std::vector<std::array<uint8_t, 6>>& mac_addrs) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1079 | if (!on_rtt_results_internal_callback) { |
| 1080 | return WIFI_ERROR_NOT_AVAILABLE; |
| 1081 | } |
| 1082 | static_assert(sizeof(mac_addr) == sizeof(std::array<uint8_t, 6>), |
| 1083 | "MAC address size mismatch"); |
| 1084 | // TODO: How do we handle partial cancels (i.e only a subset of enabled mac |
| 1085 | // addressed are cancelled). |
| 1086 | std::vector<std::array<uint8_t, 6>> mac_addrs_internal(mac_addrs); |
| 1087 | wifi_error status = global_func_table_.wifi_rtt_range_cancel( |
| 1088 | id, getIfaceHandle(iface_name), mac_addrs.size(), |
| 1089 | reinterpret_cast<mac_addr*>(mac_addrs_internal.data())); |
| 1090 | // If the request Id is wrong, don't stop the ongoing range request. Any |
| 1091 | // other error should be treated as the end of rtt ranging. |
| 1092 | if (status != WIFI_ERROR_INVALID_REQUEST_ID) { |
| 1093 | on_rtt_results_internal_callback = nullptr; |
| 1094 | } |
| 1095 | return status; |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1096 | } |
| 1097 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1098 | std::pair<wifi_error, wifi_rtt_capabilities> WifiLegacyHal::getRttCapabilities( |
| 1099 | const std::string& iface_name) { |
| 1100 | wifi_rtt_capabilities rtt_caps; |
| 1101 | wifi_error status = global_func_table_.wifi_get_rtt_capabilities( |
| 1102 | getIfaceHandle(iface_name), &rtt_caps); |
| 1103 | return {status, rtt_caps}; |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1104 | } |
| 1105 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1106 | std::pair<wifi_error, wifi_rtt_responder> WifiLegacyHal::getRttResponderInfo( |
| 1107 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1108 | wifi_rtt_responder rtt_responder; |
| 1109 | wifi_error status = global_func_table_.wifi_rtt_get_responder_info( |
| 1110 | getIfaceHandle(iface_name), &rtt_responder); |
| 1111 | return {status, rtt_responder}; |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1112 | } |
| 1113 | |
| 1114 | wifi_error WifiLegacyHal::enableRttResponder( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1115 | const std::string& iface_name, wifi_request_id id, |
| 1116 | const wifi_channel_info& channel_hint, uint32_t max_duration_secs, |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1117 | const wifi_rtt_responder& info) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1118 | wifi_rtt_responder info_internal(info); |
| 1119 | return global_func_table_.wifi_enable_responder( |
| 1120 | id, getIfaceHandle(iface_name), channel_hint, max_duration_secs, |
| 1121 | &info_internal); |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1124 | wifi_error WifiLegacyHal::disableRttResponder(const std::string& iface_name, |
| 1125 | wifi_request_id id) { |
| 1126 | return global_func_table_.wifi_disable_responder( |
| 1127 | id, getIfaceHandle(iface_name)); |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1128 | } |
| 1129 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1130 | wifi_error WifiLegacyHal::setRttLci(const std::string& iface_name, |
| 1131 | wifi_request_id id, |
| 1132 | const wifi_lci_information& info) { |
| 1133 | wifi_lci_information info_internal(info); |
| 1134 | return global_func_table_.wifi_set_lci(id, getIfaceHandle(iface_name), |
| 1135 | &info_internal); |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1136 | } |
| 1137 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1138 | wifi_error WifiLegacyHal::setRttLcr(const std::string& iface_name, |
| 1139 | wifi_request_id id, |
| 1140 | const wifi_lcr_information& info) { |
| 1141 | wifi_lcr_information info_internal(info); |
| 1142 | return global_func_table_.wifi_set_lcr(id, getIfaceHandle(iface_name), |
| 1143 | &info_internal); |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1144 | } |
| 1145 | |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1146 | wifi_error WifiLegacyHal::nanRegisterCallbackHandlers( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1147 | const std::string& iface_name, const NanCallbackHandlers& user_callbacks) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1148 | on_nan_notify_response_user_callback = user_callbacks.on_notify_response; |
| 1149 | on_nan_event_publish_terminated_user_callback = |
| 1150 | user_callbacks.on_event_publish_terminated; |
| 1151 | on_nan_event_match_user_callback = user_callbacks.on_event_match; |
| 1152 | on_nan_event_match_expired_user_callback = |
| 1153 | user_callbacks.on_event_match_expired; |
| 1154 | on_nan_event_subscribe_terminated_user_callback = |
| 1155 | user_callbacks.on_event_subscribe_terminated; |
| 1156 | on_nan_event_followup_user_callback = user_callbacks.on_event_followup; |
| 1157 | on_nan_event_disc_eng_event_user_callback = |
| 1158 | user_callbacks.on_event_disc_eng_event; |
| 1159 | on_nan_event_disabled_user_callback = user_callbacks.on_event_disabled; |
| 1160 | on_nan_event_tca_user_callback = user_callbacks.on_event_tca; |
| 1161 | on_nan_event_beacon_sdf_payload_user_callback = |
| 1162 | user_callbacks.on_event_beacon_sdf_payload; |
| 1163 | on_nan_event_data_path_request_user_callback = |
| 1164 | user_callbacks.on_event_data_path_request; |
| 1165 | on_nan_event_data_path_confirm_user_callback = |
| 1166 | user_callbacks.on_event_data_path_confirm; |
| 1167 | on_nan_event_data_path_end_user_callback = |
| 1168 | user_callbacks.on_event_data_path_end; |
| 1169 | on_nan_event_transmit_follow_up_user_callback = |
| 1170 | user_callbacks.on_event_transmit_follow_up; |
| 1171 | on_nan_event_range_request_user_callback = |
| 1172 | user_callbacks.on_event_range_request; |
| 1173 | on_nan_event_range_report_user_callback = |
| 1174 | user_callbacks.on_event_range_report; |
Etan Cohen | 1bf15f1 | 2017-12-12 16:15:16 -0800 | [diff] [blame] | 1175 | on_nan_event_schedule_update_user_callback = |
| 1176 | user_callbacks.on_event_schedule_update; |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1177 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1178 | return global_func_table_.wifi_nan_register_handler( |
| 1179 | getIfaceHandle(iface_name), |
| 1180 | {onAysncNanNotifyResponse, onAysncNanEventPublishReplied, |
| 1181 | onAysncNanEventPublishTerminated, onAysncNanEventMatch, |
| 1182 | onAysncNanEventMatchExpired, onAysncNanEventSubscribeTerminated, |
| 1183 | onAysncNanEventFollowup, onAysncNanEventDiscEngEvent, |
| 1184 | onAysncNanEventDisabled, onAysncNanEventTca, |
| 1185 | onAysncNanEventBeaconSdfPayload, onAysncNanEventDataPathRequest, |
| 1186 | onAysncNanEventDataPathConfirm, onAysncNanEventDataPathEnd, |
| 1187 | onAysncNanEventTransmitFollowUp, onAysncNanEventRangeRequest, |
Etan Cohen | 1bf15f1 | 2017-12-12 16:15:16 -0800 | [diff] [blame] | 1188 | onAysncNanEventRangeReport, onAsyncNanEventScheduleUpdate}); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1189 | } |
| 1190 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1191 | wifi_error WifiLegacyHal::nanEnableRequest(const std::string& iface_name, |
| 1192 | transaction_id id, |
| 1193 | const NanEnableRequest& msg) { |
| 1194 | NanEnableRequest msg_internal(msg); |
| 1195 | return global_func_table_.wifi_nan_enable_request( |
| 1196 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1199 | wifi_error WifiLegacyHal::nanDisableRequest(const std::string& iface_name, |
| 1200 | transaction_id id) { |
| 1201 | return global_func_table_.wifi_nan_disable_request( |
| 1202 | id, getIfaceHandle(iface_name)); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1205 | wifi_error WifiLegacyHal::nanPublishRequest(const std::string& iface_name, |
| 1206 | transaction_id id, |
| 1207 | const NanPublishRequest& msg) { |
| 1208 | NanPublishRequest msg_internal(msg); |
| 1209 | return global_func_table_.wifi_nan_publish_request( |
| 1210 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1211 | } |
| 1212 | |
| 1213 | wifi_error WifiLegacyHal::nanPublishCancelRequest( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1214 | const std::string& iface_name, transaction_id id, |
| 1215 | const NanPublishCancelRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1216 | NanPublishCancelRequest msg_internal(msg); |
| 1217 | return global_func_table_.wifi_nan_publish_cancel_request( |
| 1218 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1219 | } |
| 1220 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1221 | wifi_error WifiLegacyHal::nanSubscribeRequest(const std::string& iface_name, |
| 1222 | transaction_id id, |
| 1223 | const NanSubscribeRequest& msg) { |
| 1224 | NanSubscribeRequest msg_internal(msg); |
| 1225 | return global_func_table_.wifi_nan_subscribe_request( |
| 1226 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | wifi_error WifiLegacyHal::nanSubscribeCancelRequest( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1230 | const std::string& iface_name, transaction_id id, |
| 1231 | const NanSubscribeCancelRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1232 | NanSubscribeCancelRequest msg_internal(msg); |
| 1233 | return global_func_table_.wifi_nan_subscribe_cancel_request( |
| 1234 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | wifi_error WifiLegacyHal::nanTransmitFollowupRequest( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1238 | const std::string& iface_name, transaction_id id, |
| 1239 | const NanTransmitFollowupRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1240 | NanTransmitFollowupRequest msg_internal(msg); |
| 1241 | return global_func_table_.wifi_nan_transmit_followup_request( |
| 1242 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1243 | } |
| 1244 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1245 | wifi_error WifiLegacyHal::nanStatsRequest(const std::string& iface_name, |
| 1246 | transaction_id id, |
| 1247 | const NanStatsRequest& msg) { |
| 1248 | NanStatsRequest msg_internal(msg); |
| 1249 | return global_func_table_.wifi_nan_stats_request( |
| 1250 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1251 | } |
| 1252 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1253 | wifi_error WifiLegacyHal::nanConfigRequest(const std::string& iface_name, |
| 1254 | transaction_id id, |
| 1255 | const NanConfigRequest& msg) { |
| 1256 | NanConfigRequest msg_internal(msg); |
| 1257 | return global_func_table_.wifi_nan_config_request( |
| 1258 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1259 | } |
| 1260 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1261 | wifi_error WifiLegacyHal::nanTcaRequest(const std::string& iface_name, |
| 1262 | transaction_id id, |
| 1263 | const NanTCARequest& msg) { |
| 1264 | NanTCARequest msg_internal(msg); |
| 1265 | return global_func_table_.wifi_nan_tca_request( |
| 1266 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1267 | } |
| 1268 | |
| 1269 | wifi_error WifiLegacyHal::nanBeaconSdfPayloadRequest( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1270 | const std::string& iface_name, transaction_id id, |
| 1271 | const NanBeaconSdfPayloadRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1272 | NanBeaconSdfPayloadRequest msg_internal(msg); |
| 1273 | return global_func_table_.wifi_nan_beacon_sdf_payload_request( |
| 1274 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | std::pair<wifi_error, NanVersion> WifiLegacyHal::nanGetVersion() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1278 | NanVersion version; |
| 1279 | wifi_error status = |
| 1280 | global_func_table_.wifi_nan_get_version(global_handle_, &version); |
| 1281 | return {status, version}; |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1282 | } |
| 1283 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1284 | wifi_error WifiLegacyHal::nanGetCapabilities(const std::string& iface_name, |
| 1285 | transaction_id id) { |
| 1286 | return global_func_table_.wifi_nan_get_capabilities( |
| 1287 | id, getIfaceHandle(iface_name)); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1288 | } |
| 1289 | |
| 1290 | wifi_error WifiLegacyHal::nanDataInterfaceCreate( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1291 | const std::string& iface_name, transaction_id id, |
| 1292 | const std::string& data_iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1293 | return global_func_table_.wifi_nan_data_interface_create( |
| 1294 | id, getIfaceHandle(iface_name), makeCharVec(data_iface_name).data()); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | wifi_error WifiLegacyHal::nanDataInterfaceDelete( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1298 | const std::string& iface_name, transaction_id id, |
| 1299 | const std::string& data_iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1300 | return global_func_table_.wifi_nan_data_interface_delete( |
| 1301 | id, getIfaceHandle(iface_name), makeCharVec(data_iface_name).data()); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | wifi_error WifiLegacyHal::nanDataRequestInitiator( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1305 | const std::string& iface_name, transaction_id id, |
| 1306 | const NanDataPathInitiatorRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1307 | NanDataPathInitiatorRequest msg_internal(msg); |
| 1308 | return global_func_table_.wifi_nan_data_request_initiator( |
| 1309 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1310 | } |
| 1311 | |
| 1312 | wifi_error WifiLegacyHal::nanDataIndicationResponse( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1313 | const std::string& iface_name, transaction_id id, |
| 1314 | const NanDataPathIndicationResponse& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1315 | NanDataPathIndicationResponse msg_internal(msg); |
| 1316 | return global_func_table_.wifi_nan_data_indication_response( |
| 1317 | id, getIfaceHandle(iface_name), &msg_internal); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1318 | } |
| 1319 | |
Etan Cohen | c9836f9 | 2017-06-30 13:55:21 -0700 | [diff] [blame] | 1320 | typedef struct { |
| 1321 | u8 num_ndp_instances; |
| 1322 | NanDataPathId ndp_instance_id; |
| 1323 | } NanDataPathEndSingleNdpIdRequest; |
| 1324 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1325 | wifi_error WifiLegacyHal::nanDataEnd(const std::string& iface_name, |
| 1326 | transaction_id id, |
| 1327 | uint32_t ndpInstanceId) { |
| 1328 | NanDataPathEndSingleNdpIdRequest msg; |
| 1329 | msg.num_ndp_instances = 1; |
| 1330 | msg.ndp_instance_id = ndpInstanceId; |
| 1331 | wifi_error status = global_func_table_.wifi_nan_data_end( |
| 1332 | id, getIfaceHandle(iface_name), (NanDataPathEndRequest*)&msg); |
| 1333 | return status; |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1334 | } |
| 1335 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1336 | wifi_error WifiLegacyHal::setCountryCode(const std::string& iface_name, |
| 1337 | std::array<int8_t, 2> code) { |
| 1338 | std::string code_str(code.data(), code.data() + code.size()); |
| 1339 | return global_func_table_.wifi_set_country_code(getIfaceHandle(iface_name), |
| 1340 | code_str.c_str()); |
Roshan Pius | 32fc12e | 2017-01-25 17:44:42 -0800 | [diff] [blame] | 1341 | } |
| 1342 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1343 | wifi_error WifiLegacyHal::retrieveIfaceHandles() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1344 | wifi_interface_handle* iface_handles = nullptr; |
| 1345 | int num_iface_handles = 0; |
| 1346 | wifi_error status = global_func_table_.wifi_get_ifaces( |
| 1347 | global_handle_, &num_iface_handles, &iface_handles); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1348 | if (status != WIFI_SUCCESS) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1349 | LOG(ERROR) << "Failed to enumerate interface handles"; |
| 1350 | return status; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1351 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1352 | for (int i = 0; i < num_iface_handles; ++i) { |
| 1353 | std::array<char, IFNAMSIZ> iface_name_arr = {}; |
| 1354 | status = global_func_table_.wifi_get_iface_name( |
| 1355 | iface_handles[i], iface_name_arr.data(), iface_name_arr.size()); |
| 1356 | if (status != WIFI_SUCCESS) { |
| 1357 | LOG(WARNING) << "Failed to get interface handle name"; |
| 1358 | continue; |
| 1359 | } |
| 1360 | // Assuming the interface name is null terminated since the legacy HAL |
| 1361 | // API does not return a size. |
| 1362 | std::string iface_name(iface_name_arr.data()); |
| 1363 | LOG(INFO) << "Adding interface handle for " << iface_name; |
| 1364 | iface_name_to_handle_[iface_name] = iface_handles[i]; |
| 1365 | } |
| 1366 | return WIFI_SUCCESS; |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | wifi_interface_handle WifiLegacyHal::getIfaceHandle( |
| 1370 | const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1371 | const auto iface_handle_iter = iface_name_to_handle_.find(iface_name); |
| 1372 | if (iface_handle_iter == iface_name_to_handle_.end()) { |
| 1373 | LOG(ERROR) << "Unknown iface name: " << iface_name; |
| 1374 | return nullptr; |
| 1375 | } |
| 1376 | return iface_handle_iter->second; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1377 | } |
| 1378 | |
| 1379 | void WifiLegacyHal::runEventLoop() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1380 | LOG(DEBUG) << "Starting legacy HAL event loop"; |
| 1381 | global_func_table_.wifi_event_loop(global_handle_); |
| 1382 | const auto lock = hidl_sync_util::acquireGlobalLock(); |
| 1383 | if (!awaiting_event_loop_termination_) { |
| 1384 | LOG(FATAL) |
| 1385 | << "Legacy HAL event loop terminated, but HAL was not stopping"; |
| 1386 | } |
| 1387 | LOG(DEBUG) << "Legacy HAL event loop terminated"; |
| 1388 | awaiting_event_loop_termination_ = false; |
| 1389 | stop_wait_cv_.notify_one(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1390 | } |
| 1391 | |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 1392 | std::pair<wifi_error, std::vector<wifi_cached_scan_results>> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 1393 | WifiLegacyHal::getGscanCachedResults(const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1394 | std::vector<wifi_cached_scan_results> cached_scan_results; |
| 1395 | cached_scan_results.resize(kMaxCachedGscanResults); |
| 1396 | int32_t num_results = 0; |
| 1397 | wifi_error status = global_func_table_.wifi_get_cached_gscan_results( |
| 1398 | getIfaceHandle(iface_name), true /* always flush */, |
| 1399 | cached_scan_results.size(), cached_scan_results.data(), &num_results); |
| 1400 | CHECK(num_results >= 0 && |
| 1401 | static_cast<uint32_t>(num_results) <= kMaxCachedGscanResults); |
| 1402 | cached_scan_results.resize(num_results); |
| 1403 | // Check for invalid IE lengths in these cached scan results and correct it. |
| 1404 | for (auto& cached_scan_result : cached_scan_results) { |
| 1405 | int num_scan_results = cached_scan_result.num_results; |
| 1406 | for (int i = 0; i < num_scan_results; i++) { |
| 1407 | auto& scan_result = cached_scan_result.results[i]; |
| 1408 | if (scan_result.ie_length > 0) { |
| 1409 | LOG(DEBUG) << "Cached scan result has non-zero IE length " |
| 1410 | << scan_result.ie_length; |
| 1411 | scan_result.ie_length = 0; |
| 1412 | } |
| 1413 | } |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 1414 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1415 | return {status, std::move(cached_scan_results)}; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 1416 | } |
| 1417 | |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 1418 | void WifiLegacyHal::invalidate() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1419 | global_handle_ = nullptr; |
| 1420 | iface_name_to_handle_.clear(); |
| 1421 | on_driver_memory_dump_internal_callback = nullptr; |
| 1422 | on_firmware_memory_dump_internal_callback = nullptr; |
| 1423 | on_gscan_event_internal_callback = nullptr; |
| 1424 | on_gscan_full_result_internal_callback = nullptr; |
| 1425 | on_link_layer_stats_result_internal_callback = nullptr; |
| 1426 | on_rssi_threshold_breached_internal_callback = nullptr; |
| 1427 | on_ring_buffer_data_internal_callback = nullptr; |
| 1428 | on_error_alert_internal_callback = nullptr; |
Roshan Pius | 01f0877 | 2018-01-22 17:56:06 -0800 | [diff] [blame] | 1429 | on_radio_mode_change_internal_callback = nullptr; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 1430 | on_rtt_results_internal_callback = nullptr; |
| 1431 | on_nan_notify_response_user_callback = nullptr; |
| 1432 | on_nan_event_publish_terminated_user_callback = nullptr; |
| 1433 | on_nan_event_match_user_callback = nullptr; |
| 1434 | on_nan_event_match_expired_user_callback = nullptr; |
| 1435 | on_nan_event_subscribe_terminated_user_callback = nullptr; |
| 1436 | on_nan_event_followup_user_callback = nullptr; |
| 1437 | on_nan_event_disc_eng_event_user_callback = nullptr; |
| 1438 | on_nan_event_disabled_user_callback = nullptr; |
| 1439 | on_nan_event_tca_user_callback = nullptr; |
| 1440 | on_nan_event_beacon_sdf_payload_user_callback = nullptr; |
| 1441 | on_nan_event_data_path_request_user_callback = nullptr; |
| 1442 | on_nan_event_data_path_confirm_user_callback = nullptr; |
| 1443 | on_nan_event_data_path_end_user_callback = nullptr; |
| 1444 | on_nan_event_transmit_follow_up_user_callback = nullptr; |
| 1445 | on_nan_event_range_request_user_callback = nullptr; |
| 1446 | on_nan_event_range_report_user_callback = nullptr; |
Etan Cohen | 1bf15f1 | 2017-12-12 16:15:16 -0800 | [diff] [blame] | 1447 | on_nan_event_schedule_update_user_callback = nullptr; |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 1448 | } |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 1449 | |
| 1450 | } // namespace legacy_hal |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1451 | } // namespace implementation |
Ahmed ElArabawy | f501a98 | 2019-07-23 15:02:22 -0700 | [diff] [blame] | 1452 | } // namespace V1_4 |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1453 | } // namespace wifi |
| 1454 | } // namespace hardware |
| 1455 | } // namespace android |