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> |
| 18 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 19 | #include <android-base/logging.h> |
| 20 | #include <cutils/properties.h> |
| 21 | |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 22 | #include "wifi_legacy_hal.h" |
Roshan Pius | e73a506 | 2016-12-12 08:53:34 -0800 | [diff] [blame] | 23 | #include "wifi_legacy_hal_stubs.h" |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 24 | |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 25 | namespace android { |
| 26 | namespace hardware { |
| 27 | namespace wifi { |
| 28 | namespace V1_0 { |
| 29 | namespace implementation { |
| 30 | namespace legacy_hal { |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 31 | // Constants ported over from the legacy HAL calling code |
| 32 | // (com_android_server_wifi_WifiNative.cpp). This will all be thrown |
| 33 | // away when this shim layer is replaced by the real vendor |
| 34 | // implementation. |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 35 | static constexpr uint32_t kMaxVersionStringLength = 256; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 36 | static constexpr uint32_t kMaxCachedGscanResults = 64; |
| 37 | static constexpr uint32_t kMaxGscanFrequenciesForBand = 64; |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 38 | static constexpr uint32_t kLinkLayerStatsDataMpduSizeThreshold = 128; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 39 | static constexpr uint32_t kMaxWakeReasonStatsArraySize = 32; |
| 40 | static constexpr uint32_t kMaxRingBuffers = 10; |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 41 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 42 | // Legacy HAL functions accept "C" style function pointers, so use global |
| 43 | // functions to pass to the legacy HAL function and store the corresponding |
| 44 | // std::function methods to be invoked. |
| 45 | // Callback to be invoked once |stop| is complete. |
| 46 | std::function<void(wifi_handle handle)> on_stop_complete_internal_callback; |
| 47 | void onStopComplete(wifi_handle handle) { |
| 48 | if (on_stop_complete_internal_callback) { |
| 49 | on_stop_complete_internal_callback(handle); |
| 50 | } |
| 51 | } |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 52 | |
| 53 | // Callback to be invoked for driver dump. |
| 54 | std::function<void(char*, int)> on_driver_memory_dump_internal_callback; |
| 55 | void onDriverMemoryDump(char* buffer, int buffer_size) { |
| 56 | if (on_driver_memory_dump_internal_callback) { |
| 57 | on_driver_memory_dump_internal_callback(buffer, buffer_size); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // Callback to be invoked for firmware dump. |
| 62 | std::function<void(char*, int)> on_firmware_memory_dump_internal_callback; |
| 63 | void onFirmwareMemoryDump(char* buffer, int buffer_size) { |
| 64 | if (on_firmware_memory_dump_internal_callback) { |
| 65 | on_firmware_memory_dump_internal_callback(buffer, buffer_size); |
| 66 | } |
| 67 | } |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 68 | |
| 69 | // Callback to be invoked for Gscan events. |
| 70 | std::function<void(wifi_request_id, wifi_scan_event)> |
| 71 | on_gscan_event_internal_callback; |
| 72 | void onGscanEvent(wifi_request_id id, wifi_scan_event event) { |
| 73 | if (on_gscan_event_internal_callback) { |
| 74 | on_gscan_event_internal_callback(id, event); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // Callback to be invoked for Gscan full results. |
| 79 | std::function<void(wifi_request_id, wifi_scan_result*, uint32_t)> |
| 80 | on_gscan_full_result_internal_callback; |
| 81 | void onGscanFullResult(wifi_request_id id, |
| 82 | wifi_scan_result* result, |
| 83 | uint32_t buckets_scanned) { |
| 84 | if (on_gscan_full_result_internal_callback) { |
| 85 | on_gscan_full_result_internal_callback(id, result, buckets_scanned); |
| 86 | } |
| 87 | } |
| 88 | |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 89 | // Callback to be invoked for link layer stats results. |
| 90 | std::function<void((wifi_request_id, wifi_iface_stat*, int, wifi_radio_stat*))> |
| 91 | on_link_layer_stats_result_internal_callback; |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 92 | void onLinkLayerStatsResult(wifi_request_id id, |
| 93 | wifi_iface_stat* iface_stat, |
| 94 | int num_radios, |
| 95 | wifi_radio_stat* radio_stat) { |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 96 | if (on_link_layer_stats_result_internal_callback) { |
| 97 | on_link_layer_stats_result_internal_callback( |
| 98 | id, iface_stat, num_radios, radio_stat); |
| 99 | } |
| 100 | } |
| 101 | |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 102 | // Callback to be invoked for rssi threshold breach. |
| 103 | std::function<void((wifi_request_id, uint8_t*, int8_t))> |
| 104 | on_rssi_threshold_breached_internal_callback; |
| 105 | void onRssiThresholdBreached(wifi_request_id id, uint8_t* bssid, int8_t rssi) { |
| 106 | if (on_rssi_threshold_breached_internal_callback) { |
| 107 | on_rssi_threshold_breached_internal_callback(id, bssid, rssi); |
| 108 | } |
| 109 | } |
| 110 | |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 111 | // Callback to be invoked for ring buffer data indication. |
| 112 | std::function<void(char*, char*, int, wifi_ring_buffer_status*)> |
| 113 | on_ring_buffer_data_internal_callback; |
| 114 | void onRingBufferData(char* ring_name, |
| 115 | char* buffer, |
| 116 | int buffer_size, |
| 117 | wifi_ring_buffer_status* status) { |
| 118 | if (on_ring_buffer_data_internal_callback) { |
| 119 | on_ring_buffer_data_internal_callback( |
| 120 | ring_name, buffer, buffer_size, status); |
| 121 | } |
| 122 | } |
| 123 | |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 124 | // Callback to be invoked for error alert indication. |
| 125 | std::function<void(wifi_request_id, char*, int, int)> |
| 126 | on_error_alert_internal_callback; |
| 127 | void onErrorAlert(wifi_request_id id, |
| 128 | char* buffer, |
| 129 | int buffer_size, |
| 130 | int err_code) { |
| 131 | if (on_error_alert_internal_callback) { |
| 132 | on_error_alert_internal_callback(id, buffer, buffer_size, err_code); |
| 133 | } |
| 134 | } |
| 135 | |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 136 | // Callback to be invoked for rtt results results. |
| 137 | std::function<void( |
| 138 | wifi_request_id, unsigned num_results, wifi_rtt_result* rtt_results[])> |
| 139 | on_rtt_results_internal_callback; |
| 140 | void onRttResults(wifi_request_id id, |
| 141 | unsigned num_results, |
| 142 | wifi_rtt_result* rtt_results[]) { |
| 143 | if (on_rtt_results_internal_callback) { |
| 144 | on_rtt_results_internal_callback(id, num_results, rtt_results); |
| 145 | } |
| 146 | } |
| 147 | |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 148 | // Callbacks for the various NAN operations. |
| 149 | // NOTE: These have very little conversions to perform before invoking the user |
| 150 | // callbacks. |
| 151 | // So, handle all of them here directly to avoid adding an unnecessary layer. |
| 152 | std::function<void(transaction_id, const NanResponseMsg&)> |
| 153 | on_nan_notify_response_user_callback; |
| 154 | void onNanNotifyResponse(transaction_id id, NanResponseMsg* msg) { |
| 155 | if (on_nan_notify_response_user_callback && msg) { |
| 156 | on_nan_notify_response_user_callback(id, *msg); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | std::function<void(const NanPublishTerminatedInd&)> |
| 161 | on_nan_event_publish_terminated_user_callback; |
| 162 | void onNanEventPublishTerminated(NanPublishTerminatedInd* event) { |
| 163 | if (on_nan_event_publish_terminated_user_callback && event) { |
| 164 | on_nan_event_publish_terminated_user_callback(*event); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | std::function<void(const NanMatchInd&)> on_nan_event_match_user_callback; |
| 169 | void onNanEventMatch(NanMatchInd* event) { |
| 170 | if (on_nan_event_match_user_callback && event) { |
| 171 | on_nan_event_match_user_callback(*event); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | std::function<void(const NanMatchExpiredInd&)> |
| 176 | on_nan_event_match_expired_user_callback; |
| 177 | void onNanEventMatchExpired(NanMatchExpiredInd* event) { |
| 178 | if (on_nan_event_match_expired_user_callback && event) { |
| 179 | on_nan_event_match_expired_user_callback(*event); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | std::function<void(const NanSubscribeTerminatedInd&)> |
| 184 | on_nan_event_subscribe_terminated_user_callback; |
| 185 | void onNanEventSubscribeTerminated(NanSubscribeTerminatedInd* event) { |
| 186 | if (on_nan_event_subscribe_terminated_user_callback && event) { |
| 187 | on_nan_event_subscribe_terminated_user_callback(*event); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | std::function<void(const NanFollowupInd&)> on_nan_event_followup_user_callback; |
| 192 | void onNanEventFollowup(NanFollowupInd* event) { |
| 193 | if (on_nan_event_followup_user_callback && event) { |
| 194 | on_nan_event_followup_user_callback(*event); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | std::function<void(const NanDiscEngEventInd&)> |
| 199 | on_nan_event_disc_eng_event_user_callback; |
| 200 | void onNanEventDiscEngEvent(NanDiscEngEventInd* event) { |
| 201 | if (on_nan_event_disc_eng_event_user_callback && event) { |
| 202 | on_nan_event_disc_eng_event_user_callback(*event); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | std::function<void(const NanDisabledInd&)> on_nan_event_disabled_user_callback; |
| 207 | void onNanEventDisabled(NanDisabledInd* event) { |
| 208 | if (on_nan_event_disabled_user_callback && event) { |
| 209 | on_nan_event_disabled_user_callback(*event); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | std::function<void(const NanTCAInd&)> on_nan_event_tca_user_callback; |
| 214 | void onNanEventTca(NanTCAInd* event) { |
| 215 | if (on_nan_event_tca_user_callback && event) { |
| 216 | on_nan_event_tca_user_callback(*event); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | std::function<void(const NanBeaconSdfPayloadInd&)> |
| 221 | on_nan_event_beacon_sdf_payload_user_callback; |
| 222 | void onNanEventBeaconSdfPayload(NanBeaconSdfPayloadInd* event) { |
| 223 | if (on_nan_event_beacon_sdf_payload_user_callback && event) { |
| 224 | on_nan_event_beacon_sdf_payload_user_callback(*event); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | std::function<void(const NanDataPathRequestInd&)> |
| 229 | on_nan_event_data_path_request_user_callback; |
| 230 | void onNanEventDataPathRequest(NanDataPathRequestInd* event) { |
| 231 | if (on_nan_event_data_path_request_user_callback && event) { |
| 232 | on_nan_event_data_path_request_user_callback(*event); |
| 233 | } |
| 234 | } |
| 235 | std::function<void(const NanDataPathConfirmInd&)> |
| 236 | on_nan_event_data_path_confirm_user_callback; |
| 237 | void onNanEventDataPathConfirm(NanDataPathConfirmInd* event) { |
| 238 | if (on_nan_event_data_path_confirm_user_callback && event) { |
| 239 | on_nan_event_data_path_confirm_user_callback(*event); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | std::function<void(const NanDataPathEndInd&)> |
| 244 | on_nan_event_data_path_end_user_callback; |
| 245 | void onNanEventDataPathEnd(NanDataPathEndInd* event) { |
| 246 | if (on_nan_event_data_path_end_user_callback && event) { |
| 247 | on_nan_event_data_path_end_user_callback(*event); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | std::function<void(const NanTransmitFollowupInd&)> |
| 252 | on_nan_event_transmit_follow_up_user_callback; |
| 253 | void onNanEventTransmitFollowUp(NanTransmitFollowupInd* event) { |
| 254 | if (on_nan_event_transmit_follow_up_user_callback && event) { |
| 255 | on_nan_event_transmit_follow_up_user_callback(*event); |
| 256 | } |
| 257 | } |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 258 | // End of the free-standing "C" style callbacks. |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 259 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 260 | WifiLegacyHal::WifiLegacyHal() |
| 261 | : global_handle_(nullptr), |
| 262 | wlan_interface_handle_(nullptr), |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 263 | awaiting_event_loop_termination_(false), |
| 264 | is_started_(false) {} |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 265 | |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 266 | wifi_error WifiLegacyHal::initialize() { |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 267 | LOG(DEBUG) << "Initialize legacy HAL"; |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 268 | // TODO: Add back the HAL Tool if we need to. All we need from the HAL tool |
| 269 | // for now is this function call which we can directly call. |
Roshan Pius | e73a506 | 2016-12-12 08:53:34 -0800 | [diff] [blame] | 270 | if (!initHalFuncTableWithStubs(&global_func_table_)) { |
| 271 | LOG(ERROR) << "Failed to initialize legacy hal function table with stubs"; |
| 272 | return WIFI_ERROR_UNKNOWN; |
| 273 | } |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 274 | wifi_error status = init_wifi_vendor_hal_func_table(&global_func_table_); |
| 275 | if (status != WIFI_SUCCESS) { |
Roshan Pius | 908a69a | 2016-10-03 13:33:23 -0700 | [diff] [blame] | 276 | LOG(ERROR) << "Failed to initialize legacy hal function table"; |
| 277 | return WIFI_ERROR_UNKNOWN; |
| 278 | } |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 279 | return WIFI_SUCCESS; |
| 280 | } |
| 281 | |
| 282 | wifi_error WifiLegacyHal::start() { |
| 283 | // Ensure that we're starting in a good state. |
| 284 | CHECK(global_func_table_.wifi_initialize && !global_handle_ && |
| 285 | !wlan_interface_handle_ && !awaiting_event_loop_termination_); |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 286 | if (is_started_) { |
| 287 | LOG(DEBUG) << "Legacy HAL already started"; |
| 288 | return WIFI_SUCCESS; |
| 289 | } |
| 290 | LOG(DEBUG) << "Starting legacy HAL"; |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 291 | if (!iface_tool_.SetWifiUpState(true)) { |
Roshan Pius | 908a69a | 2016-10-03 13:33:23 -0700 | [diff] [blame] | 292 | LOG(ERROR) << "Failed to set WiFi interface up"; |
| 293 | return WIFI_ERROR_UNKNOWN; |
| 294 | } |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 295 | wifi_error status = global_func_table_.wifi_initialize(&global_handle_); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 296 | if (status != WIFI_SUCCESS || !global_handle_) { |
| 297 | LOG(ERROR) << "Failed to retrieve global handle"; |
| 298 | return status; |
| 299 | } |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 300 | std::thread(&WifiLegacyHal::runEventLoop, this).detach(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 301 | status = retrieveWlanInterfaceHandle(); |
| 302 | if (status != WIFI_SUCCESS || !wlan_interface_handle_) { |
| 303 | LOG(ERROR) << "Failed to retrieve wlan interface handle"; |
| 304 | return status; |
| 305 | } |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 306 | LOG(DEBUG) << "Legacy HAL start complete"; |
| 307 | is_started_ = true; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 308 | return WIFI_SUCCESS; |
| 309 | } |
| 310 | |
| 311 | wifi_error WifiLegacyHal::stop( |
| 312 | const std::function<void()>& on_stop_complete_user_callback) { |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 313 | if (!is_started_) { |
| 314 | LOG(DEBUG) << "Legacy HAL already stopped"; |
| 315 | on_stop_complete_user_callback(); |
| 316 | return WIFI_SUCCESS; |
| 317 | } |
| 318 | LOG(DEBUG) << "Stopping legacy HAL"; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 319 | on_stop_complete_internal_callback = [&](wifi_handle handle) { |
| 320 | CHECK_EQ(global_handle_, handle) << "Handle mismatch"; |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 321 | // Invalidate all the internal pointers now that the HAL is |
| 322 | // stopped. |
| 323 | invalidate(); |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 324 | iface_tool_.SetWifiUpState(false); |
| 325 | on_stop_complete_user_callback(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 326 | }; |
| 327 | awaiting_event_loop_termination_ = true; |
| 328 | global_func_table_.wifi_cleanup(global_handle_, onStopComplete); |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 329 | LOG(DEBUG) << "Legacy HAL stop complete"; |
| 330 | is_started_ = false; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 331 | return WIFI_SUCCESS; |
| 332 | } |
| 333 | |
Roshan Pius | ab5c471 | 2016-10-06 14:37:15 -0700 | [diff] [blame] | 334 | std::string WifiLegacyHal::getApIfaceName() { |
| 335 | // Fake name. This interface does not exist in legacy HAL |
| 336 | // API's. |
| 337 | return "ap0"; |
| 338 | } |
| 339 | |
| 340 | std::string WifiLegacyHal::getNanIfaceName() { |
| 341 | // Fake name. This interface does not exist in legacy HAL |
| 342 | // API's. |
| 343 | return "nan0"; |
| 344 | } |
| 345 | |
| 346 | std::string WifiLegacyHal::getP2pIfaceName() { |
| 347 | std::array<char, PROPERTY_VALUE_MAX> buffer; |
| 348 | property_get("wifi.direct.interface", buffer.data(), "p2p0"); |
| 349 | return buffer.data(); |
| 350 | } |
| 351 | |
| 352 | std::string WifiLegacyHal::getStaIfaceName() { |
| 353 | std::array<char, PROPERTY_VALUE_MAX> buffer; |
| 354 | property_get("wifi.interface", buffer.data(), "wlan0"); |
| 355 | return buffer.data(); |
| 356 | } |
| 357 | |
| 358 | std::pair<wifi_error, std::string> WifiLegacyHal::getDriverVersion() { |
Roshan Pius | 4b26c83 | 2016-10-03 12:49:58 -0700 | [diff] [blame] | 359 | std::array<char, kMaxVersionStringLength> buffer; |
| 360 | buffer.fill(0); |
| 361 | wifi_error status = global_func_table_.wifi_get_driver_version( |
| 362 | wlan_interface_handle_, buffer.data(), buffer.size()); |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 363 | return {status, buffer.data()}; |
Roshan Pius | 4b26c83 | 2016-10-03 12:49:58 -0700 | [diff] [blame] | 364 | } |
| 365 | |
Roshan Pius | ab5c471 | 2016-10-06 14:37:15 -0700 | [diff] [blame] | 366 | std::pair<wifi_error, std::string> WifiLegacyHal::getFirmwareVersion() { |
Roshan Pius | 4b26c83 | 2016-10-03 12:49:58 -0700 | [diff] [blame] | 367 | std::array<char, kMaxVersionStringLength> buffer; |
| 368 | buffer.fill(0); |
| 369 | wifi_error status = global_func_table_.wifi_get_firmware_version( |
| 370 | wlan_interface_handle_, buffer.data(), buffer.size()); |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 371 | return {status, buffer.data()}; |
Roshan Pius | 4b26c83 | 2016-10-03 12:49:58 -0700 | [diff] [blame] | 372 | } |
| 373 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 374 | std::pair<wifi_error, std::vector<uint8_t>> |
Roshan Pius | ab5c471 | 2016-10-06 14:37:15 -0700 | [diff] [blame] | 375 | WifiLegacyHal::requestDriverMemoryDump() { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 376 | std::vector<uint8_t> driver_dump; |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 377 | on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer, |
| 378 | int buffer_size) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 379 | driver_dump.insert(driver_dump.end(), |
| 380 | reinterpret_cast<uint8_t*>(buffer), |
| 381 | reinterpret_cast<uint8_t*>(buffer) + buffer_size); |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 382 | }; |
| 383 | wifi_error status = global_func_table_.wifi_get_driver_memory_dump( |
| 384 | wlan_interface_handle_, {onDriverMemoryDump}); |
| 385 | on_driver_memory_dump_internal_callback = nullptr; |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 386 | return {status, std::move(driver_dump)}; |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 387 | } |
| 388 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 389 | std::pair<wifi_error, std::vector<uint8_t>> |
Roshan Pius | ab5c471 | 2016-10-06 14:37:15 -0700 | [diff] [blame] | 390 | WifiLegacyHal::requestFirmwareMemoryDump() { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 391 | std::vector<uint8_t> firmware_dump; |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 392 | on_firmware_memory_dump_internal_callback = [&firmware_dump]( |
| 393 | char* buffer, int buffer_size) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 394 | firmware_dump.insert(firmware_dump.end(), |
| 395 | reinterpret_cast<uint8_t*>(buffer), |
| 396 | reinterpret_cast<uint8_t*>(buffer) + buffer_size); |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 397 | }; |
| 398 | wifi_error status = global_func_table_.wifi_get_firmware_memory_dump( |
| 399 | wlan_interface_handle_, {onFirmwareMemoryDump}); |
| 400 | on_firmware_memory_dump_internal_callback = nullptr; |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 401 | return {status, std::move(firmware_dump)}; |
| 402 | } |
| 403 | |
| 404 | std::pair<wifi_error, uint32_t> WifiLegacyHal::getSupportedFeatureSet() { |
| 405 | feature_set set; |
| 406 | static_assert(sizeof(set) == sizeof(uint32_t), |
| 407 | "Some features can not be represented in output"); |
| 408 | wifi_error status = global_func_table_.wifi_get_supported_feature_set( |
| 409 | wlan_interface_handle_, &set); |
| 410 | return {status, static_cast<uint32_t>(set)}; |
| 411 | } |
| 412 | |
| 413 | std::pair<wifi_error, PacketFilterCapabilities> |
| 414 | WifiLegacyHal::getPacketFilterCapabilities() { |
| 415 | PacketFilterCapabilities caps; |
| 416 | wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities( |
| 417 | wlan_interface_handle_, &caps.version, &caps.max_len); |
| 418 | return {status, caps}; |
| 419 | } |
| 420 | |
| 421 | wifi_error WifiLegacyHal::setPacketFilter(const std::vector<uint8_t>& program) { |
| 422 | return global_func_table_.wifi_set_packet_filter( |
| 423 | wlan_interface_handle_, program.data(), program.size()); |
Roshan Pius | cdb77f3 | 2016-10-03 14:09:57 -0700 | [diff] [blame] | 424 | } |
| 425 | |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 426 | std::pair<wifi_error, wifi_gscan_capabilities> |
| 427 | WifiLegacyHal::getGscanCapabilities() { |
| 428 | wifi_gscan_capabilities caps; |
| 429 | wifi_error status = global_func_table_.wifi_get_gscan_capabilities( |
| 430 | wlan_interface_handle_, &caps); |
| 431 | return {status, caps}; |
| 432 | } |
| 433 | |
| 434 | wifi_error WifiLegacyHal::startGscan( |
| 435 | wifi_request_id id, |
| 436 | const wifi_scan_cmd_params& params, |
| 437 | const std::function<void(wifi_request_id)>& on_failure_user_callback, |
| 438 | const on_gscan_results_callback& on_results_user_callback, |
| 439 | const on_gscan_full_result_callback& on_full_result_user_callback) { |
| 440 | // If there is already an ongoing background scan, reject new scan requests. |
| 441 | if (on_gscan_event_internal_callback || |
| 442 | on_gscan_full_result_internal_callback) { |
| 443 | return WIFI_ERROR_NOT_AVAILABLE; |
| 444 | } |
| 445 | |
| 446 | // This callback will be used to either trigger |on_results_user_callback| or |
| 447 | // |on_failure_user_callback|. |
| 448 | on_gscan_event_internal_callback = |
| 449 | [on_failure_user_callback, on_results_user_callback, this]( |
| 450 | wifi_request_id id, wifi_scan_event event) { |
| 451 | switch (event) { |
| 452 | case WIFI_SCAN_RESULTS_AVAILABLE: |
| 453 | case WIFI_SCAN_THRESHOLD_NUM_SCANS: |
| 454 | case WIFI_SCAN_THRESHOLD_PERCENT: { |
| 455 | wifi_error status; |
| 456 | std::vector<wifi_cached_scan_results> cached_scan_results; |
| 457 | std::tie(status, cached_scan_results) = getGscanCachedResults(); |
| 458 | if (status == WIFI_SUCCESS) { |
| 459 | on_results_user_callback(id, cached_scan_results); |
| 460 | return; |
| 461 | } |
| 462 | } |
| 463 | // Fall through if failed. Failure to retrieve cached scan results |
| 464 | // should trigger a background scan failure. |
| 465 | case WIFI_SCAN_FAILED: |
| 466 | on_failure_user_callback(id); |
| 467 | on_gscan_event_internal_callback = nullptr; |
| 468 | on_gscan_full_result_internal_callback = nullptr; |
| 469 | return; |
| 470 | } |
| 471 | LOG(FATAL) << "Unexpected gscan event received: " << event; |
| 472 | }; |
| 473 | |
| 474 | on_gscan_full_result_internal_callback = [on_full_result_user_callback]( |
| 475 | wifi_request_id id, wifi_scan_result* result, uint32_t buckets_scanned) { |
| 476 | if (result) { |
| 477 | on_full_result_user_callback(id, result, buckets_scanned); |
| 478 | } |
| 479 | }; |
| 480 | |
| 481 | wifi_scan_result_handler handler = {onGscanFullResult, onGscanEvent}; |
| 482 | wifi_error status = global_func_table_.wifi_start_gscan( |
| 483 | id, wlan_interface_handle_, params, handler); |
| 484 | if (status != WIFI_SUCCESS) { |
| 485 | on_gscan_event_internal_callback = nullptr; |
| 486 | on_gscan_full_result_internal_callback = nullptr; |
| 487 | } |
| 488 | return status; |
| 489 | } |
| 490 | |
| 491 | wifi_error WifiLegacyHal::stopGscan(wifi_request_id id) { |
| 492 | // If there is no an ongoing background scan, reject stop requests. |
| 493 | // TODO(b/32337212): This needs to be handled by the HIDL object because we |
| 494 | // need to return the NOT_STARTED error code. |
| 495 | if (!on_gscan_event_internal_callback && |
| 496 | !on_gscan_full_result_internal_callback) { |
| 497 | return WIFI_ERROR_NOT_AVAILABLE; |
| 498 | } |
| 499 | wifi_error status = |
| 500 | global_func_table_.wifi_stop_gscan(id, wlan_interface_handle_); |
| 501 | // If the request Id is wrong, don't stop the ongoing background scan. Any |
| 502 | // other error should be treated as the end of background scan. |
| 503 | if (status != WIFI_ERROR_INVALID_REQUEST_ID) { |
| 504 | on_gscan_event_internal_callback = nullptr; |
| 505 | on_gscan_full_result_internal_callback = nullptr; |
| 506 | } |
| 507 | return status; |
| 508 | } |
| 509 | |
| 510 | std::pair<wifi_error, std::vector<uint32_t>> |
| 511 | WifiLegacyHal::getValidFrequenciesForGscan(wifi_band band) { |
| 512 | static_assert(sizeof(uint32_t) >= sizeof(wifi_channel), |
| 513 | "Wifi Channel cannot be represented in output"); |
| 514 | std::vector<uint32_t> freqs; |
| 515 | freqs.resize(kMaxGscanFrequenciesForBand); |
| 516 | int32_t num_freqs = 0; |
| 517 | wifi_error status = global_func_table_.wifi_get_valid_channels( |
| 518 | wlan_interface_handle_, |
| 519 | band, |
| 520 | freqs.size(), |
| 521 | reinterpret_cast<wifi_channel*>(freqs.data()), |
| 522 | &num_freqs); |
| 523 | CHECK(num_freqs >= 0 && |
| 524 | static_cast<uint32_t>(num_freqs) <= kMaxGscanFrequenciesForBand); |
| 525 | freqs.resize(num_freqs); |
| 526 | return {status, std::move(freqs)}; |
| 527 | } |
| 528 | |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 529 | wifi_error WifiLegacyHal::enableLinkLayerStats(bool debug) { |
| 530 | wifi_link_layer_params params; |
| 531 | params.mpdu_size_threshold = kLinkLayerStatsDataMpduSizeThreshold; |
| 532 | params.aggressive_statistics_gathering = debug; |
| 533 | return global_func_table_.wifi_set_link_stats(wlan_interface_handle_, params); |
| 534 | } |
| 535 | |
| 536 | wifi_error WifiLegacyHal::disableLinkLayerStats() { |
| 537 | // TODO: Do we care about these responses? |
| 538 | uint32_t clear_mask_rsp; |
| 539 | uint8_t stop_rsp; |
| 540 | return global_func_table_.wifi_clear_link_stats( |
| 541 | wlan_interface_handle_, 0xFFFFFFFF, &clear_mask_rsp, 1, &stop_rsp); |
| 542 | } |
| 543 | |
| 544 | std::pair<wifi_error, LinkLayerStats> WifiLegacyHal::getLinkLayerStats() { |
| 545 | LinkLayerStats link_stats{}; |
| 546 | LinkLayerStats* link_stats_ptr = &link_stats; |
| 547 | |
| 548 | on_link_layer_stats_result_internal_callback = [&link_stats_ptr]( |
| 549 | wifi_request_id /* id */, |
| 550 | wifi_iface_stat* iface_stats_ptr, |
| 551 | int num_radios, |
| 552 | wifi_radio_stat* radio_stats_ptr) { |
| 553 | if (iface_stats_ptr != nullptr) { |
| 554 | link_stats_ptr->iface = *iface_stats_ptr; |
| 555 | link_stats_ptr->iface.num_peers = 0; |
| 556 | } else { |
| 557 | LOG(ERROR) << "Invalid iface stats in link layer stats"; |
| 558 | } |
| 559 | if (num_radios == 1 && radio_stats_ptr != nullptr) { |
| 560 | link_stats_ptr->radio = *radio_stats_ptr; |
| 561 | // Copy over the tx level array to the separate vector. |
| 562 | if (radio_stats_ptr->num_tx_levels > 0 && |
| 563 | radio_stats_ptr->tx_time_per_levels != nullptr) { |
| 564 | link_stats_ptr->radio_tx_time_per_levels.assign( |
| 565 | radio_stats_ptr->tx_time_per_levels, |
| 566 | radio_stats_ptr->tx_time_per_levels + |
| 567 | radio_stats_ptr->num_tx_levels); |
| 568 | } |
| 569 | link_stats_ptr->radio.num_tx_levels = 0; |
| 570 | link_stats_ptr->radio.tx_time_per_levels = nullptr; |
| 571 | } else { |
| 572 | LOG(ERROR) << "Invalid radio stats in link layer stats"; |
| 573 | } |
| 574 | }; |
| 575 | |
| 576 | wifi_error status = global_func_table_.wifi_get_link_stats( |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 577 | 0, wlan_interface_handle_, {onLinkLayerStatsResult}); |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 578 | on_link_layer_stats_result_internal_callback = nullptr; |
| 579 | return {status, link_stats}; |
| 580 | } |
| 581 | |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 582 | wifi_error WifiLegacyHal::startRssiMonitoring( |
| 583 | wifi_request_id id, |
| 584 | int8_t max_rssi, |
| 585 | int8_t min_rssi, |
| 586 | const on_rssi_threshold_breached_callback& |
| 587 | on_threshold_breached_user_callback) { |
| 588 | if (on_rssi_threshold_breached_internal_callback) { |
| 589 | return WIFI_ERROR_NOT_AVAILABLE; |
| 590 | } |
| 591 | on_rssi_threshold_breached_internal_callback = |
| 592 | [on_threshold_breached_user_callback]( |
| 593 | wifi_request_id id, uint8_t* bssid_ptr, int8_t rssi) { |
| 594 | if (!bssid_ptr) { |
| 595 | return; |
| 596 | } |
| 597 | std::array<uint8_t, 6> bssid_arr; |
| 598 | // |bssid_ptr| pointer is assumed to have 6 bytes for the mac address. |
| 599 | std::copy(bssid_ptr, bssid_ptr + 6, std::begin(bssid_arr)); |
| 600 | on_threshold_breached_user_callback(id, bssid_arr, rssi); |
| 601 | }; |
Roshan Pius | 7a41d9d | 2016-12-06 10:12:59 -0800 | [diff] [blame] | 602 | wifi_error status = |
| 603 | global_func_table_.wifi_start_rssi_monitoring(id, |
| 604 | wlan_interface_handle_, |
| 605 | max_rssi, |
| 606 | min_rssi, |
| 607 | {onRssiThresholdBreached}); |
| 608 | if (status != WIFI_SUCCESS) { |
| 609 | on_rssi_threshold_breached_internal_callback = nullptr; |
| 610 | } |
| 611 | return status; |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | wifi_error WifiLegacyHal::stopRssiMonitoring(wifi_request_id id) { |
| 615 | if (!on_rssi_threshold_breached_internal_callback) { |
| 616 | return WIFI_ERROR_NOT_AVAILABLE; |
| 617 | } |
| 618 | wifi_error status = |
| 619 | global_func_table_.wifi_stop_rssi_monitoring(id, wlan_interface_handle_); |
| 620 | // If the request Id is wrong, don't stop the ongoing rssi monitoring. Any |
| 621 | // other error should be treated as the end of background scan. |
| 622 | if (status != WIFI_ERROR_INVALID_REQUEST_ID) { |
| 623 | on_rssi_threshold_breached_internal_callback = nullptr; |
| 624 | } |
| 625 | return status; |
| 626 | } |
| 627 | |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 628 | std::pair<wifi_error, wifi_roaming_capabilities> |
| 629 | WifiLegacyHal::getRoamingCapabilities() { |
| 630 | wifi_roaming_capabilities caps; |
| 631 | wifi_error status = global_func_table_.wifi_get_roaming_capabilities( |
| 632 | wlan_interface_handle_, &caps); |
| 633 | return {status, caps}; |
| 634 | } |
| 635 | |
| 636 | wifi_error WifiLegacyHal::enableFirmwareRoaming(fw_roaming_state_t state) { |
| 637 | return global_func_table_.wifi_enable_firmware_roaming(wlan_interface_handle_, |
| 638 | state); |
| 639 | } |
| 640 | |
| 641 | wifi_error WifiLegacyHal::configureRoaming(const wifi_roaming_config& config) { |
| 642 | wifi_roaming_config config_internal = config; |
| 643 | return global_func_table_.wifi_configure_roaming(wlan_interface_handle_, |
| 644 | &config_internal); |
| 645 | } |
| 646 | |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 647 | std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet() { |
| 648 | uint32_t supported_features; |
| 649 | wifi_error status = global_func_table_.wifi_get_logger_supported_feature_set( |
| 650 | wlan_interface_handle_, &supported_features); |
| 651 | return {status, supported_features}; |
| 652 | } |
| 653 | |
| 654 | wifi_error WifiLegacyHal::startPktFateMonitoring() { |
| 655 | return global_func_table_.wifi_start_pkt_fate_monitoring( |
| 656 | wlan_interface_handle_); |
| 657 | } |
| 658 | |
| 659 | std::pair<wifi_error, std::vector<wifi_tx_report>> |
| 660 | WifiLegacyHal::getTxPktFates() { |
| 661 | std::vector<wifi_tx_report> tx_pkt_fates; |
| 662 | tx_pkt_fates.resize(MAX_FATE_LOG_LEN); |
| 663 | size_t num_fates = 0; |
| 664 | wifi_error status = |
| 665 | global_func_table_.wifi_get_tx_pkt_fates(wlan_interface_handle_, |
| 666 | tx_pkt_fates.data(), |
| 667 | tx_pkt_fates.size(), |
| 668 | &num_fates); |
| 669 | CHECK(num_fates <= MAX_FATE_LOG_LEN); |
| 670 | tx_pkt_fates.resize(num_fates); |
| 671 | return {status, std::move(tx_pkt_fates)}; |
| 672 | } |
| 673 | |
| 674 | std::pair<wifi_error, std::vector<wifi_rx_report>> |
| 675 | WifiLegacyHal::getRxPktFates() { |
| 676 | std::vector<wifi_rx_report> rx_pkt_fates; |
| 677 | rx_pkt_fates.resize(MAX_FATE_LOG_LEN); |
| 678 | size_t num_fates = 0; |
| 679 | wifi_error status = |
| 680 | global_func_table_.wifi_get_rx_pkt_fates(wlan_interface_handle_, |
| 681 | rx_pkt_fates.data(), |
| 682 | rx_pkt_fates.size(), |
| 683 | &num_fates); |
| 684 | CHECK(num_fates <= MAX_FATE_LOG_LEN); |
| 685 | rx_pkt_fates.resize(num_fates); |
| 686 | return {status, std::move(rx_pkt_fates)}; |
| 687 | } |
| 688 | |
| 689 | std::pair<wifi_error, WakeReasonStats> WifiLegacyHal::getWakeReasonStats() { |
| 690 | WakeReasonStats stats; |
| 691 | stats.cmd_event_wake_cnt.resize(kMaxWakeReasonStatsArraySize); |
| 692 | stats.driver_fw_local_wake_cnt.resize(kMaxWakeReasonStatsArraySize); |
| 693 | |
| 694 | // This legacy struct needs separate memory to store the variable sized wake |
| 695 | // reason types. |
| 696 | stats.wake_reason_cnt.cmd_event_wake_cnt = |
| 697 | reinterpret_cast<int32_t*>(stats.cmd_event_wake_cnt.data()); |
| 698 | stats.wake_reason_cnt.cmd_event_wake_cnt_sz = stats.cmd_event_wake_cnt.size(); |
| 699 | stats.wake_reason_cnt.cmd_event_wake_cnt_used = 0; |
| 700 | stats.wake_reason_cnt.driver_fw_local_wake_cnt = |
| 701 | reinterpret_cast<int32_t*>(stats.driver_fw_local_wake_cnt.data()); |
| 702 | stats.wake_reason_cnt.driver_fw_local_wake_cnt_sz = |
| 703 | stats.driver_fw_local_wake_cnt.size(); |
| 704 | stats.wake_reason_cnt.driver_fw_local_wake_cnt_used = 0; |
| 705 | |
| 706 | wifi_error status = global_func_table_.wifi_get_wake_reason_stats( |
| 707 | wlan_interface_handle_, &stats.wake_reason_cnt); |
| 708 | |
| 709 | CHECK(stats.wake_reason_cnt.cmd_event_wake_cnt_used >= 0 && |
| 710 | static_cast<uint32_t>(stats.wake_reason_cnt.cmd_event_wake_cnt_used) <= |
| 711 | kMaxWakeReasonStatsArraySize); |
| 712 | stats.cmd_event_wake_cnt.resize( |
| 713 | stats.wake_reason_cnt.cmd_event_wake_cnt_used); |
| 714 | stats.wake_reason_cnt.cmd_event_wake_cnt = nullptr; |
| 715 | |
| 716 | CHECK(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used >= 0 && |
| 717 | static_cast<uint32_t>( |
| 718 | stats.wake_reason_cnt.driver_fw_local_wake_cnt_used) <= |
| 719 | kMaxWakeReasonStatsArraySize); |
| 720 | stats.driver_fw_local_wake_cnt.resize( |
| 721 | stats.wake_reason_cnt.driver_fw_local_wake_cnt_used); |
| 722 | stats.wake_reason_cnt.driver_fw_local_wake_cnt = nullptr; |
| 723 | |
| 724 | return {status, stats}; |
| 725 | } |
| 726 | |
| 727 | wifi_error WifiLegacyHal::registerRingBufferCallbackHandler( |
| 728 | const on_ring_buffer_data_callback& on_user_data_callback) { |
| 729 | if (on_ring_buffer_data_internal_callback) { |
| 730 | return WIFI_ERROR_NOT_AVAILABLE; |
| 731 | } |
| 732 | on_ring_buffer_data_internal_callback = [on_user_data_callback]( |
| 733 | char* ring_name, |
| 734 | char* buffer, |
| 735 | int buffer_size, |
| 736 | wifi_ring_buffer_status* status) { |
| 737 | if (status && buffer) { |
| 738 | std::vector<uint8_t> buffer_vector( |
| 739 | reinterpret_cast<uint8_t*>(buffer), |
| 740 | reinterpret_cast<uint8_t*>(buffer) + buffer_size); |
| 741 | on_user_data_callback(ring_name, buffer_vector, *status); |
| 742 | } |
| 743 | }; |
Roshan Pius | adc87cb | 2016-12-14 18:02:56 -0800 | [diff] [blame^] | 744 | wifi_error status = global_func_table_.wifi_set_log_handler( |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 745 | 0, wlan_interface_handle_, {onRingBufferData}); |
Roshan Pius | adc87cb | 2016-12-14 18:02:56 -0800 | [diff] [blame^] | 746 | if (status != WIFI_SUCCESS) { |
| 747 | on_ring_buffer_data_internal_callback = nullptr; |
| 748 | } |
| 749 | return status; |
| 750 | } |
| 751 | |
| 752 | wifi_error WifiLegacyHal::deregisterRingBufferCallbackHandler() { |
| 753 | if (!on_ring_buffer_data_internal_callback) { |
| 754 | return WIFI_ERROR_NOT_AVAILABLE; |
| 755 | } |
| 756 | on_ring_buffer_data_internal_callback = nullptr; |
| 757 | return global_func_table_.wifi_reset_log_handler(0, wlan_interface_handle_); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 758 | } |
| 759 | |
| 760 | std::pair<wifi_error, std::vector<wifi_ring_buffer_status>> |
| 761 | WifiLegacyHal::getRingBuffersStatus() { |
| 762 | std::vector<wifi_ring_buffer_status> ring_buffers_status; |
| 763 | ring_buffers_status.resize(kMaxRingBuffers); |
| 764 | uint32_t num_rings = 0; |
| 765 | wifi_error status = global_func_table_.wifi_get_ring_buffers_status( |
| 766 | wlan_interface_handle_, &num_rings, ring_buffers_status.data()); |
| 767 | CHECK(num_rings <= kMaxRingBuffers); |
| 768 | ring_buffers_status.resize(num_rings); |
| 769 | return {status, std::move(ring_buffers_status)}; |
| 770 | } |
| 771 | |
| 772 | wifi_error WifiLegacyHal::startRingBufferLogging(const std::string& ring_name, |
| 773 | uint32_t verbose_level, |
| 774 | uint32_t max_interval_sec, |
| 775 | uint32_t min_data_size) { |
| 776 | std::vector<char> ring_name_internal(ring_name.begin(), ring_name.end()); |
| 777 | return global_func_table_.wifi_start_logging(wlan_interface_handle_, |
| 778 | verbose_level, |
| 779 | 0, |
| 780 | max_interval_sec, |
| 781 | min_data_size, |
| 782 | ring_name_internal.data()); |
| 783 | } |
| 784 | |
| 785 | wifi_error WifiLegacyHal::getRingBufferData(const std::string& ring_name) { |
| 786 | std::vector<char> ring_name_internal(ring_name.begin(), ring_name.end()); |
| 787 | return global_func_table_.wifi_get_ring_data(wlan_interface_handle_, |
| 788 | ring_name_internal.data()); |
| 789 | } |
| 790 | |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 791 | wifi_error WifiLegacyHal::registerErrorAlertCallbackHandler( |
| 792 | const on_error_alert_callback& on_user_alert_callback) { |
| 793 | if (on_error_alert_internal_callback) { |
| 794 | return WIFI_ERROR_NOT_AVAILABLE; |
| 795 | } |
| 796 | on_error_alert_internal_callback = [on_user_alert_callback]( |
| 797 | wifi_request_id id, char* buffer, int buffer_size, int err_code) { |
| 798 | if (buffer) { |
| 799 | CHECK(id == 0); |
| 800 | on_user_alert_callback( |
| 801 | err_code, |
| 802 | std::vector<uint8_t>( |
| 803 | reinterpret_cast<uint8_t*>(buffer), |
| 804 | reinterpret_cast<uint8_t*>(buffer) + buffer_size)); |
| 805 | } |
| 806 | }; |
| 807 | wifi_error status = global_func_table_.wifi_set_alert_handler( |
| 808 | 0, wlan_interface_handle_, {onErrorAlert}); |
| 809 | if (status != WIFI_SUCCESS) { |
| 810 | on_error_alert_internal_callback = nullptr; |
| 811 | } |
| 812 | return status; |
| 813 | } |
| 814 | |
| 815 | wifi_error WifiLegacyHal::deregisterErrorAlertCallbackHandler() { |
| 816 | if (!on_error_alert_internal_callback) { |
| 817 | return WIFI_ERROR_NOT_AVAILABLE; |
| 818 | } |
| 819 | on_error_alert_internal_callback = nullptr; |
| 820 | return global_func_table_.wifi_reset_alert_handler(0, wlan_interface_handle_); |
| 821 | } |
| 822 | |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 823 | wifi_error WifiLegacyHal::startRttRangeRequest( |
| 824 | wifi_request_id id, |
| 825 | const std::vector<wifi_rtt_config>& rtt_configs, |
| 826 | const on_rtt_results_callback& on_results_user_callback) { |
| 827 | if (on_rtt_results_internal_callback) { |
| 828 | return WIFI_ERROR_NOT_AVAILABLE; |
| 829 | } |
| 830 | |
| 831 | on_rtt_results_internal_callback = [on_results_user_callback]( |
| 832 | wifi_request_id id, |
| 833 | unsigned num_results, |
| 834 | wifi_rtt_result* rtt_results[]) { |
| 835 | if (num_results > 0 && !rtt_results) { |
| 836 | LOG(ERROR) << "Unexpected nullptr in RTT results"; |
| 837 | return; |
| 838 | } |
| 839 | std::vector<const wifi_rtt_result*> rtt_results_vec; |
| 840 | std::copy_if( |
| 841 | rtt_results, |
| 842 | rtt_results + num_results, |
| 843 | back_inserter(rtt_results_vec), |
| 844 | [](wifi_rtt_result* rtt_result) { return rtt_result != nullptr; }); |
| 845 | on_results_user_callback(id, rtt_results_vec); |
| 846 | }; |
| 847 | |
| 848 | std::vector<wifi_rtt_config> rtt_configs_internal(rtt_configs); |
Roshan Pius | 7a41d9d | 2016-12-06 10:12:59 -0800 | [diff] [blame] | 849 | wifi_error status = |
| 850 | global_func_table_.wifi_rtt_range_request(id, |
| 851 | wlan_interface_handle_, |
| 852 | rtt_configs.size(), |
| 853 | rtt_configs_internal.data(), |
| 854 | {onRttResults}); |
| 855 | if (status != WIFI_SUCCESS) { |
| 856 | on_rtt_results_internal_callback = nullptr; |
| 857 | } |
| 858 | return status; |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | wifi_error WifiLegacyHal::cancelRttRangeRequest( |
| 862 | wifi_request_id id, const std::vector<std::array<uint8_t, 6>>& mac_addrs) { |
| 863 | if (!on_rtt_results_internal_callback) { |
| 864 | return WIFI_ERROR_NOT_AVAILABLE; |
| 865 | } |
| 866 | static_assert(sizeof(mac_addr) == sizeof(std::array<uint8_t, 6>), |
| 867 | "MAC address size mismatch"); |
| 868 | // TODO: How do we handle partial cancels (i.e only a subset of enabled mac |
| 869 | // addressed are cancelled). |
| 870 | std::vector<std::array<uint8_t, 6>> mac_addrs_internal(mac_addrs); |
| 871 | wifi_error status = global_func_table_.wifi_rtt_range_cancel( |
| 872 | id, |
| 873 | wlan_interface_handle_, |
| 874 | mac_addrs.size(), |
| 875 | reinterpret_cast<mac_addr*>(mac_addrs_internal.data())); |
| 876 | // If the request Id is wrong, don't stop the ongoing range request. Any |
| 877 | // other error should be treated as the end of rtt ranging. |
| 878 | if (status != WIFI_ERROR_INVALID_REQUEST_ID) { |
| 879 | on_rtt_results_internal_callback = nullptr; |
| 880 | } |
| 881 | return status; |
| 882 | } |
| 883 | |
| 884 | std::pair<wifi_error, wifi_rtt_capabilities> |
| 885 | WifiLegacyHal::getRttCapabilities() { |
| 886 | wifi_rtt_capabilities rtt_caps; |
| 887 | wifi_error status = global_func_table_.wifi_get_rtt_capabilities( |
| 888 | wlan_interface_handle_, &rtt_caps); |
| 889 | return {status, rtt_caps}; |
| 890 | } |
| 891 | |
| 892 | std::pair<wifi_error, wifi_rtt_responder> WifiLegacyHal::getRttResponderInfo() { |
| 893 | wifi_rtt_responder rtt_responder; |
| 894 | wifi_error status = global_func_table_.wifi_rtt_get_responder_info( |
| 895 | wlan_interface_handle_, &rtt_responder); |
| 896 | return {status, rtt_responder}; |
| 897 | } |
| 898 | |
| 899 | wifi_error WifiLegacyHal::enableRttResponder( |
| 900 | wifi_request_id id, |
| 901 | const wifi_channel_info& channel_hint, |
| 902 | uint32_t max_duration_secs, |
| 903 | const wifi_rtt_responder& info) { |
| 904 | wifi_rtt_responder info_internal(info); |
| 905 | return global_func_table_.wifi_enable_responder(id, |
| 906 | wlan_interface_handle_, |
| 907 | channel_hint, |
| 908 | max_duration_secs, |
| 909 | &info_internal); |
| 910 | } |
| 911 | |
| 912 | wifi_error WifiLegacyHal::disableRttResponder(wifi_request_id id) { |
| 913 | return global_func_table_.wifi_disable_responder(id, wlan_interface_handle_); |
| 914 | } |
| 915 | |
| 916 | wifi_error WifiLegacyHal::setRttLci(wifi_request_id id, |
| 917 | const wifi_lci_information& info) { |
| 918 | wifi_lci_information info_internal(info); |
| 919 | return global_func_table_.wifi_set_lci( |
| 920 | id, wlan_interface_handle_, &info_internal); |
| 921 | } |
| 922 | |
| 923 | wifi_error WifiLegacyHal::setRttLcr(wifi_request_id id, |
| 924 | const wifi_lcr_information& info) { |
| 925 | wifi_lcr_information info_internal(info); |
| 926 | return global_func_table_.wifi_set_lcr( |
| 927 | id, wlan_interface_handle_, &info_internal); |
| 928 | } |
| 929 | |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 930 | wifi_error WifiLegacyHal::nanRegisterCallbackHandlers( |
| 931 | const NanCallbackHandlers& user_callbacks) { |
| 932 | on_nan_notify_response_user_callback = user_callbacks.on_notify_response; |
| 933 | on_nan_event_publish_terminated_user_callback = |
| 934 | user_callbacks.on_event_publish_terminated; |
| 935 | on_nan_event_match_user_callback = user_callbacks.on_event_match; |
| 936 | on_nan_event_match_expired_user_callback = |
| 937 | user_callbacks.on_event_match_expired; |
| 938 | on_nan_event_subscribe_terminated_user_callback = |
| 939 | user_callbacks.on_event_subscribe_terminated; |
| 940 | on_nan_event_followup_user_callback = user_callbacks.on_event_followup; |
| 941 | on_nan_event_disc_eng_event_user_callback = |
| 942 | user_callbacks.on_event_disc_eng_event; |
| 943 | on_nan_event_disabled_user_callback = user_callbacks.on_event_disabled; |
| 944 | on_nan_event_tca_user_callback = user_callbacks.on_event_tca; |
| 945 | on_nan_event_beacon_sdf_payload_user_callback = |
| 946 | user_callbacks.on_event_beacon_sdf_payload; |
| 947 | on_nan_event_data_path_request_user_callback = |
| 948 | user_callbacks.on_event_data_path_request; |
| 949 | on_nan_event_data_path_confirm_user_callback = |
| 950 | user_callbacks.on_event_data_path_confirm; |
| 951 | on_nan_event_data_path_end_user_callback = |
| 952 | user_callbacks.on_event_data_path_end; |
| 953 | on_nan_event_transmit_follow_up_user_callback = |
| 954 | user_callbacks.on_event_transmit_follow_up; |
| 955 | |
| 956 | return global_func_table_.wifi_nan_register_handler( |
| 957 | wlan_interface_handle_, |
| 958 | {onNanNotifyResponse, |
| 959 | onNanEventPublishTerminated, |
| 960 | onNanEventMatch, |
| 961 | onNanEventMatchExpired, |
| 962 | onNanEventSubscribeTerminated, |
| 963 | onNanEventFollowup, |
| 964 | onNanEventDiscEngEvent, |
| 965 | onNanEventDisabled, |
| 966 | onNanEventTca, |
| 967 | onNanEventBeaconSdfPayload, |
| 968 | onNanEventDataPathRequest, |
| 969 | onNanEventDataPathConfirm, |
| 970 | onNanEventDataPathEnd, |
| 971 | onNanEventTransmitFollowUp}); |
| 972 | } |
| 973 | |
| 974 | wifi_error WifiLegacyHal::nanEnableRequest(transaction_id id, |
| 975 | const NanEnableRequest& msg) { |
| 976 | NanEnableRequest msg_internal(msg); |
| 977 | return global_func_table_.wifi_nan_enable_request( |
| 978 | id, wlan_interface_handle_, &msg_internal); |
| 979 | } |
| 980 | |
| 981 | wifi_error WifiLegacyHal::nanDisableRequest(transaction_id id) { |
| 982 | return global_func_table_.wifi_nan_disable_request(id, |
| 983 | wlan_interface_handle_); |
| 984 | } |
| 985 | |
| 986 | wifi_error WifiLegacyHal::nanPublishRequest(transaction_id id, |
| 987 | const NanPublishRequest& msg) { |
| 988 | NanPublishRequest msg_internal(msg); |
| 989 | return global_func_table_.wifi_nan_publish_request( |
| 990 | id, wlan_interface_handle_, &msg_internal); |
| 991 | } |
| 992 | |
| 993 | wifi_error WifiLegacyHal::nanPublishCancelRequest( |
| 994 | transaction_id id, const NanPublishCancelRequest& msg) { |
| 995 | NanPublishCancelRequest msg_internal(msg); |
| 996 | return global_func_table_.wifi_nan_publish_cancel_request( |
| 997 | id, wlan_interface_handle_, &msg_internal); |
| 998 | } |
| 999 | |
| 1000 | wifi_error WifiLegacyHal::nanSubscribeRequest(transaction_id id, |
| 1001 | const NanSubscribeRequest& msg) { |
| 1002 | NanSubscribeRequest msg_internal(msg); |
| 1003 | return global_func_table_.wifi_nan_subscribe_request( |
| 1004 | id, wlan_interface_handle_, &msg_internal); |
| 1005 | } |
| 1006 | |
| 1007 | wifi_error WifiLegacyHal::nanSubscribeCancelRequest( |
| 1008 | transaction_id id, const NanSubscribeCancelRequest& msg) { |
| 1009 | NanSubscribeCancelRequest msg_internal(msg); |
| 1010 | return global_func_table_.wifi_nan_subscribe_cancel_request( |
| 1011 | id, wlan_interface_handle_, &msg_internal); |
| 1012 | } |
| 1013 | |
| 1014 | wifi_error WifiLegacyHal::nanTransmitFollowupRequest( |
| 1015 | transaction_id id, const NanTransmitFollowupRequest& msg) { |
| 1016 | NanTransmitFollowupRequest msg_internal(msg); |
| 1017 | return global_func_table_.wifi_nan_transmit_followup_request( |
| 1018 | id, wlan_interface_handle_, &msg_internal); |
| 1019 | } |
| 1020 | |
| 1021 | wifi_error WifiLegacyHal::nanStatsRequest(transaction_id id, |
| 1022 | const NanStatsRequest& msg) { |
| 1023 | NanStatsRequest msg_internal(msg); |
| 1024 | return global_func_table_.wifi_nan_stats_request( |
| 1025 | id, wlan_interface_handle_, &msg_internal); |
| 1026 | } |
| 1027 | |
| 1028 | wifi_error WifiLegacyHal::nanConfigRequest(transaction_id id, |
| 1029 | const NanConfigRequest& msg) { |
| 1030 | NanConfigRequest msg_internal(msg); |
| 1031 | return global_func_table_.wifi_nan_config_request( |
| 1032 | id, wlan_interface_handle_, &msg_internal); |
| 1033 | } |
| 1034 | |
| 1035 | wifi_error WifiLegacyHal::nanTcaRequest(transaction_id id, |
| 1036 | const NanTCARequest& msg) { |
| 1037 | NanTCARequest msg_internal(msg); |
| 1038 | return global_func_table_.wifi_nan_tca_request( |
| 1039 | id, wlan_interface_handle_, &msg_internal); |
| 1040 | } |
| 1041 | |
| 1042 | wifi_error WifiLegacyHal::nanBeaconSdfPayloadRequest( |
| 1043 | transaction_id id, const NanBeaconSdfPayloadRequest& msg) { |
| 1044 | NanBeaconSdfPayloadRequest msg_internal(msg); |
| 1045 | return global_func_table_.wifi_nan_beacon_sdf_payload_request( |
| 1046 | id, wlan_interface_handle_, &msg_internal); |
| 1047 | } |
| 1048 | |
| 1049 | std::pair<wifi_error, NanVersion> WifiLegacyHal::nanGetVersion() { |
| 1050 | NanVersion version; |
| 1051 | wifi_error status = |
| 1052 | global_func_table_.wifi_nan_get_version(global_handle_, &version); |
| 1053 | return {status, version}; |
| 1054 | } |
| 1055 | |
| 1056 | wifi_error WifiLegacyHal::nanGetCapabilities(transaction_id id) { |
| 1057 | return global_func_table_.wifi_nan_get_capabilities(id, |
| 1058 | wlan_interface_handle_); |
| 1059 | } |
| 1060 | |
| 1061 | wifi_error WifiLegacyHal::nanDataInterfaceCreate( |
| 1062 | transaction_id id, const std::string& iface_name) { |
| 1063 | std::vector<char> iface_name_internal(iface_name.begin(), iface_name.end()); |
| 1064 | return global_func_table_.wifi_nan_data_interface_create( |
| 1065 | id, wlan_interface_handle_, iface_name_internal.data()); |
| 1066 | } |
| 1067 | |
| 1068 | wifi_error WifiLegacyHal::nanDataInterfaceDelete( |
| 1069 | transaction_id id, const std::string& iface_name) { |
| 1070 | std::vector<char> iface_name_internal(iface_name.begin(), iface_name.end()); |
| 1071 | return global_func_table_.wifi_nan_data_interface_delete( |
| 1072 | id, wlan_interface_handle_, iface_name_internal.data()); |
| 1073 | } |
| 1074 | |
| 1075 | wifi_error WifiLegacyHal::nanDataRequestInitiator( |
| 1076 | transaction_id id, const NanDataPathInitiatorRequest& msg) { |
| 1077 | NanDataPathInitiatorRequest msg_internal(msg); |
| 1078 | return global_func_table_.wifi_nan_data_request_initiator( |
| 1079 | id, wlan_interface_handle_, &msg_internal); |
| 1080 | } |
| 1081 | |
| 1082 | wifi_error WifiLegacyHal::nanDataIndicationResponse( |
| 1083 | transaction_id id, const NanDataPathIndicationResponse& msg) { |
| 1084 | NanDataPathIndicationResponse msg_internal(msg); |
| 1085 | return global_func_table_.wifi_nan_data_indication_response( |
| 1086 | id, wlan_interface_handle_, &msg_internal); |
| 1087 | } |
| 1088 | |
| 1089 | wifi_error WifiLegacyHal::nanDataEnd(transaction_id id, |
| 1090 | const NanDataPathEndRequest& msg) { |
| 1091 | NanDataPathEndRequest msg_internal(msg); |
| 1092 | return global_func_table_.wifi_nan_data_end( |
| 1093 | id, wlan_interface_handle_, &msg_internal); |
| 1094 | } |
| 1095 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1096 | wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() { |
Roshan Pius | ab5c471 | 2016-10-06 14:37:15 -0700 | [diff] [blame] | 1097 | const std::string& ifname_to_find = getStaIfaceName(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1098 | wifi_interface_handle* iface_handles = nullptr; |
| 1099 | int num_iface_handles = 0; |
| 1100 | wifi_error status = global_func_table_.wifi_get_ifaces( |
| 1101 | global_handle_, &num_iface_handles, &iface_handles); |
| 1102 | if (status != WIFI_SUCCESS) { |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 1103 | LOG(ERROR) << "Failed to enumerate interface handles"; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1104 | return status; |
| 1105 | } |
| 1106 | for (int i = 0; i < num_iface_handles; ++i) { |
| 1107 | std::array<char, IFNAMSIZ> current_ifname; |
| 1108 | current_ifname.fill(0); |
| 1109 | status = global_func_table_.wifi_get_iface_name( |
| 1110 | iface_handles[i], current_ifname.data(), current_ifname.size()); |
| 1111 | if (status != WIFI_SUCCESS) { |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 1112 | LOG(WARNING) << "Failed to get interface handle name"; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1113 | continue; |
| 1114 | } |
| 1115 | if (ifname_to_find == current_ifname.data()) { |
| 1116 | wlan_interface_handle_ = iface_handles[i]; |
| 1117 | return WIFI_SUCCESS; |
| 1118 | } |
| 1119 | } |
| 1120 | return WIFI_ERROR_UNKNOWN; |
| 1121 | } |
| 1122 | |
| 1123 | void WifiLegacyHal::runEventLoop() { |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 1124 | LOG(DEBUG) << "Starting legacy HAL event loop"; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1125 | global_func_table_.wifi_event_loop(global_handle_); |
| 1126 | if (!awaiting_event_loop_termination_) { |
| 1127 | LOG(FATAL) << "Legacy HAL event loop terminated, but HAL was not stopping"; |
| 1128 | } |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 1129 | LOG(DEBUG) << "Legacy HAL event loop terminated"; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1130 | awaiting_event_loop_termination_ = false; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1131 | } |
| 1132 | |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 1133 | std::pair<wifi_error, std::vector<wifi_cached_scan_results>> |
| 1134 | WifiLegacyHal::getGscanCachedResults() { |
| 1135 | std::vector<wifi_cached_scan_results> cached_scan_results; |
| 1136 | cached_scan_results.resize(kMaxCachedGscanResults); |
| 1137 | int32_t num_results = 0; |
| 1138 | wifi_error status = global_func_table_.wifi_get_cached_gscan_results( |
| 1139 | wlan_interface_handle_, |
| 1140 | true /* always flush */, |
| 1141 | cached_scan_results.size(), |
| 1142 | cached_scan_results.data(), |
| 1143 | &num_results); |
| 1144 | CHECK(num_results >= 0 && |
| 1145 | static_cast<uint32_t>(num_results) <= kMaxCachedGscanResults); |
| 1146 | cached_scan_results.resize(num_results); |
| 1147 | // Check for invalid IE lengths in these cached scan results and correct it. |
| 1148 | for (auto& cached_scan_result : cached_scan_results) { |
| 1149 | int num_scan_results = cached_scan_result.num_results; |
| 1150 | for (int i = 0; i < num_scan_results; i++) { |
| 1151 | auto& scan_result = cached_scan_result.results[i]; |
| 1152 | if (scan_result.ie_length > 0) { |
| 1153 | LOG(ERROR) << "Cached scan result has non-zero IE length " |
| 1154 | << scan_result.ie_length; |
| 1155 | scan_result.ie_length = 0; |
| 1156 | } |
| 1157 | } |
| 1158 | } |
| 1159 | return {status, std::move(cached_scan_results)}; |
| 1160 | } |
| 1161 | |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 1162 | void WifiLegacyHal::invalidate() { |
| 1163 | global_handle_ = nullptr; |
| 1164 | wlan_interface_handle_ = nullptr; |
| 1165 | on_stop_complete_internal_callback = nullptr; |
| 1166 | on_driver_memory_dump_internal_callback = nullptr; |
| 1167 | on_firmware_memory_dump_internal_callback = nullptr; |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 1168 | on_gscan_event_internal_callback = nullptr; |
| 1169 | on_gscan_full_result_internal_callback = nullptr; |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 1170 | on_link_layer_stats_result_internal_callback = nullptr; |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 1171 | on_rssi_threshold_breached_internal_callback = nullptr; |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 1172 | on_ring_buffer_data_internal_callback = nullptr; |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 1173 | on_error_alert_internal_callback = nullptr; |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 1174 | on_rtt_results_internal_callback = nullptr; |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 1175 | on_nan_notify_response_user_callback = nullptr; |
| 1176 | on_nan_event_publish_terminated_user_callback = nullptr; |
| 1177 | on_nan_event_match_user_callback = nullptr; |
| 1178 | on_nan_event_match_expired_user_callback = nullptr; |
| 1179 | on_nan_event_subscribe_terminated_user_callback = nullptr; |
| 1180 | on_nan_event_followup_user_callback = nullptr; |
| 1181 | on_nan_event_disc_eng_event_user_callback = nullptr; |
| 1182 | on_nan_event_disabled_user_callback = nullptr; |
| 1183 | on_nan_event_tca_user_callback = nullptr; |
| 1184 | on_nan_event_beacon_sdf_payload_user_callback = nullptr; |
| 1185 | on_nan_event_data_path_request_user_callback = nullptr; |
| 1186 | on_nan_event_data_path_confirm_user_callback = nullptr; |
| 1187 | on_nan_event_data_path_end_user_callback = nullptr; |
| 1188 | on_nan_event_transmit_follow_up_user_callback = nullptr; |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 1189 | } |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 1190 | |
| 1191 | } // namespace legacy_hal |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 1192 | } // namespace implementation |
| 1193 | } // namespace V1_0 |
| 1194 | } // namespace wifi |
| 1195 | } // namespace hardware |
| 1196 | } // namespace android |