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 { |
| 27 | namespace V1_0 { |
| 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( |
| 32 | const std::string& ifname, |
| 33 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal) |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 34 | : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) { |
| 35 | // Register all the callbacks here. these should be valid for the lifetime |
| 36 | // of the object. Whenever the mode changes legacy HAL will remove |
| 37 | // all of these callbacks. |
| 38 | legacy_hal::NanCallbackHandlers callback_handlers; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 39 | android::wp<WifiNanIface> weak_ptr_this(this); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 40 | |
| 41 | // Callback for response. |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 42 | callback_handlers.on_notify_response = [weak_ptr_this]( |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 43 | legacy_hal::transaction_id id, const legacy_hal::NanResponseMsg& msg) { |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 44 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 45 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 46 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 47 | return; |
| 48 | } |
| 49 | WifiNanStatus wifiNanStatus; |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 50 | if (!hidl_struct_util::convertLegacyNanResponseHeaderToHidl(msg, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 51 | &wifiNanStatus)) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 52 | LOG(ERROR) << "Failed to convert nan response header"; |
| 53 | return; |
| 54 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 55 | |
| 56 | switch (msg.response_type) { |
| 57 | case legacy_hal::NAN_RESPONSE_ENABLED: { |
| 58 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 59 | if (!callback->notifyEnableResponse(id, wifiNanStatus).isOk()) { |
| 60 | LOG(ERROR) << "Failed to invoke the callback"; |
| 61 | } |
| 62 | } |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 63 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 64 | case legacy_hal::NAN_RESPONSE_DISABLED: { |
| 65 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 66 | if (!callback->notifyDisableResponse(id, wifiNanStatus).isOk()) { |
| 67 | LOG(ERROR) << "Failed to invoke the callback"; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | case legacy_hal::NAN_RESPONSE_PUBLISH: { |
| 72 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 73 | if (!callback->notifyStartPublishResponse(id, wifiNanStatus, |
| 74 | msg.body.publish_response.publish_id).isOk()) { |
| 75 | LOG(ERROR) << "Failed to invoke the callback"; |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: { |
| 80 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 81 | if (!callback->notifyStopPublishResponse(id, wifiNanStatus).isOk()) { |
| 82 | LOG(ERROR) << "Failed to invoke the callback"; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: { |
| 87 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 88 | if (!callback->notifyTransmitFollowupResponse(id, wifiNanStatus).isOk()) { |
| 89 | LOG(ERROR) << "Failed to invoke the callback"; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | case legacy_hal::NAN_RESPONSE_SUBSCRIBE: { |
| 94 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 95 | if (!callback->notifyStartSubscribeResponse(id, wifiNanStatus, |
| 96 | msg.body.subscribe_response.subscribe_id).isOk()) { |
| 97 | LOG(ERROR) << "Failed to invoke the callback"; |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: { |
| 102 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 103 | if (!callback->notifyStopSubscribeResponse(id, wifiNanStatus).isOk()) { |
| 104 | LOG(ERROR) << "Failed to invoke the callback"; |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | case legacy_hal::NAN_RESPONSE_CONFIG: { |
| 109 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 110 | if (!callback->notifyConfigResponse(id, wifiNanStatus).isOk()) { |
| 111 | LOG(ERROR) << "Failed to invoke the callback"; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD: { |
| 116 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 117 | if (!callback->notifyBeaconSdfPayloadResponse(id, wifiNanStatus).isOk()) { |
| 118 | LOG(ERROR) << "Failed to invoke the callback"; |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | case legacy_hal::NAN_GET_CAPABILITIES: { |
| 123 | NanCapabilities hidl_struct; |
| 124 | if (!hidl_struct_util::convertLegacyNanCapabilitiesResponseToHidl( |
| 125 | msg.body.nan_capabilities, &hidl_struct)) { |
| 126 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 127 | return; |
| 128 | } |
| 129 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 130 | if (!callback->notifyCapabilitiesResponse(id, wifiNanStatus, |
| 131 | hidl_struct).isOk()) { |
| 132 | LOG(ERROR) << "Failed to invoke the callback"; |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | case legacy_hal::NAN_DP_INTERFACE_CREATE: { |
| 137 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 138 | if (!callback->notifyCreateDataInterfaceResponse(id, wifiNanStatus).isOk()) { |
| 139 | LOG(ERROR) << "Failed to invoke the callback"; |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | case legacy_hal::NAN_DP_INTERFACE_DELETE: { |
| 144 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 145 | if (!callback->notifyDeleteDataInterfaceResponse(id, wifiNanStatus).isOk()) { |
| 146 | LOG(ERROR) << "Failed to invoke the callback"; |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | case legacy_hal::NAN_DP_INITIATOR_RESPONSE: { |
| 151 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 152 | if (!callback->notifyInitiateDataPathResponse(id, wifiNanStatus).isOk()) { |
| 153 | LOG(ERROR) << "Failed to invoke the callback"; |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | case legacy_hal::NAN_DP_RESPONDER_RESPONSE: { |
| 158 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 159 | if (!callback->notifyRespondToDataPathIndicationResponse(id, wifiNanStatus, |
| 160 | msg.body.data_request_response.ndp_instance_id).isOk()) { |
| 161 | LOG(ERROR) << "Failed to invoke the callback"; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | case legacy_hal::NAN_DP_END: { |
| 166 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 167 | if (!callback->notifyTerminateDataPathResponse(id, wifiNanStatus).isOk()) { |
| 168 | LOG(ERROR) << "Failed to invoke the callback"; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | case legacy_hal::NAN_RESPONSE_TCA: |
| 173 | /* fall through */ |
| 174 | case legacy_hal::NAN_RESPONSE_STATS: |
| 175 | /* fall through */ |
| 176 | case legacy_hal::NAN_RESPONSE_ERROR: |
| 177 | /* fall through */ |
| 178 | default: |
| 179 | LOG(ERROR) << "Unknown or unhandled response type: " << msg.response_type; |
| 180 | return; |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 181 | } |
| 182 | }; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 183 | |
| 184 | callback_handlers.on_event_disc_eng_event = [weak_ptr_this]( |
| 185 | const legacy_hal::NanDiscEngEventInd& msg) { |
| 186 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 187 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 188 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 189 | return; |
| 190 | } |
| 191 | NanClusterEventInd hidl_struct; |
| 192 | // event types defined identically - hence can be cast |
| 193 | hidl_struct.eventType = (NanClusterEventType) msg.event_type; |
| 194 | hidl_struct.addr = msg.data.mac_addr.addr; |
| 195 | |
| 196 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 197 | if (!callback->eventClusterEvent(hidl_struct).isOk()) { |
| 198 | LOG(ERROR) << "Failed to invoke the callback"; |
| 199 | } |
| 200 | } |
| 201 | }; |
| 202 | |
| 203 | callback_handlers.on_event_disabled = [weak_ptr_this]( |
| 204 | const legacy_hal::NanDisabledInd& msg) { |
| 205 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 206 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 207 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 208 | return; |
| 209 | } |
| 210 | WifiNanStatus status; |
| 211 | status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason); |
| 212 | status.description = msg.nan_reason; |
| 213 | |
| 214 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 215 | if (!callback->eventDisabled(status).isOk()) { |
| 216 | LOG(ERROR) << "Failed to invoke the callback"; |
| 217 | } |
| 218 | } |
| 219 | }; |
| 220 | |
| 221 | callback_handlers.on_event_publish_terminated = [weak_ptr_this]( |
| 222 | const legacy_hal::NanPublishTerminatedInd& msg) { |
| 223 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 224 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 225 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 226 | return; |
| 227 | } |
| 228 | WifiNanStatus status; |
| 229 | status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason); |
| 230 | status.description = msg.nan_reason; |
| 231 | |
| 232 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 233 | if (!callback->eventPublishTerminated(msg.publish_id, status).isOk()) { |
| 234 | LOG(ERROR) << "Failed to invoke the callback"; |
| 235 | } |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | callback_handlers.on_event_subscribe_terminated = [weak_ptr_this]( |
| 240 | const legacy_hal::NanSubscribeTerminatedInd& msg) { |
| 241 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 242 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 243 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 244 | return; |
| 245 | } |
| 246 | WifiNanStatus status; |
| 247 | status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason); |
| 248 | status.description = msg.nan_reason; |
| 249 | |
| 250 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 251 | if (!callback->eventSubscribeTerminated(msg.subscribe_id, status).isOk()) { |
| 252 | LOG(ERROR) << "Failed to invoke the callback"; |
| 253 | } |
| 254 | } |
| 255 | }; |
| 256 | |
| 257 | callback_handlers.on_event_match = [weak_ptr_this]( |
| 258 | const legacy_hal::NanMatchInd& msg) { |
| 259 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 260 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 261 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 262 | return; |
| 263 | } |
| 264 | NanMatchInd hidl_struct; |
| 265 | if (!hidl_struct_util::convertLegacyNanMatchIndToHidl( |
| 266 | msg, &hidl_struct)) { |
| 267 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 272 | if (!callback->eventMatch(hidl_struct).isOk()) { |
| 273 | LOG(ERROR) << "Failed to invoke the callback"; |
| 274 | } |
| 275 | } |
| 276 | }; |
| 277 | |
| 278 | callback_handlers.on_event_match_expired = [weak_ptr_this]( |
| 279 | const legacy_hal::NanMatchExpiredInd& msg) { |
| 280 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 281 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 282 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 283 | return; |
| 284 | } |
| 285 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 286 | if (!callback->eventMatchExpired(msg.publish_subscribe_id, |
| 287 | msg.requestor_instance_id).isOk()) { |
| 288 | LOG(ERROR) << "Failed to invoke the callback"; |
| 289 | } |
| 290 | } |
| 291 | }; |
| 292 | |
| 293 | callback_handlers.on_event_followup = [weak_ptr_this]( |
| 294 | const legacy_hal::NanFollowupInd& msg) { |
| 295 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 296 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 297 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 298 | return; |
| 299 | } |
| 300 | NanFollowupReceivedInd hidl_struct; |
| 301 | if (!hidl_struct_util::convertLegacyNanFollowupIndToHidl( |
| 302 | msg, &hidl_struct)) { |
| 303 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 304 | return; |
| 305 | } |
| 306 | |
| 307 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 308 | if (!callback->eventFollowupReceived(hidl_struct).isOk()) { |
| 309 | LOG(ERROR) << "Failed to invoke the callback"; |
| 310 | } |
| 311 | } |
| 312 | }; |
| 313 | |
| 314 | callback_handlers.on_event_transmit_follow_up = [weak_ptr_this]( |
| 315 | const legacy_hal::NanTransmitFollowupInd& msg) { |
| 316 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 317 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 318 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 319 | return; |
| 320 | } |
| 321 | WifiNanStatus status; |
| 322 | status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason); |
| 323 | status.description = msg.nan_reason; |
| 324 | |
| 325 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 326 | if (!callback->eventTransmitFollowup(msg.id, status).isOk()) { |
| 327 | LOG(ERROR) << "Failed to invoke the callback"; |
| 328 | } |
| 329 | } |
| 330 | }; |
| 331 | |
| 332 | callback_handlers.on_event_data_path_request = [weak_ptr_this]( |
| 333 | const legacy_hal::NanDataPathRequestInd& msg) { |
| 334 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 335 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 336 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 337 | return; |
| 338 | } |
| 339 | NanDataPathRequestInd hidl_struct; |
| 340 | if (!hidl_struct_util::convertLegacyNanDataPathRequestIndToHidl( |
| 341 | msg, &hidl_struct)) { |
| 342 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 347 | if (!callback->eventDataPathRequest(hidl_struct).isOk()) { |
| 348 | LOG(ERROR) << "Failed to invoke the callback"; |
| 349 | } |
| 350 | } |
| 351 | }; |
| 352 | |
| 353 | callback_handlers.on_event_data_path_confirm = [weak_ptr_this]( |
| 354 | const legacy_hal::NanDataPathConfirmInd& msg) { |
| 355 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 356 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 357 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 358 | return; |
| 359 | } |
| 360 | NanDataPathConfirmInd hidl_struct; |
| 361 | if (!hidl_struct_util::convertLegacyNanDataPathConfirmIndToHidl( |
| 362 | msg, &hidl_struct)) { |
| 363 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 364 | return; |
| 365 | } |
| 366 | |
| 367 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 368 | if (!callback->eventDataPathConfirm(hidl_struct).isOk()) { |
| 369 | LOG(ERROR) << "Failed to invoke the callback"; |
| 370 | } |
| 371 | } |
| 372 | }; |
| 373 | |
| 374 | callback_handlers.on_event_data_path_end = [weak_ptr_this]( |
| 375 | const legacy_hal::NanDataPathEndInd& msg) { |
| 376 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 377 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 378 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 379 | return; |
| 380 | } |
| 381 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 382 | for (int i = 0; i < msg.num_ndp_instances; ++i) { |
| 383 | if (!callback->eventDataPathTerminated(msg.ndp_instance_id[i]).isOk()) { |
| 384 | LOG(ERROR) << "Failed to invoke the callback"; |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | }; |
| 389 | |
| 390 | callback_handlers.on_event_beacon_sdf_payload = [weak_ptr_this]( |
| 391 | const legacy_hal::NanBeaconSdfPayloadInd& 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 | NanBeaconSdfPayloadInd hidl_struct; |
| 398 | if (!hidl_struct_util::convertLegacyNanBeaconSdfPayloadIndToHidl( |
| 399 | msg, &hidl_struct)) { |
| 400 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 405 | if (!callback->eventBeaconSdfPayload(hidl_struct).isOk()) { |
| 406 | LOG(ERROR) << "Failed to invoke the callback"; |
| 407 | } |
| 408 | } |
| 409 | }; |
| 410 | |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 411 | legacy_hal::wifi_error legacy_status = |
| 412 | legacy_hal_.lock()->nanRegisterCallbackHandlers(callback_handlers); |
| 413 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 414 | LOG(ERROR) << "Failed to register nan callbacks. Invalidating object"; |
| 415 | invalidate(); |
| 416 | } |
| 417 | } |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 418 | |
| 419 | void WifiNanIface::invalidate() { |
| 420 | legacy_hal_.reset(); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 421 | event_callbacks_.clear(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 422 | is_valid_ = false; |
| 423 | } |
| 424 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 425 | bool WifiNanIface::isValid() { |
| 426 | return is_valid_; |
| 427 | } |
| 428 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 429 | Return<void> WifiNanIface::getName(getName_cb hidl_status_cb) { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 430 | return validateAndCall(this, |
| 431 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 432 | &WifiNanIface::getNameInternal, |
| 433 | hidl_status_cb); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 434 | } |
| 435 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 436 | Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) { |
| 437 | return validateAndCall(this, |
| 438 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 439 | &WifiNanIface::getTypeInternal, |
| 440 | hidl_status_cb); |
| 441 | } |
| 442 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 443 | Return<void> WifiNanIface::registerEventCallback( |
| 444 | const sp<IWifiNanIfaceEventCallback>& callback, |
| 445 | registerEventCallback_cb hidl_status_cb) { |
| 446 | return validateAndCall(this, |
| 447 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 448 | &WifiNanIface::registerEventCallbackInternal, |
| 449 | hidl_status_cb, |
| 450 | callback); |
| 451 | } |
| 452 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 453 | Return<void> WifiNanIface::getCapabilitiesRequest(uint16_t cmd_id, |
| 454 | getCapabilitiesRequest_cb hidl_status_cb) { |
| 455 | return validateAndCall(this, |
| 456 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 457 | &WifiNanIface::getCapabilitiesRequestInternal, |
| 458 | hidl_status_cb, |
| 459 | cmd_id); |
| 460 | } |
| 461 | |
| 462 | Return<void> WifiNanIface::enableRequest(uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 463 | const NanEnableRequest& msg, |
| 464 | enableRequest_cb hidl_status_cb) { |
| 465 | return validateAndCall(this, |
| 466 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 467 | &WifiNanIface::enableRequestInternal, |
| 468 | hidl_status_cb, |
| 469 | cmd_id, |
| 470 | msg); |
| 471 | } |
| 472 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 473 | Return<void> WifiNanIface::configRequest(uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 474 | const NanConfigRequest& msg, |
| 475 | configRequest_cb hidl_status_cb) { |
| 476 | return validateAndCall(this, |
| 477 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 478 | &WifiNanIface::configRequestInternal, |
| 479 | hidl_status_cb, |
| 480 | cmd_id, |
| 481 | msg); |
| 482 | } |
| 483 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 484 | Return<void> WifiNanIface::disableRequest(uint16_t cmd_id, |
| 485 | disableRequest_cb hidl_status_cb) { |
| 486 | return validateAndCall(this, |
| 487 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 488 | &WifiNanIface::disableRequestInternal, |
| 489 | hidl_status_cb, |
| 490 | cmd_id); |
| 491 | } |
| 492 | |
| 493 | Return<void> WifiNanIface::startPublishRequest(uint16_t cmd_id, |
| 494 | const NanPublishRequest& msg, |
| 495 | startPublishRequest_cb hidl_status_cb) { |
| 496 | return validateAndCall(this, |
| 497 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 498 | &WifiNanIface::startPublishRequestInternal, |
| 499 | hidl_status_cb, |
| 500 | cmd_id, |
| 501 | msg); |
| 502 | } |
| 503 | |
| 504 | Return<void> WifiNanIface::stopPublishRequest( |
| 505 | uint16_t cmd_id, |
| 506 | uint16_t sessionId, |
| 507 | stopPublishRequest_cb hidl_status_cb) { |
| 508 | return validateAndCall(this, |
| 509 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 510 | &WifiNanIface::stopPublishRequestInternal, |
| 511 | hidl_status_cb, |
| 512 | cmd_id, |
| 513 | sessionId); |
| 514 | } |
| 515 | |
| 516 | Return<void> WifiNanIface::startSubscribeRequest( |
| 517 | uint16_t cmd_id, |
| 518 | const NanSubscribeRequest& msg, |
| 519 | startSubscribeRequest_cb hidl_status_cb) { |
| 520 | return validateAndCall(this, |
| 521 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 522 | &WifiNanIface::startSubscribeRequestInternal, |
| 523 | hidl_status_cb, |
| 524 | cmd_id, |
| 525 | msg); |
| 526 | } |
| 527 | |
| 528 | Return<void> WifiNanIface::stopSubscribeRequest( |
| 529 | uint16_t cmd_id, |
| 530 | uint16_t sessionId, |
| 531 | stopSubscribeRequest_cb hidl_status_cb) { |
| 532 | return validateAndCall(this, |
| 533 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 534 | &WifiNanIface::stopSubscribeRequestInternal, |
| 535 | hidl_status_cb, |
| 536 | cmd_id, |
| 537 | sessionId); |
| 538 | } |
| 539 | |
| 540 | Return<void> WifiNanIface::transmitFollowupRequest( |
| 541 | uint16_t cmd_id, |
| 542 | const NanTransmitFollowupRequest& msg, |
| 543 | transmitFollowupRequest_cb hidl_status_cb) { |
| 544 | return validateAndCall(this, |
| 545 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 546 | &WifiNanIface::transmitFollowupRequestInternal, |
| 547 | hidl_status_cb, |
| 548 | cmd_id, |
| 549 | msg); |
| 550 | } |
| 551 | |
| 552 | Return<void> WifiNanIface::createDataInterfaceRequest( |
| 553 | uint16_t cmd_id, |
| 554 | const hidl_string& iface_name, |
| 555 | createDataInterfaceRequest_cb hidl_status_cb) { |
| 556 | return validateAndCall(this, |
| 557 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 558 | &WifiNanIface::createDataInterfaceRequestInternal, |
| 559 | hidl_status_cb, |
| 560 | cmd_id, |
| 561 | iface_name); |
| 562 | } |
| 563 | |
| 564 | Return<void> WifiNanIface::deleteDataInterfaceRequest( |
| 565 | uint16_t cmd_id, |
| 566 | const hidl_string& iface_name, |
| 567 | deleteDataInterfaceRequest_cb hidl_status_cb) { |
| 568 | return validateAndCall(this, |
| 569 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 570 | &WifiNanIface::deleteDataInterfaceRequestInternal, |
| 571 | hidl_status_cb, |
| 572 | cmd_id, |
| 573 | iface_name); |
| 574 | } |
| 575 | |
| 576 | Return<void> WifiNanIface::initiateDataPathRequest( |
| 577 | uint16_t cmd_id, |
| 578 | const NanInitiateDataPathRequest& msg, |
| 579 | initiateDataPathRequest_cb hidl_status_cb) { |
| 580 | return validateAndCall(this, |
| 581 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 582 | &WifiNanIface::initiateDataPathRequestInternal, |
| 583 | hidl_status_cb, |
| 584 | cmd_id, |
| 585 | msg); |
| 586 | } |
| 587 | |
| 588 | Return<void> WifiNanIface::respondToDataPathIndicationRequest( |
| 589 | uint16_t cmd_id, |
| 590 | const NanRespondToDataPathIndicationRequest& msg, |
| 591 | respondToDataPathIndicationRequest_cb hidl_status_cb) { |
| 592 | return validateAndCall(this, |
| 593 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 594 | &WifiNanIface::respondToDataPathIndicationRequestInternal, |
| 595 | hidl_status_cb, |
| 596 | cmd_id, |
| 597 | msg); |
| 598 | } |
| 599 | |
| 600 | Return<void> WifiNanIface::terminateDataPathRequest(uint16_t cmd_id, uint32_t ndpInstanceId, |
| 601 | terminateDataPathRequest_cb hidl_status_cb) { |
| 602 | return validateAndCall(this, |
| 603 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 604 | &WifiNanIface::terminateDataPathRequestInternal, |
| 605 | hidl_status_cb, |
| 606 | cmd_id, |
| 607 | ndpInstanceId); |
| 608 | } |
| 609 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 610 | Return<void> WifiNanIface::beaconSdfPayloadRequest( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 611 | uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 612 | const NanBeaconSdfPayloadRequest& msg, |
| 613 | beaconSdfPayloadRequest_cb hidl_status_cb) { |
| 614 | return validateAndCall(this, |
| 615 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 616 | &WifiNanIface::beaconSdfPayloadRequestInternal, |
| 617 | hidl_status_cb, |
| 618 | cmd_id, |
| 619 | msg); |
| 620 | } |
| 621 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 622 | std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() { |
| 623 | return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; |
| 624 | } |
| 625 | |
| 626 | std::pair<WifiStatus, IfaceType> WifiNanIface::getTypeInternal() { |
| 627 | return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN}; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 628 | } |
| 629 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 630 | WifiStatus WifiNanIface::registerEventCallbackInternal( |
| 631 | const sp<IWifiNanIfaceEventCallback>& callback) { |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 632 | // TODO(b/31632518): remove the callback when the client is destroyed and/or |
| 633 | // make sure that the same callback is only registered once (i.e. detect duplicates) |
| 634 | // OR: consider having a single listener - not clear why multiple listeners (managers) are |
| 635 | // necessary, nor how they would coordinate (at least command IDs). |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 636 | event_callbacks_.emplace_back(callback); |
| 637 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 638 | } |
| 639 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 640 | WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t cmd_id) { |
| 641 | legacy_hal::wifi_error legacy_status = |
| 642 | legacy_hal_.lock()->nanGetCapabilities(cmd_id); |
| 643 | return createWifiStatusFromLegacyError(legacy_status); |
| 644 | } |
| 645 | |
| 646 | WifiStatus WifiNanIface::enableRequestInternal(uint16_t cmd_id, |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 647 | const NanEnableRequest& msg) { |
| 648 | legacy_hal::NanEnableRequest legacy_msg; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 649 | if (!hidl_struct_util::convertHidlNanEnableRequestToLegacy(msg, &legacy_msg)) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 650 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 651 | } |
| 652 | legacy_hal::wifi_error legacy_status = |
| 653 | legacy_hal_.lock()->nanEnableRequest(cmd_id, legacy_msg); |
| 654 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 655 | } |
| 656 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 657 | WifiStatus WifiNanIface::configRequestInternal( |
| 658 | uint16_t cmd_id, const NanConfigRequest& msg) { |
| 659 | legacy_hal::NanConfigRequest legacy_msg; |
| 660 | if (!hidl_struct_util::convertHidlNanConfigRequestToLegacy(msg, |
| 661 | &legacy_msg)) { |
| 662 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 663 | } |
| 664 | legacy_hal::wifi_error legacy_status = |
| 665 | legacy_hal_.lock()->nanConfigRequest(cmd_id, legacy_msg); |
| 666 | return createWifiStatusFromLegacyError(legacy_status); |
| 667 | } |
| 668 | |
| 669 | WifiStatus WifiNanIface::disableRequestInternal(uint16_t cmd_id) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 670 | legacy_hal::wifi_error legacy_status = |
| 671 | legacy_hal_.lock()->nanDisableRequest(cmd_id); |
| 672 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 673 | } |
| 674 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 675 | WifiStatus WifiNanIface::startPublishRequestInternal(uint16_t cmd_id, |
| 676 | const NanPublishRequest& msg) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 677 | legacy_hal::NanPublishRequest legacy_msg; |
| 678 | if (!hidl_struct_util::convertHidlNanPublishRequestToLegacy(msg, |
| 679 | &legacy_msg)) { |
| 680 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 681 | } |
| 682 | legacy_hal::wifi_error legacy_status = |
| 683 | legacy_hal_.lock()->nanPublishRequest(cmd_id, legacy_msg); |
| 684 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 685 | } |
| 686 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 687 | WifiStatus WifiNanIface::stopPublishRequestInternal( |
| 688 | uint16_t cmd_id, uint16_t sessionId) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 689 | legacy_hal::NanPublishCancelRequest legacy_msg; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 690 | legacy_msg.publish_id = sessionId; |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 691 | legacy_hal::wifi_error legacy_status = |
| 692 | legacy_hal_.lock()->nanPublishCancelRequest(cmd_id, legacy_msg); |
| 693 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 694 | } |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 695 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 696 | WifiStatus WifiNanIface::startSubscribeRequestInternal( |
| 697 | uint16_t cmd_id, const NanSubscribeRequest& msg) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 698 | legacy_hal::NanSubscribeRequest legacy_msg; |
| 699 | if (!hidl_struct_util::convertHidlNanSubscribeRequestToLegacy(msg, |
| 700 | &legacy_msg)) { |
| 701 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 702 | } |
| 703 | legacy_hal::wifi_error legacy_status = |
| 704 | legacy_hal_.lock()->nanSubscribeRequest(cmd_id, legacy_msg); |
| 705 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 706 | } |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 707 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 708 | WifiStatus WifiNanIface::stopSubscribeRequestInternal( |
| 709 | uint16_t cmd_id, uint16_t sessionId) { |
| 710 | legacy_hal::NanSubscribeCancelRequest legacy_msg; |
| 711 | legacy_msg.subscribe_id = sessionId; |
| 712 | legacy_hal::wifi_error legacy_status = |
| 713 | legacy_hal_.lock()->nanSubscribeCancelRequest(cmd_id, legacy_msg); |
| 714 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 715 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 716 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 717 | WifiStatus WifiNanIface::transmitFollowupRequestInternal( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 718 | uint16_t cmd_id, const NanTransmitFollowupRequest& msg) { |
| 719 | legacy_hal::NanTransmitFollowupRequest legacy_msg; |
| 720 | if (!hidl_struct_util::convertHidlNanTransmitFollowupRequestToLegacy(msg, &legacy_msg)) { |
| 721 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 722 | } |
| 723 | legacy_hal::wifi_error legacy_status = |
| 724 | legacy_hal_.lock()->nanTransmitFollowupRequest(cmd_id, legacy_msg); |
| 725 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 726 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 727 | |
| 728 | WifiStatus WifiNanIface::createDataInterfaceRequestInternal( |
| 729 | uint16_t cmd_id, const std::string& iface_name) { |
| 730 | legacy_hal::wifi_error legacy_status = |
| 731 | legacy_hal_.lock()->nanDataInterfaceCreate(cmd_id, iface_name); |
| 732 | return createWifiStatusFromLegacyError(legacy_status); |
| 733 | } |
| 734 | WifiStatus WifiNanIface::deleteDataInterfaceRequestInternal( |
| 735 | uint16_t cmd_id, const std::string& iface_name) { |
| 736 | legacy_hal::wifi_error legacy_status = |
| 737 | legacy_hal_.lock()->nanDataInterfaceDelete(cmd_id, iface_name); |
| 738 | return createWifiStatusFromLegacyError(legacy_status); |
| 739 | } |
| 740 | WifiStatus WifiNanIface::initiateDataPathRequestInternal( |
| 741 | uint16_t cmd_id, const NanInitiateDataPathRequest& msg) { |
| 742 | legacy_hal::NanDataPathInitiatorRequest legacy_msg; |
| 743 | if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequestToLegacy(msg, &legacy_msg)) { |
| 744 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 745 | } |
| 746 | legacy_hal::wifi_error legacy_status = |
| 747 | legacy_hal_.lock()->nanDataRequestInitiator(cmd_id, legacy_msg); |
| 748 | return createWifiStatusFromLegacyError(legacy_status); |
| 749 | } |
| 750 | WifiStatus WifiNanIface::respondToDataPathIndicationRequestInternal( |
| 751 | uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg) { |
| 752 | legacy_hal::NanDataPathIndicationResponse legacy_msg; |
| 753 | if (!hidl_struct_util::convertHidlNanDataPathIndicationResponseToLegacy(msg, &legacy_msg)) { |
| 754 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 755 | } |
| 756 | legacy_hal::wifi_error legacy_status = |
| 757 | legacy_hal_.lock()->nanDataIndicationResponse(cmd_id, legacy_msg); |
| 758 | return createWifiStatusFromLegacyError(legacy_status); |
| 759 | } |
| 760 | WifiStatus WifiNanIface::terminateDataPathRequestInternal( |
| 761 | uint16_t cmd_id, uint32_t ndpInstanceId) { |
| 762 | legacy_hal::NanDataPathEndRequest* legacy_msg = (legacy_hal::NanDataPathEndRequest*)malloc( |
| 763 | sizeof(legacy_hal::NanDataPathEndRequest) + sizeof(uint32_t)); |
| 764 | legacy_msg->num_ndp_instances = 1; |
| 765 | legacy_msg->ndp_instance_id[0] = ndpInstanceId; |
| 766 | |
| 767 | legacy_hal::wifi_error legacy_status = |
| 768 | legacy_hal_.lock()->nanDataEnd(cmd_id, *legacy_msg); |
| 769 | free(legacy_msg); |
| 770 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 771 | } |
| 772 | WifiStatus WifiNanIface::beaconSdfPayloadRequestInternal( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 773 | uint16_t cmd_id, const NanBeaconSdfPayloadRequest& msg) { |
| 774 | legacy_hal::NanBeaconSdfPayloadRequest legacy_msg; |
| 775 | if (!hidl_struct_util::convertHidlNanBeaconSdfPayloadRequestToLegacy(msg, &legacy_msg)) { |
| 776 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 777 | } |
| 778 | legacy_hal::wifi_error legacy_status = |
| 779 | legacy_hal_.lock()->nanBeaconSdfPayloadRequest(cmd_id, legacy_msg); |
| 780 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 781 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 782 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 783 | } // namespace implementation |
| 784 | } // namespace V1_0 |
| 785 | } // namespace wifi |
| 786 | } // namespace hardware |
| 787 | } // namespace android |