Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -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 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 17 | #include <android-base/logging.h> |
| 18 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 19 | #include "hidl_return_util.h" |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 20 | #include "hidl_struct_util.h" |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 21 | #include "wifi_nan_iface.h" |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 22 | #include "wifi_status_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace wifi { |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 27 | namespace V1_5 { |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 28 | namespace implementation { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 29 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 30 | |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 31 | WifiNanIface::WifiNanIface( |
Roshan Pius | 5ba0a90 | 2020-04-14 11:55:42 -0700 | [diff] [blame] | 32 | const std::string& ifname, bool is_dedicated_iface, |
Roshan Pius | 356d5a6 | 2019-05-17 15:07:34 -0700 | [diff] [blame] | 33 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, |
| 34 | const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util) |
| 35 | : ifname_(ifname), |
Roshan Pius | 5ba0a90 | 2020-04-14 11:55:42 -0700 | [diff] [blame] | 36 | is_dedicated_iface_(is_dedicated_iface), |
Roshan Pius | 356d5a6 | 2019-05-17 15:07:34 -0700 | [diff] [blame] | 37 | legacy_hal_(legacy_hal), |
| 38 | iface_util_(iface_util), |
| 39 | is_valid_(true) { |
Roshan Pius | 5ba0a90 | 2020-04-14 11:55:42 -0700 | [diff] [blame] | 40 | if (is_dedicated_iface_) { |
| 41 | // If using a dedicated iface, set the iface up first. |
| 42 | if (!iface_util_.lock()->setUpState(ifname_, true)) { |
| 43 | // Fatal failure, invalidate the iface object. |
| 44 | invalidate(); |
| 45 | return; |
| 46 | } |
| 47 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 48 | // Register all the callbacks here. these should be valid for the lifetime |
| 49 | // of the object. Whenever the mode changes legacy HAL will remove |
| 50 | // all of these callbacks. |
| 51 | legacy_hal::NanCallbackHandlers callback_handlers; |
| 52 | android::wp<WifiNanIface> weak_ptr_this(this); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 53 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 54 | // Callback for response. |
| 55 | callback_handlers |
| 56 | .on_notify_response = [weak_ptr_this]( |
| 57 | legacy_hal::transaction_id id, |
| 58 | const legacy_hal::NanResponseMsg& msg) { |
| 59 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 60 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 61 | LOG(ERROR) << "Callback invoked on an invalid object"; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 62 | return; |
| 63 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 64 | WifiNanStatus wifiNanStatus; |
| 65 | if (!hidl_struct_util::convertLegacyNanResponseHeaderToHidl( |
| 66 | msg, &wifiNanStatus)) { |
| 67 | LOG(ERROR) << "Failed to convert nan response header"; |
| 68 | return; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 69 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 70 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 71 | switch (msg.response_type) { |
| 72 | case legacy_hal::NAN_RESPONSE_ENABLED: { |
| 73 | for (const auto& callback : |
| 74 | shared_ptr_this->getEventCallbacks()) { |
| 75 | if (!callback->notifyEnableResponse(id, wifiNanStatus) |
| 76 | .isOk()) { |
| 77 | LOG(ERROR) << "Failed to invoke the callback"; |
| 78 | } |
| 79 | } |
| 80 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 81 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 82 | case legacy_hal::NAN_RESPONSE_DISABLED: { |
| 83 | for (const auto& callback : |
| 84 | shared_ptr_this->getEventCallbacks()) { |
| 85 | if (!callback->notifyDisableResponse(id, wifiNanStatus) |
| 86 | .isOk()) { |
| 87 | LOG(ERROR) << "Failed to invoke the callback"; |
| 88 | } |
| 89 | } |
| 90 | break; |
| 91 | } |
| 92 | case legacy_hal::NAN_RESPONSE_PUBLISH: { |
| 93 | for (const auto& callback : |
| 94 | shared_ptr_this->getEventCallbacks()) { |
| 95 | if (!callback |
| 96 | ->notifyStartPublishResponse( |
| 97 | id, wifiNanStatus, |
| 98 | msg.body.publish_response.publish_id) |
| 99 | .isOk()) { |
| 100 | LOG(ERROR) << "Failed to invoke the callback"; |
| 101 | } |
| 102 | } |
| 103 | break; |
| 104 | } |
| 105 | case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: { |
| 106 | for (const auto& callback : |
| 107 | shared_ptr_this->getEventCallbacks()) { |
| 108 | if (!callback->notifyStopPublishResponse(id, wifiNanStatus) |
| 109 | .isOk()) { |
| 110 | LOG(ERROR) << "Failed to invoke the callback"; |
| 111 | } |
| 112 | } |
| 113 | break; |
| 114 | } |
| 115 | case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: { |
| 116 | for (const auto& callback : |
| 117 | shared_ptr_this->getEventCallbacks()) { |
| 118 | if (!callback |
| 119 | ->notifyTransmitFollowupResponse(id, wifiNanStatus) |
| 120 | .isOk()) { |
| 121 | LOG(ERROR) << "Failed to invoke the callback"; |
| 122 | } |
| 123 | } |
| 124 | break; |
| 125 | } |
| 126 | case legacy_hal::NAN_RESPONSE_SUBSCRIBE: { |
| 127 | for (const auto& callback : |
| 128 | shared_ptr_this->getEventCallbacks()) { |
| 129 | if (!callback |
| 130 | ->notifyStartSubscribeResponse( |
| 131 | id, wifiNanStatus, |
| 132 | msg.body.subscribe_response.subscribe_id) |
| 133 | .isOk()) { |
| 134 | LOG(ERROR) << "Failed to invoke the callback"; |
| 135 | } |
| 136 | } |
| 137 | break; |
| 138 | } |
| 139 | case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: { |
| 140 | for (const auto& callback : |
| 141 | shared_ptr_this->getEventCallbacks()) { |
| 142 | if (!callback |
| 143 | ->notifyStopSubscribeResponse(id, wifiNanStatus) |
| 144 | .isOk()) { |
| 145 | LOG(ERROR) << "Failed to invoke the callback"; |
| 146 | } |
| 147 | } |
| 148 | break; |
| 149 | } |
| 150 | case legacy_hal::NAN_RESPONSE_CONFIG: { |
| 151 | for (const auto& callback : |
| 152 | shared_ptr_this->getEventCallbacks()) { |
| 153 | if (!callback->notifyConfigResponse(id, wifiNanStatus) |
| 154 | .isOk()) { |
| 155 | LOG(ERROR) << "Failed to invoke the callback"; |
| 156 | } |
| 157 | } |
| 158 | break; |
| 159 | } |
| 160 | case legacy_hal::NAN_GET_CAPABILITIES: { |
| 161 | NanCapabilities hidl_struct; |
| 162 | if (!hidl_struct_util:: |
| 163 | convertLegacyNanCapabilitiesResponseToHidl( |
| 164 | msg.body.nan_capabilities, &hidl_struct)) { |
| 165 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 166 | return; |
| 167 | } |
| 168 | for (const auto& callback : |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 169 | shared_ptr_this->getEventCallbacks_1_5()) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 170 | if (!callback |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 171 | ->notifyCapabilitiesResponse_1_5(id, wifiNanStatus, |
| 172 | hidl_struct) |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 173 | .isOk()) { |
| 174 | LOG(ERROR) << "Failed to invoke the callback"; |
| 175 | } |
| 176 | } |
| 177 | break; |
| 178 | } |
| 179 | case legacy_hal::NAN_DP_INTERFACE_CREATE: { |
| 180 | for (const auto& callback : |
| 181 | shared_ptr_this->getEventCallbacks()) { |
| 182 | if (!callback |
| 183 | ->notifyCreateDataInterfaceResponse(id, |
| 184 | wifiNanStatus) |
| 185 | .isOk()) { |
| 186 | LOG(ERROR) << "Failed to invoke the callback"; |
| 187 | } |
| 188 | } |
| 189 | break; |
| 190 | } |
| 191 | case legacy_hal::NAN_DP_INTERFACE_DELETE: { |
| 192 | for (const auto& callback : |
| 193 | shared_ptr_this->getEventCallbacks()) { |
| 194 | if (!callback |
| 195 | ->notifyDeleteDataInterfaceResponse(id, |
| 196 | wifiNanStatus) |
| 197 | .isOk()) { |
| 198 | LOG(ERROR) << "Failed to invoke the callback"; |
| 199 | } |
| 200 | } |
| 201 | break; |
| 202 | } |
| 203 | case legacy_hal::NAN_DP_INITIATOR_RESPONSE: { |
| 204 | for (const auto& callback : |
| 205 | shared_ptr_this->getEventCallbacks()) { |
| 206 | if (!callback |
| 207 | ->notifyInitiateDataPathResponse( |
| 208 | id, wifiNanStatus, |
| 209 | msg.body.data_request_response.ndp_instance_id) |
| 210 | .isOk()) { |
| 211 | LOG(ERROR) << "Failed to invoke the callback"; |
| 212 | } |
| 213 | } |
| 214 | break; |
| 215 | } |
| 216 | case legacy_hal::NAN_DP_RESPONDER_RESPONSE: { |
| 217 | for (const auto& callback : |
| 218 | shared_ptr_this->getEventCallbacks()) { |
| 219 | if (!callback |
| 220 | ->notifyRespondToDataPathIndicationResponse( |
| 221 | id, wifiNanStatus) |
| 222 | .isOk()) { |
| 223 | LOG(ERROR) << "Failed to invoke the callback"; |
| 224 | } |
| 225 | } |
| 226 | break; |
| 227 | } |
| 228 | case legacy_hal::NAN_DP_END: { |
| 229 | for (const auto& callback : |
| 230 | shared_ptr_this->getEventCallbacks()) { |
| 231 | if (!callback |
| 232 | ->notifyTerminateDataPathResponse(id, |
| 233 | wifiNanStatus) |
| 234 | .isOk()) { |
| 235 | LOG(ERROR) << "Failed to invoke the callback"; |
| 236 | } |
| 237 | } |
| 238 | break; |
| 239 | } |
| 240 | case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD: |
| 241 | /* fall through */ |
| 242 | case legacy_hal::NAN_RESPONSE_TCA: |
| 243 | /* fall through */ |
| 244 | case legacy_hal::NAN_RESPONSE_STATS: |
| 245 | /* fall through */ |
| 246 | case legacy_hal::NAN_RESPONSE_ERROR: |
| 247 | /* fall through */ |
| 248 | default: |
| 249 | LOG(ERROR) << "Unknown or unhandled response type: " |
| 250 | << msg.response_type; |
| 251 | return; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 252 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 253 | }; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 254 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 255 | callback_handlers.on_event_disc_eng_event = |
| 256 | [weak_ptr_this](const legacy_hal::NanDiscEngEventInd& msg) { |
| 257 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 258 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 259 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 260 | return; |
| 261 | } |
| 262 | NanClusterEventInd hidl_struct; |
| 263 | // event types defined identically - hence can be cast |
| 264 | hidl_struct.eventType = (NanClusterEventType)msg.event_type; |
| 265 | hidl_struct.addr = msg.data.mac_addr.addr; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 266 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 267 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 268 | if (!callback->eventClusterEvent(hidl_struct).isOk()) { |
| 269 | LOG(ERROR) << "Failed to invoke the callback"; |
| 270 | } |
| 271 | } |
| 272 | }; |
Etan Cohen | c190f93 | 2017-02-17 13:06:55 -0800 | [diff] [blame] | 273 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 274 | callback_handlers.on_event_disabled = |
| 275 | [weak_ptr_this](const legacy_hal::NanDisabledInd& msg) { |
| 276 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 277 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 278 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 279 | return; |
| 280 | } |
| 281 | WifiNanStatus status; |
| 282 | hidl_struct_util::convertToWifiNanStatus( |
| 283 | msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status); |
Etan Cohen | c190f93 | 2017-02-17 13:06:55 -0800 | [diff] [blame] | 284 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 285 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 286 | if (!callback->eventDisabled(status).isOk()) { |
| 287 | LOG(ERROR) << "Failed to invoke the callback"; |
| 288 | } |
| 289 | } |
| 290 | }; |
| 291 | |
| 292 | callback_handlers.on_event_publish_terminated = |
| 293 | [weak_ptr_this](const legacy_hal::NanPublishTerminatedInd& msg) { |
| 294 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 295 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 296 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 297 | return; |
| 298 | } |
| 299 | WifiNanStatus status; |
| 300 | hidl_struct_util::convertToWifiNanStatus( |
| 301 | msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status); |
| 302 | |
| 303 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 304 | if (!callback->eventPublishTerminated(msg.publish_id, status) |
| 305 | .isOk()) { |
| 306 | LOG(ERROR) << "Failed to invoke the callback"; |
| 307 | } |
| 308 | } |
| 309 | }; |
| 310 | |
| 311 | callback_handlers.on_event_subscribe_terminated = |
| 312 | [weak_ptr_this](const legacy_hal::NanSubscribeTerminatedInd& msg) { |
| 313 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 314 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 315 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 316 | return; |
| 317 | } |
| 318 | WifiNanStatus status; |
| 319 | hidl_struct_util::convertToWifiNanStatus( |
| 320 | msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status); |
| 321 | |
| 322 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 323 | if (!callback |
| 324 | ->eventSubscribeTerminated(msg.subscribe_id, status) |
| 325 | .isOk()) { |
| 326 | LOG(ERROR) << "Failed to invoke the callback"; |
| 327 | } |
| 328 | } |
| 329 | }; |
| 330 | |
| 331 | callback_handlers.on_event_match = |
| 332 | [weak_ptr_this](const legacy_hal::NanMatchInd& msg) { |
| 333 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 334 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 335 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 336 | return; |
| 337 | } |
| 338 | NanMatchInd hidl_struct; |
| 339 | if (!hidl_struct_util::convertLegacyNanMatchIndToHidl( |
| 340 | msg, &hidl_struct)) { |
| 341 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 346 | if (!callback->eventMatch(hidl_struct).isOk()) { |
| 347 | LOG(ERROR) << "Failed to invoke the callback"; |
| 348 | } |
| 349 | } |
| 350 | }; |
| 351 | |
| 352 | callback_handlers.on_event_match_expired = |
| 353 | [weak_ptr_this](const legacy_hal::NanMatchExpiredInd& msg) { |
| 354 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 355 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 356 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 357 | return; |
| 358 | } |
| 359 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 360 | if (!callback |
| 361 | ->eventMatchExpired(msg.publish_subscribe_id, |
| 362 | msg.requestor_instance_id) |
| 363 | .isOk()) { |
| 364 | LOG(ERROR) << "Failed to invoke the callback"; |
| 365 | } |
| 366 | } |
| 367 | }; |
| 368 | |
| 369 | callback_handlers.on_event_followup = |
| 370 | [weak_ptr_this](const legacy_hal::NanFollowupInd& msg) { |
| 371 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 372 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 373 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 374 | return; |
| 375 | } |
| 376 | NanFollowupReceivedInd hidl_struct; |
| 377 | if (!hidl_struct_util::convertLegacyNanFollowupIndToHidl( |
| 378 | msg, &hidl_struct)) { |
| 379 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 380 | return; |
| 381 | } |
| 382 | |
| 383 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 384 | if (!callback->eventFollowupReceived(hidl_struct).isOk()) { |
| 385 | LOG(ERROR) << "Failed to invoke the callback"; |
| 386 | } |
| 387 | } |
| 388 | }; |
| 389 | |
| 390 | callback_handlers.on_event_transmit_follow_up = |
| 391 | [weak_ptr_this](const legacy_hal::NanTransmitFollowupInd& msg) { |
| 392 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 393 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 394 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 395 | return; |
| 396 | } |
| 397 | WifiNanStatus status; |
| 398 | hidl_struct_util::convertToWifiNanStatus( |
| 399 | msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status); |
| 400 | |
| 401 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 402 | if (!callback->eventTransmitFollowup(msg.id, status).isOk()) { |
| 403 | LOG(ERROR) << "Failed to invoke the callback"; |
| 404 | } |
| 405 | } |
| 406 | }; |
| 407 | |
| 408 | callback_handlers.on_event_data_path_request = |
| 409 | [weak_ptr_this](const legacy_hal::NanDataPathRequestInd& msg) { |
| 410 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 411 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 412 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 413 | return; |
| 414 | } |
| 415 | NanDataPathRequestInd hidl_struct; |
| 416 | if (!hidl_struct_util::convertLegacyNanDataPathRequestIndToHidl( |
| 417 | msg, &hidl_struct)) { |
| 418 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 423 | if (!callback->eventDataPathRequest(hidl_struct).isOk()) { |
| 424 | LOG(ERROR) << "Failed to invoke the callback"; |
| 425 | } |
| 426 | } |
| 427 | }; |
| 428 | |
| 429 | callback_handlers.on_event_data_path_confirm = |
| 430 | [weak_ptr_this](const legacy_hal::NanDataPathConfirmInd& msg) { |
| 431 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 432 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 433 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 434 | return; |
| 435 | } |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 436 | V1_2::NanDataPathConfirmInd hidl_struct; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 437 | if (!hidl_struct_util::convertLegacyNanDataPathConfirmIndToHidl( |
| 438 | msg, &hidl_struct)) { |
| 439 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 440 | return; |
| 441 | } |
| 442 | |
Etan Cohen | 44a8bf9 | 2018-04-09 13:32:40 -0700 | [diff] [blame] | 443 | for (const auto& callback : |
| 444 | shared_ptr_this->getEventCallbacks_1_2()) { |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 445 | if (!callback->eventDataPathConfirm_1_2(hidl_struct).isOk()) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 446 | LOG(ERROR) << "Failed to invoke the callback"; |
| 447 | } |
| 448 | } |
| 449 | }; |
| 450 | |
| 451 | callback_handlers.on_event_data_path_end = |
| 452 | [weak_ptr_this](const legacy_hal::NanDataPathEndInd& msg) { |
| 453 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 454 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 455 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 456 | return; |
| 457 | } |
| 458 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 459 | for (int i = 0; i < msg.num_ndp_instances; ++i) { |
| 460 | if (!callback |
| 461 | ->eventDataPathTerminated(msg.ndp_instance_id[i]) |
| 462 | .isOk()) { |
| 463 | LOG(ERROR) << "Failed to invoke the callback"; |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | }; |
| 468 | |
| 469 | callback_handlers.on_event_beacon_sdf_payload = |
| 470 | [weak_ptr_this](const legacy_hal::NanBeaconSdfPayloadInd& /* msg */) { |
| 471 | LOG(ERROR) << "on_event_beacon_sdf_payload - should not be called"; |
| 472 | }; |
| 473 | |
| 474 | callback_handlers.on_event_range_request = |
| 475 | [weak_ptr_this](const legacy_hal::NanRangeRequestInd& /* msg */) { |
| 476 | LOG(ERROR) << "on_event_range_request - should not be called"; |
| 477 | }; |
| 478 | |
| 479 | callback_handlers.on_event_range_report = |
| 480 | [weak_ptr_this](const legacy_hal::NanRangeReportInd& /* msg */) { |
| 481 | LOG(ERROR) << "on_event_range_report - should not be called"; |
| 482 | }; |
| 483 | |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 484 | callback_handlers |
| 485 | .on_event_schedule_update = [weak_ptr_this]( |
| 486 | const legacy_hal:: |
| 487 | NanDataPathScheduleUpdateInd& msg) { |
| 488 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 489 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 490 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 491 | return; |
| 492 | } |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 493 | V1_2::NanDataPathScheduleUpdateInd hidl_struct; |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 494 | if (!hidl_struct_util::convertLegacyNanDataPathScheduleUpdateIndToHidl( |
| 495 | msg, &hidl_struct)) { |
| 496 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 497 | return; |
| 498 | } |
| 499 | |
Etan Cohen | 44a8bf9 | 2018-04-09 13:32:40 -0700 | [diff] [blame] | 500 | for (const auto& callback : shared_ptr_this->getEventCallbacks_1_2()) { |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 501 | if (!callback->eventDataPathScheduleUpdate(hidl_struct).isOk()) { |
| 502 | LOG(ERROR) << "Failed to invoke the callback"; |
| 503 | } |
| 504 | } |
| 505 | }; |
Etan Cohen | 1bf15f1 | 2017-12-12 16:15:16 -0800 | [diff] [blame] | 506 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 507 | legacy_hal::wifi_error legacy_status = |
| 508 | legacy_hal_.lock()->nanRegisterCallbackHandlers(ifname_, |
| 509 | callback_handlers); |
| 510 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 511 | LOG(ERROR) << "Failed to register nan callbacks. Invalidating object"; |
| 512 | invalidate(); |
| 513 | } |
Roshan Pius | 356d5a6 | 2019-05-17 15:07:34 -0700 | [diff] [blame] | 514 | |
| 515 | // Register for iface state toggle events. |
| 516 | iface_util::IfaceEventHandlers event_handlers = {}; |
| 517 | event_handlers.on_state_toggle_off_on = |
| 518 | [weak_ptr_this](const std::string& /* iface_name */) { |
| 519 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 520 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 521 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 522 | return; |
| 523 | } |
| 524 | // Tell framework that NAN has been disabled. |
| 525 | WifiNanStatus status = { |
| 526 | NanStatusType::UNSUPPORTED_CONCURRENCY_NAN_DISABLED, ""}; |
| 527 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 528 | if (!callback->eventDisabled(status).isOk()) { |
| 529 | LOG(ERROR) << "Failed to invoke the callback"; |
| 530 | } |
| 531 | } |
| 532 | }; |
| 533 | iface_util_.lock()->registerIfaceEventHandlers(ifname_, event_handlers); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 534 | } |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 535 | |
| 536 | void WifiNanIface::invalidate() { |
Nate Jiang | 674b27a | 2020-08-26 16:38:19 -0700 | [diff] [blame] | 537 | if (!isValid()) { |
| 538 | return; |
| 539 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 540 | // send commands to HAL to actually disable and destroy interfaces |
| 541 | legacy_hal_.lock()->nanDisableRequest(ifname_, 0xFFFF); |
| 542 | legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFE, "aware_data0"); |
| 543 | legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFD, "aware_data1"); |
Roshan Pius | 356d5a6 | 2019-05-17 15:07:34 -0700 | [diff] [blame] | 544 | iface_util_.lock()->unregisterIfaceEventHandlers(ifname_); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 545 | legacy_hal_.reset(); |
| 546 | event_cb_handler_.invalidate(); |
Etan Cohen | 44a8bf9 | 2018-04-09 13:32:40 -0700 | [diff] [blame] | 547 | event_cb_handler_1_2_.invalidate(); |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 548 | event_cb_handler_1_5_.invalidate(); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 549 | is_valid_ = false; |
Roshan Pius | 5ba0a90 | 2020-04-14 11:55:42 -0700 | [diff] [blame] | 550 | if (is_dedicated_iface_) { |
| 551 | // If using a dedicated iface, set the iface down. |
| 552 | iface_util_.lock()->setUpState(ifname_, false); |
| 553 | } |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 554 | } |
| 555 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 556 | bool WifiNanIface::isValid() { return is_valid_; } |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 557 | |
Roshan Pius | 675609b | 2017-10-31 14:24:58 -0700 | [diff] [blame] | 558 | std::string WifiNanIface::getName() { return ifname_; } |
| 559 | |
Etan Cohen | 44a8bf9 | 2018-04-09 13:32:40 -0700 | [diff] [blame] | 560 | std::set<sp<V1_0::IWifiNanIfaceEventCallback>> |
| 561 | WifiNanIface::getEventCallbacks() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 562 | return event_cb_handler_.getCallbacks(); |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 563 | } |
| 564 | |
Etan Cohen | 44a8bf9 | 2018-04-09 13:32:40 -0700 | [diff] [blame] | 565 | std::set<sp<V1_2::IWifiNanIfaceEventCallback>> |
| 566 | WifiNanIface::getEventCallbacks_1_2() { |
| 567 | return event_cb_handler_1_2_.getCallbacks(); |
| 568 | } |
| 569 | |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 570 | std::set<sp<IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks_1_5() { |
| 571 | return event_cb_handler_1_5_.getCallbacks(); |
| 572 | } |
| 573 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 574 | Return<void> WifiNanIface::getName(getName_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 575 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 576 | &WifiNanIface::getNameInternal, hidl_status_cb); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 577 | } |
| 578 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 579 | Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 580 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 581 | &WifiNanIface::getTypeInternal, hidl_status_cb); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 582 | } |
| 583 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 584 | Return<void> WifiNanIface::registerEventCallback( |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 585 | const sp<V1_0::IWifiNanIfaceEventCallback>& callback, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 586 | registerEventCallback_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 587 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 588 | &WifiNanIface::registerEventCallbackInternal, |
| 589 | hidl_status_cb, callback); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 590 | } |
| 591 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 592 | Return<void> WifiNanIface::getCapabilitiesRequest( |
| 593 | uint16_t cmd_id, getCapabilitiesRequest_cb hidl_status_cb) { |
| 594 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 595 | &WifiNanIface::getCapabilitiesRequestInternal, |
| 596 | hidl_status_cb, cmd_id); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | Return<void> WifiNanIface::enableRequest(uint16_t cmd_id, |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 600 | const V1_0::NanEnableRequest& msg, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 601 | enableRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 602 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 603 | &WifiNanIface::enableRequestInternal, hidl_status_cb, |
| 604 | cmd_id, msg); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 605 | } |
| 606 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 607 | Return<void> WifiNanIface::configRequest(uint16_t cmd_id, |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 608 | const V1_0::NanConfigRequest& msg, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 609 | configRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 610 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 611 | &WifiNanIface::configRequestInternal, hidl_status_cb, |
| 612 | cmd_id, msg); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 613 | } |
| 614 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 615 | Return<void> WifiNanIface::disableRequest(uint16_t cmd_id, |
| 616 | disableRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 617 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 618 | &WifiNanIface::disableRequestInternal, |
| 619 | hidl_status_cb, cmd_id); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 620 | } |
| 621 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 622 | Return<void> WifiNanIface::startPublishRequest( |
| 623 | uint16_t cmd_id, const NanPublishRequest& msg, |
| 624 | startPublishRequest_cb hidl_status_cb) { |
| 625 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 626 | &WifiNanIface::startPublishRequestInternal, |
| 627 | hidl_status_cb, cmd_id, msg); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | Return<void> WifiNanIface::stopPublishRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 631 | uint16_t cmd_id, uint8_t sessionId, stopPublishRequest_cb hidl_status_cb) { |
| 632 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 633 | &WifiNanIface::stopPublishRequestInternal, |
| 634 | hidl_status_cb, cmd_id, sessionId); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | Return<void> WifiNanIface::startSubscribeRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 638 | uint16_t cmd_id, const NanSubscribeRequest& msg, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 639 | startSubscribeRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 640 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 641 | &WifiNanIface::startSubscribeRequestInternal, |
| 642 | hidl_status_cb, cmd_id, msg); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | Return<void> WifiNanIface::stopSubscribeRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 646 | uint16_t cmd_id, uint8_t sessionId, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 647 | stopSubscribeRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 648 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 649 | &WifiNanIface::stopSubscribeRequestInternal, |
| 650 | hidl_status_cb, cmd_id, sessionId); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | Return<void> WifiNanIface::transmitFollowupRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 654 | uint16_t cmd_id, const NanTransmitFollowupRequest& msg, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 655 | transmitFollowupRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 656 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 657 | &WifiNanIface::transmitFollowupRequestInternal, |
| 658 | hidl_status_cb, cmd_id, msg); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | Return<void> WifiNanIface::createDataInterfaceRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 662 | uint16_t cmd_id, const hidl_string& iface_name, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 663 | createDataInterfaceRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 664 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 665 | &WifiNanIface::createDataInterfaceRequestInternal, |
| 666 | hidl_status_cb, cmd_id, iface_name); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | Return<void> WifiNanIface::deleteDataInterfaceRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 670 | uint16_t cmd_id, const hidl_string& iface_name, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 671 | deleteDataInterfaceRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 672 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 673 | &WifiNanIface::deleteDataInterfaceRequestInternal, |
| 674 | hidl_status_cb, cmd_id, iface_name); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | Return<void> WifiNanIface::initiateDataPathRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 678 | uint16_t cmd_id, const NanInitiateDataPathRequest& msg, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 679 | initiateDataPathRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 680 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 681 | &WifiNanIface::initiateDataPathRequestInternal, |
| 682 | hidl_status_cb, cmd_id, msg); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | Return<void> WifiNanIface::respondToDataPathIndicationRequest( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 686 | uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 687 | respondToDataPathIndicationRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 688 | return validateAndCall( |
| 689 | this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 690 | &WifiNanIface::respondToDataPathIndicationRequestInternal, |
| 691 | hidl_status_cb, cmd_id, msg); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 692 | } |
| 693 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 694 | Return<void> WifiNanIface::terminateDataPathRequest( |
| 695 | uint16_t cmd_id, uint32_t ndpInstanceId, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 696 | terminateDataPathRequest_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 697 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 698 | &WifiNanIface::terminateDataPathRequestInternal, |
| 699 | hidl_status_cb, cmd_id, ndpInstanceId); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 700 | } |
| 701 | |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 702 | Return<void> WifiNanIface::registerEventCallback_1_2( |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 703 | const sp<V1_2::IWifiNanIfaceEventCallback>& callback, |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 704 | registerEventCallback_1_2_cb hidl_status_cb) { |
| 705 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 706 | &WifiNanIface::registerEventCallback_1_2Internal, |
| 707 | hidl_status_cb, callback); |
| 708 | } |
| 709 | |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 710 | Return<void> WifiNanIface::enableRequest_1_2( |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 711 | uint16_t cmd_id, const V1_0::NanEnableRequest& msg1, |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 712 | const V1_2::NanConfigRequestSupplemental& msg2, |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 713 | enableRequest_1_2_cb hidl_status_cb) { |
| 714 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 715 | &WifiNanIface::enableRequest_1_2Internal, |
| 716 | hidl_status_cb, cmd_id, msg1, msg2); |
| 717 | } |
| 718 | |
| 719 | Return<void> WifiNanIface::configRequest_1_2( |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 720 | uint16_t cmd_id, const V1_0::NanConfigRequest& msg1, |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 721 | const V1_2::NanConfigRequestSupplemental& msg2, |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 722 | configRequest_1_2_cb hidl_status_cb) { |
| 723 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 724 | &WifiNanIface::configRequest_1_2Internal, |
| 725 | hidl_status_cb, cmd_id, msg1, msg2); |
| 726 | } |
| 727 | |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 728 | Return<void> WifiNanIface::enableRequest_1_4( |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 729 | uint16_t cmd_id, const V1_4::NanEnableRequest& msg1, |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 730 | const V1_2::NanConfigRequestSupplemental& msg2, |
| 731 | enableRequest_1_4_cb hidl_status_cb) { |
| 732 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 733 | &WifiNanIface::enableRequest_1_4Internal, |
| 734 | hidl_status_cb, cmd_id, msg1, msg2); |
| 735 | } |
| 736 | |
| 737 | Return<void> WifiNanIface::configRequest_1_4( |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 738 | uint16_t cmd_id, const V1_4::NanConfigRequest& msg1, |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 739 | const V1_2::NanConfigRequestSupplemental& msg2, |
| 740 | configRequest_1_4_cb hidl_status_cb) { |
| 741 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 742 | &WifiNanIface::configRequest_1_4Internal, |
| 743 | hidl_status_cb, cmd_id, msg1, msg2); |
| 744 | } |
| 745 | |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 746 | Return<void> WifiNanIface::registerEventCallback_1_5( |
| 747 | const sp<IWifiNanIfaceEventCallback>& callback, |
| 748 | registerEventCallback_1_5_cb hidl_status_cb) { |
| 749 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 750 | &WifiNanIface::registerEventCallback_1_5Internal, |
| 751 | hidl_status_cb, callback); |
| 752 | } |
| 753 | |
| 754 | Return<void> WifiNanIface::enableRequest_1_5( |
| 755 | uint16_t cmd_id, const V1_4::NanEnableRequest& msg1, |
| 756 | const NanConfigRequestSupplemental& msg2, |
| 757 | enableRequest_1_5_cb hidl_status_cb) { |
| 758 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 759 | &WifiNanIface::enableRequest_1_5Internal, |
| 760 | hidl_status_cb, cmd_id, msg1, msg2); |
| 761 | } |
| 762 | |
| 763 | Return<void> WifiNanIface::configRequest_1_5( |
| 764 | uint16_t cmd_id, const V1_4::NanConfigRequest& msg1, |
| 765 | const NanConfigRequestSupplemental& msg2, |
| 766 | configRequest_1_5_cb hidl_status_cb) { |
| 767 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 768 | &WifiNanIface::configRequest_1_5Internal, |
| 769 | hidl_status_cb, cmd_id, msg1, msg2); |
| 770 | } |
| 771 | |
| 772 | Return<void> WifiNanIface::getCapabilitiesRequest_1_5( |
| 773 | uint16_t cmd_id, getCapabilitiesRequest_1_5_cb hidl_status_cb) { |
| 774 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 775 | &WifiNanIface::getCapabilitiesRequest_1_5Internal, |
| 776 | hidl_status_cb, cmd_id); |
| 777 | } |
| 778 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 779 | std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 780 | return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | std::pair<WifiStatus, IfaceType> WifiNanIface::getTypeInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 784 | return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN}; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 785 | } |
| 786 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 787 | WifiStatus WifiNanIface::registerEventCallbackInternal( |
Etan Cohen | 44a8bf9 | 2018-04-09 13:32:40 -0700 | [diff] [blame] | 788 | const sp<V1_0::IWifiNanIfaceEventCallback>& callback) { |
| 789 | if (!event_cb_handler_.addCallback(callback)) { |
| 790 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 791 | } |
| 792 | return createWifiStatus(WifiStatusCode::SUCCESS); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 793 | } |
| 794 | |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 795 | WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t /* cmd_id */) { |
| 796 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 797 | } |
| 798 | |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 799 | WifiStatus WifiNanIface::enableRequestInternal( |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 800 | uint16_t /* cmd_id */, const V1_0::NanEnableRequest& /* msg */) { |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 801 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 802 | } |
| 803 | |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 804 | WifiStatus WifiNanIface::configRequestInternal( |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 805 | uint16_t /* cmd_id */, const V1_0::NanConfigRequest& /* msg */) { |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 806 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | WifiStatus WifiNanIface::disableRequestInternal(uint16_t cmd_id) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 810 | legacy_hal::wifi_error legacy_status = |
| 811 | legacy_hal_.lock()->nanDisableRequest(ifname_, cmd_id); |
| 812 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 813 | } |
| 814 | |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame] | 815 | WifiStatus WifiNanIface::startPublishRequestInternal( |
| 816 | uint16_t cmd_id, const NanPublishRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 817 | legacy_hal::NanPublishRequest legacy_msg; |
| 818 | if (!hidl_struct_util::convertHidlNanPublishRequestToLegacy(msg, |
| 819 | &legacy_msg)) { |
| 820 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 821 | } |
| 822 | legacy_hal::wifi_error legacy_status = |
| 823 | legacy_hal_.lock()->nanPublishRequest(ifname_, cmd_id, legacy_msg); |
| 824 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 825 | } |
| 826 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 827 | WifiStatus WifiNanIface::stopPublishRequestInternal(uint16_t cmd_id, |
| 828 | uint8_t sessionId) { |
| 829 | legacy_hal::NanPublishCancelRequest legacy_msg; |
| 830 | legacy_msg.publish_id = sessionId; |
| 831 | legacy_hal::wifi_error legacy_status = |
| 832 | legacy_hal_.lock()->nanPublishCancelRequest(ifname_, cmd_id, |
| 833 | legacy_msg); |
| 834 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 835 | } |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 836 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 837 | WifiStatus WifiNanIface::startSubscribeRequestInternal( |
| 838 | uint16_t cmd_id, const NanSubscribeRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 839 | legacy_hal::NanSubscribeRequest legacy_msg; |
| 840 | if (!hidl_struct_util::convertHidlNanSubscribeRequestToLegacy( |
| 841 | msg, &legacy_msg)) { |
| 842 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 843 | } |
| 844 | legacy_hal::wifi_error legacy_status = |
| 845 | legacy_hal_.lock()->nanSubscribeRequest(ifname_, cmd_id, legacy_msg); |
| 846 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 847 | } |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 848 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 849 | WifiStatus WifiNanIface::stopSubscribeRequestInternal(uint16_t cmd_id, |
| 850 | uint8_t sessionId) { |
| 851 | legacy_hal::NanSubscribeCancelRequest legacy_msg; |
| 852 | legacy_msg.subscribe_id = sessionId; |
| 853 | legacy_hal::wifi_error legacy_status = |
| 854 | legacy_hal_.lock()->nanSubscribeCancelRequest(ifname_, cmd_id, |
| 855 | legacy_msg); |
| 856 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 857 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 858 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 859 | WifiStatus WifiNanIface::transmitFollowupRequestInternal( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 860 | uint16_t cmd_id, const NanTransmitFollowupRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 861 | legacy_hal::NanTransmitFollowupRequest legacy_msg; |
| 862 | if (!hidl_struct_util::convertHidlNanTransmitFollowupRequestToLegacy( |
| 863 | msg, &legacy_msg)) { |
| 864 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 865 | } |
| 866 | legacy_hal::wifi_error legacy_status = |
| 867 | legacy_hal_.lock()->nanTransmitFollowupRequest(ifname_, cmd_id, |
| 868 | legacy_msg); |
| 869 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 870 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 871 | |
| 872 | WifiStatus WifiNanIface::createDataInterfaceRequestInternal( |
| 873 | uint16_t cmd_id, const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 874 | legacy_hal::wifi_error legacy_status = |
| 875 | legacy_hal_.lock()->nanDataInterfaceCreate(ifname_, cmd_id, iface_name); |
| 876 | return createWifiStatusFromLegacyError(legacy_status); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 877 | } |
| 878 | WifiStatus WifiNanIface::deleteDataInterfaceRequestInternal( |
| 879 | uint16_t cmd_id, const std::string& iface_name) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 880 | legacy_hal::wifi_error legacy_status = |
| 881 | legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, cmd_id, iface_name); |
| 882 | return createWifiStatusFromLegacyError(legacy_status); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 883 | } |
| 884 | WifiStatus WifiNanIface::initiateDataPathRequestInternal( |
| 885 | uint16_t cmd_id, const NanInitiateDataPathRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 886 | legacy_hal::NanDataPathInitiatorRequest legacy_msg; |
| 887 | if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequestToLegacy( |
| 888 | msg, &legacy_msg)) { |
| 889 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 890 | } |
| 891 | legacy_hal::wifi_error legacy_status = |
| 892 | legacy_hal_.lock()->nanDataRequestInitiator(ifname_, cmd_id, |
| 893 | legacy_msg); |
| 894 | return createWifiStatusFromLegacyError(legacy_status); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 895 | } |
| 896 | WifiStatus WifiNanIface::respondToDataPathIndicationRequestInternal( |
| 897 | uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 898 | legacy_hal::NanDataPathIndicationResponse legacy_msg; |
| 899 | if (!hidl_struct_util::convertHidlNanDataPathIndicationResponseToLegacy( |
| 900 | msg, &legacy_msg)) { |
| 901 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 902 | } |
| 903 | legacy_hal::wifi_error legacy_status = |
| 904 | legacy_hal_.lock()->nanDataIndicationResponse(ifname_, cmd_id, |
| 905 | legacy_msg); |
| 906 | return createWifiStatusFromLegacyError(legacy_status); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 907 | } |
| 908 | WifiStatus WifiNanIface::terminateDataPathRequestInternal( |
| 909 | uint16_t cmd_id, uint32_t ndpInstanceId) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 910 | legacy_hal::wifi_error legacy_status = |
| 911 | legacy_hal_.lock()->nanDataEnd(ifname_, cmd_id, ndpInstanceId); |
| 912 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 913 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 914 | |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 915 | WifiStatus WifiNanIface::registerEventCallback_1_2Internal( |
Etan Cohen | 44a8bf9 | 2018-04-09 13:32:40 -0700 | [diff] [blame] | 916 | const sp<V1_2::IWifiNanIfaceEventCallback>& callback) { |
| 917 | sp<V1_0::IWifiNanIfaceEventCallback> callback_1_0 = callback; |
| 918 | if (!event_cb_handler_.addCallback(callback_1_0)) { |
| 919 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 920 | } |
| 921 | if (!event_cb_handler_1_2_.addCallback(callback)) { |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 922 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 923 | } |
| 924 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 925 | } |
| 926 | |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 927 | WifiStatus WifiNanIface::enableRequest_1_2Internal( |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 928 | uint16_t /* cmd_id */, const V1_0::NanEnableRequest& /* msg1 */, |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 929 | const V1_2::NanConfigRequestSupplemental& /* msg2 */) { |
Ahmed ElArabawy | 83baffd | 2019-11-15 19:20:41 -0800 | [diff] [blame] | 930 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
| 931 | } |
| 932 | |
| 933 | WifiStatus WifiNanIface::configRequest_1_2Internal( |
| 934 | uint16_t /* cmd_id */, const V1_0::NanConfigRequest& /* msg1 */, |
| 935 | const V1_2::NanConfigRequestSupplemental& /* msg2 */) { |
| 936 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
| 937 | } |
| 938 | |
| 939 | WifiStatus WifiNanIface::enableRequest_1_4Internal( |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 940 | uint16_t /* cmd_id */, const V1_4::NanEnableRequest& /* msg1 */, |
| 941 | const V1_2::NanConfigRequestSupplemental& /* msg2 */) { |
| 942 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
| 943 | } |
| 944 | |
| 945 | WifiStatus WifiNanIface::configRequest_1_4Internal( |
| 946 | uint16_t /* cmd_id */, const V1_4::NanConfigRequest& /* msg1 */, |
| 947 | const V1_2::NanConfigRequestSupplemental& /* msg2 */) { |
| 948 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
| 949 | } |
| 950 | |
| 951 | WifiStatus WifiNanIface::registerEventCallback_1_5Internal( |
| 952 | const sp<IWifiNanIfaceEventCallback>& callback) { |
| 953 | sp<V1_0::IWifiNanIfaceEventCallback> callback_1_0 = callback; |
| 954 | if (!event_cb_handler_.addCallback(callback_1_0)) { |
| 955 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 956 | } |
| 957 | sp<V1_2::IWifiNanIfaceEventCallback> callback_1_2 = callback; |
| 958 | if (!event_cb_handler_1_2_.addCallback(callback_1_2)) { |
| 959 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 960 | } |
| 961 | if (!event_cb_handler_1_5_.addCallback(callback)) { |
| 962 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 963 | } |
| 964 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 965 | } |
| 966 | |
| 967 | WifiStatus WifiNanIface::getCapabilitiesRequest_1_5Internal(uint16_t cmd_id) { |
| 968 | legacy_hal::wifi_error legacy_status = |
| 969 | legacy_hal_.lock()->nanGetCapabilities(ifname_, cmd_id); |
| 970 | return createWifiStatusFromLegacyError(legacy_status); |
| 971 | } |
| 972 | |
| 973 | WifiStatus WifiNanIface::enableRequest_1_5Internal( |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 974 | uint16_t cmd_id, const V1_4::NanEnableRequest& msg1, |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 975 | const NanConfigRequestSupplemental& msg2) { |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 976 | legacy_hal::NanEnableRequest legacy_msg; |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 977 | if (!hidl_struct_util::convertHidlNanEnableRequest_1_5ToLegacy( |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 978 | msg1, msg2, &legacy_msg)) { |
| 979 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 980 | } |
| 981 | legacy_hal::wifi_error legacy_status = |
| 982 | legacy_hal_.lock()->nanEnableRequest(ifname_, cmd_id, legacy_msg); |
| 983 | return createWifiStatusFromLegacyError(legacy_status); |
| 984 | } |
| 985 | |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 986 | WifiStatus WifiNanIface::configRequest_1_5Internal( |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 987 | uint16_t cmd_id, const V1_4::NanConfigRequest& msg1, |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 988 | const NanConfigRequestSupplemental& msg2) { |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 989 | legacy_hal::NanConfigRequest legacy_msg; |
Nate Jiang | 3ec6781 | 2020-08-24 11:04:31 -0700 | [diff] [blame] | 990 | if (!hidl_struct_util::convertHidlNanConfigRequest_1_5ToLegacy( |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 991 | msg1, msg2, &legacy_msg)) { |
| 992 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 993 | } |
| 994 | legacy_hal::wifi_error legacy_status = |
| 995 | legacy_hal_.lock()->nanConfigRequest(ifname_, cmd_id, legacy_msg); |
| 996 | return createWifiStatusFromLegacyError(legacy_status); |
| 997 | } |
| 998 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 999 | } // namespace implementation |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 1000 | } // namespace V1_5 |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 1001 | } // namespace wifi |
| 1002 | } // namespace hardware |
| 1003 | } // namespace android |