blob: 8e3a191b7a782be0fbd659571024f55924698460 [file] [log] [blame]
Gabriel Birenf3262f92022-07-15 23:25:39 +00001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "wifi_nan_iface.h"
18
19#include <android-base/logging.h>
20
21#include "aidl_return_util.h"
22#include "aidl_struct_util.h"
23#include "wifi_status_util.h"
24
25namespace aidl {
26namespace android {
27namespace hardware {
28namespace wifi {
29using aidl_return_util::validateAndCall;
30
31WifiNanIface::WifiNanIface(const std::string& ifname, bool is_dedicated_iface,
32 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
33 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util)
34 : ifname_(ifname),
35 is_dedicated_iface_(is_dedicated_iface),
36 legacy_hal_(legacy_hal),
37 iface_util_(iface_util),
38 is_valid_(true) {}
39
40std::shared_ptr<WifiNanIface> WifiNanIface::create(
41 const std::string& ifname, bool is_dedicated_iface,
42 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
43 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util) {
44 std::shared_ptr<WifiNanIface> ptr = ndk::SharedRefBase::make<WifiNanIface>(
45 ifname, is_dedicated_iface, legacy_hal, iface_util);
46 if (is_dedicated_iface) {
47 // If using a dedicated iface, set the iface up first.
48 if (!iface_util.lock()->setUpState(ifname, true)) {
49 // Fatal failure, invalidate the iface object.
50 ptr->invalidate();
51 return nullptr;
52 }
53 }
54 std::weak_ptr<WifiNanIface> weak_ptr_this(ptr);
55 ptr->setWeakPtr(weak_ptr_this);
56 ptr->registerCallbackHandlers();
57 return ptr;
58}
59
60void WifiNanIface::registerCallbackHandlers() {
61 // Register all the callbacks here. These should be valid for the lifetime
62 // of the object. Whenever the mode changes legacy HAL will remove
63 // all of these callbacks.
64 legacy_hal::NanCallbackHandlers callback_handlers;
65 std::weak_ptr<WifiNanIface> weak_ptr_this = weak_ptr_this_;
66
67 // Callback for response.
68 callback_handlers.on_notify_response = [weak_ptr_this](legacy_hal::transaction_id id,
69 const legacy_hal::NanResponseMsg& msg) {
70 const auto shared_ptr_this = weak_ptr_this.lock();
71 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
72 LOG(ERROR) << "Callback invoked on an invalid object";
73 return;
74 }
75 NanStatus nanStatus;
76 if (!aidl_struct_util::convertLegacyNanResponseHeaderToAidl(msg, &nanStatus)) {
77 LOG(ERROR) << "Failed to convert nan response header";
78 return;
79 }
80
81 switch (msg.response_type) {
82 case legacy_hal::NAN_RESPONSE_ENABLED: {
83 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
84 if (!callback->notifyEnableResponse(id, nanStatus).isOk()) {
85 LOG(ERROR) << "Failed to invoke the callback";
86 }
87 }
88 break;
89 }
90 case legacy_hal::NAN_RESPONSE_DISABLED: {
91 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
92 if (!callback->notifyDisableResponse(id, nanStatus).isOk()) {
93 LOG(ERROR) << "Failed to invoke the callback";
94 }
95 }
96 break;
97 }
98 case legacy_hal::NAN_RESPONSE_PUBLISH: {
99 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
100 if (!callback->notifyStartPublishResponse(id, nanStatus,
101 msg.body.publish_response.publish_id)
102 .isOk()) {
103 LOG(ERROR) << "Failed to invoke the callback";
104 }
105 }
106 break;
107 }
108 case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: {
109 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
110 if (!callback->notifyStopPublishResponse(id, nanStatus).isOk()) {
111 LOG(ERROR) << "Failed to invoke the callback";
112 }
113 }
114 break;
115 }
116 case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: {
117 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
118 if (!callback->notifyTransmitFollowupResponse(id, nanStatus).isOk()) {
119 LOG(ERROR) << "Failed to invoke the callback";
120 }
121 }
122 break;
123 }
124 case legacy_hal::NAN_RESPONSE_SUBSCRIBE: {
125 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
126 if (!callback->notifyStartSubscribeResponse(
127 id, nanStatus, msg.body.subscribe_response.subscribe_id)
128 .isOk()) {
129 LOG(ERROR) << "Failed to invoke the callback";
130 }
131 }
132 break;
133 }
134 case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: {
135 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
136 if (!callback->notifyStopSubscribeResponse(id, nanStatus).isOk()) {
137 LOG(ERROR) << "Failed to invoke the callback";
138 }
139 }
140 break;
141 }
142 case legacy_hal::NAN_RESPONSE_CONFIG: {
143 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
144 if (!callback->notifyConfigResponse(id, nanStatus).isOk()) {
145 LOG(ERROR) << "Failed to invoke the callback";
146 }
147 }
148 break;
149 }
150 case legacy_hal::NAN_GET_CAPABILITIES: {
151 NanCapabilities aidl_struct;
152 if (!aidl_struct_util::convertLegacyNanCapabilitiesResponseToAidl(
153 msg.body.nan_capabilities, &aidl_struct)) {
154 LOG(ERROR) << "Failed to convert nan capabilities response";
155 return;
156 }
157 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
158 if (!callback->notifyCapabilitiesResponse(id, nanStatus, aidl_struct).isOk()) {
159 LOG(ERROR) << "Failed to invoke the callback";
160 }
161 }
162 break;
163 }
164 case legacy_hal::NAN_DP_INTERFACE_CREATE: {
165 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
166 if (!callback->notifyCreateDataInterfaceResponse(id, nanStatus).isOk()) {
167 LOG(ERROR) << "Failed to invoke the callback";
168 }
169 }
170 break;
171 }
172 case legacy_hal::NAN_DP_INTERFACE_DELETE: {
173 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
174 if (!callback->notifyDeleteDataInterfaceResponse(id, nanStatus).isOk()) {
175 LOG(ERROR) << "Failed to invoke the callback";
176 }
177 }
178 break;
179 }
180 case legacy_hal::NAN_DP_INITIATOR_RESPONSE: {
181 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
182 if (!callback->notifyInitiateDataPathResponse(
183 id, nanStatus,
184 msg.body.data_request_response.ndp_instance_id)
185 .isOk()) {
186 LOG(ERROR) << "Failed to invoke the callback";
187 }
188 }
189 break;
190 }
191 case legacy_hal::NAN_DP_RESPONDER_RESPONSE: {
192 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
193 if (!callback->notifyRespondToDataPathIndicationResponse(id, nanStatus)
194 .isOk()) {
195 LOG(ERROR) << "Failed to invoke the callback";
196 }
197 }
198 break;
199 }
200 case legacy_hal::NAN_DP_END: {
201 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
202 if (!callback->notifyTerminateDataPathResponse(id, nanStatus).isOk()) {
203 LOG(ERROR) << "Failed to invoke the callback";
204 }
205 }
206 break;
207 }
Nate Jiang38e8db52022-12-02 17:30:27 -0800208 case legacy_hal::NAN_PAIRING_INITIATOR_RESPONSE: {
209 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
210 if (!callback->notifyInitiatePairingResponse(
211 id, nanStatus,
212 msg.body.pairing_request_response.paring_instance_id)
213 .isOk()) {
214 LOG(ERROR) << "Failed to invoke the callback";
215 }
216 }
217 break;
218 }
219 case legacy_hal::NAN_PAIRING_RESPONDER_RESPONSE: {
220 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
221 if (!callback->notifyRespondToPairingIndicationResponse(id, nanStatus).isOk()) {
222 LOG(ERROR) << "Failed to invoke the callback";
223 }
224 }
225 break;
226 }
Nate Jiangbae6fdd2023-02-10 17:16:40 -0800227 case legacy_hal::NAN_PAIRING_END: {
228 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
229 if (!callback->notifyTerminatePairingResponse(id, nanStatus).isOk()) {
230 LOG(ERROR) << "Failed to invoke the callback";
231 }
232 }
233 break;
234 }
Nate Jiang38e8db52022-12-02 17:30:27 -0800235 case legacy_hal::NAN_BOOTSTRAPPING_INITIATOR_RESPONSE: {
236 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
237 if (!callback->notifyInitiateBootstrappingResponse(
238 id, nanStatus,
239 msg.body.bootstrapping_request_response
240 .bootstrapping_instance_id)
241 .isOk()) {
242 LOG(ERROR) << "Failed to invoke the callback";
243 }
244 }
245 break;
246 }
247 case legacy_hal::NAN_BOOTSTRAPPING_RESPONDER_RESPONSE: {
248 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
249 if (!callback->notifyRespondToBootstrappingIndicationResponse(id, nanStatus)
250 .isOk()) {
251 LOG(ERROR) << "Failed to invoke the callback";
252 }
253 }
254 break;
255 }
Nate Jiangd6cc3312023-02-14 16:37:54 -0800256 case legacy_hal::NAN_SUSPEND_REQUEST_RESPONSE: {
257 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
258 if (!callback->notifySuspendResponse(id, nanStatus).isOk()) {
259 LOG(ERROR) << "Failed to invoke the callback";
260 }
261 }
262 break;
263 }
264 case legacy_hal::NAN_RESUME_REQUEST_RESPONSE: {
265 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
266 if (!callback->notifyResumeResponse(id, nanStatus).isOk()) {
267 LOG(ERROR) << "Failed to invoke the callback";
268 }
269 }
270 break;
271 }
Gabriel Birenf3262f92022-07-15 23:25:39 +0000272 case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD:
273 /* fall through */
274 case legacy_hal::NAN_RESPONSE_TCA:
275 /* fall through */
276 case legacy_hal::NAN_RESPONSE_STATS:
277 /* fall through */
278 case legacy_hal::NAN_RESPONSE_ERROR:
279 /* fall through */
280 default:
281 LOG(ERROR) << "Unknown or unhandled response type: " << msg.response_type;
282 return;
283 }
284 };
285
286 callback_handlers.on_event_disc_eng_event = [weak_ptr_this](
287 const legacy_hal::NanDiscEngEventInd& msg) {
288 const auto shared_ptr_this = weak_ptr_this.lock();
289 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
290 LOG(ERROR) << "Callback invoked on an invalid object";
291 return;
292 }
293 NanClusterEventInd aidl_struct;
294 // event types defined identically - hence can be cast
295 aidl_struct.eventType = (NanClusterEventType)msg.event_type;
296 aidl_struct.addr = std::array<uint8_t, 6>();
297 std::copy(msg.data.mac_addr.addr, msg.data.mac_addr.addr + 6, std::begin(aidl_struct.addr));
298
299 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
300 if (!callback->eventClusterEvent(aidl_struct).isOk()) {
301 LOG(ERROR) << "Failed to invoke the callback";
302 }
303 }
304 };
305
306 callback_handlers.on_event_disabled = [weak_ptr_this](const legacy_hal::NanDisabledInd& msg) {
307 const auto shared_ptr_this = weak_ptr_this.lock();
308 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
309 LOG(ERROR) << "Callback invoked on an invalid object";
310 return;
311 }
312 NanStatus status;
313 aidl_struct_util::convertToNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
314 &status);
315
316 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
317 if (!callback->eventDisabled(status).isOk()) {
318 LOG(ERROR) << "Failed to invoke the callback";
319 }
320 }
321 };
322
323 callback_handlers.on_event_publish_terminated =
324 [weak_ptr_this](const legacy_hal::NanPublishTerminatedInd& msg) {
325 const auto shared_ptr_this = weak_ptr_this.lock();
326 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
327 LOG(ERROR) << "Callback invoked on an invalid object";
328 return;
329 }
330 NanStatus status;
331 aidl_struct_util::convertToNanStatus(msg.reason, msg.nan_reason,
332 sizeof(msg.nan_reason), &status);
333
334 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
335 if (!callback->eventPublishTerminated(msg.publish_id, status).isOk()) {
336 LOG(ERROR) << "Failed to invoke the callback";
337 }
338 }
339 };
340
341 callback_handlers.on_event_subscribe_terminated =
342 [weak_ptr_this](const legacy_hal::NanSubscribeTerminatedInd& msg) {
343 const auto shared_ptr_this = weak_ptr_this.lock();
344 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
345 LOG(ERROR) << "Callback invoked on an invalid object";
346 return;
347 }
348 NanStatus status;
349 aidl_struct_util::convertToNanStatus(msg.reason, msg.nan_reason,
350 sizeof(msg.nan_reason), &status);
351
352 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
353 if (!callback->eventSubscribeTerminated(msg.subscribe_id, status).isOk()) {
354 LOG(ERROR) << "Failed to invoke the callback";
355 }
356 }
357 };
358
359 callback_handlers.on_event_match = [weak_ptr_this](const legacy_hal::NanMatchInd& msg) {
360 const auto shared_ptr_this = weak_ptr_this.lock();
361 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
362 LOG(ERROR) << "Callback invoked on an invalid object";
363 return;
364 }
365 NanMatchInd aidl_struct;
366 if (!aidl_struct_util::convertLegacyNanMatchIndToAidl(msg, &aidl_struct)) {
367 LOG(ERROR) << "Failed to convert nan capabilities response";
368 return;
369 }
370
371 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
372 if (!callback->eventMatch(aidl_struct).isOk()) {
373 LOG(ERROR) << "Failed to invoke the callback";
374 }
375 }
376 };
377
378 callback_handlers.on_event_match_expired = [weak_ptr_this](
379 const legacy_hal::NanMatchExpiredInd& msg) {
380 const auto shared_ptr_this = weak_ptr_this.lock();
381 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
382 LOG(ERROR) << "Callback invoked on an invalid object";
383 return;
384 }
385 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
386 if (!callback->eventMatchExpired(msg.publish_subscribe_id, msg.requestor_instance_id)
387 .isOk()) {
388 LOG(ERROR) << "Failed to invoke the callback";
389 }
390 }
391 };
392
393 callback_handlers.on_event_followup = [weak_ptr_this](const legacy_hal::NanFollowupInd& msg) {
394 const auto shared_ptr_this = weak_ptr_this.lock();
395 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
396 LOG(ERROR) << "Callback invoked on an invalid object";
397 return;
398 }
399 NanFollowupReceivedInd aidl_struct;
400 if (!aidl_struct_util::convertLegacyNanFollowupIndToAidl(msg, &aidl_struct)) {
401 LOG(ERROR) << "Failed to convert nan capabilities response";
402 return;
403 }
404
405 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
406 if (!callback->eventFollowupReceived(aidl_struct).isOk()) {
407 LOG(ERROR) << "Failed to invoke the callback";
408 }
409 }
410 };
411
412 callback_handlers.on_event_transmit_follow_up =
413 [weak_ptr_this](const legacy_hal::NanTransmitFollowupInd& msg) {
414 const auto shared_ptr_this = weak_ptr_this.lock();
415 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
416 LOG(ERROR) << "Callback invoked on an invalid object";
417 return;
418 }
419 NanStatus status;
420 aidl_struct_util::convertToNanStatus(msg.reason, msg.nan_reason,
421 sizeof(msg.nan_reason), &status);
422
423 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
424 if (!callback->eventTransmitFollowup(msg.id, status).isOk()) {
425 LOG(ERROR) << "Failed to invoke the callback";
426 }
427 }
428 };
429
430 callback_handlers.on_event_data_path_request =
431 [weak_ptr_this](const legacy_hal::NanDataPathRequestInd& msg) {
432 const auto shared_ptr_this = weak_ptr_this.lock();
433 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
434 LOG(ERROR) << "Callback invoked on an invalid object";
435 return;
436 }
437 NanDataPathRequestInd aidl_struct;
438 if (!aidl_struct_util::convertLegacyNanDataPathRequestIndToAidl(msg,
439 &aidl_struct)) {
440 LOG(ERROR) << "Failed to convert nan capabilities response";
441 return;
442 }
443
444 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
445 if (!callback->eventDataPathRequest(aidl_struct).isOk()) {
446 LOG(ERROR) << "Failed to invoke the callback";
447 }
448 }
449 };
450
451 callback_handlers.on_event_data_path_confirm =
452 [weak_ptr_this](const legacy_hal::NanDataPathConfirmInd& msg) {
453 const auto shared_ptr_this = weak_ptr_this.lock();
454 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
455 LOG(ERROR) << "Callback invoked on an invalid object";
456 return;
457 }
458 NanDataPathConfirmInd aidl_struct;
459 if (!aidl_struct_util::convertLegacyNanDataPathConfirmIndToAidl(msg,
460 &aidl_struct)) {
461 LOG(ERROR) << "Failed to convert nan capabilities response";
462 return;
463 }
464
465 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
466 if (!callback->eventDataPathConfirm(aidl_struct).isOk()) {
467 LOG(ERROR) << "Failed to invoke the callback";
468 }
469 }
470 };
471
472 callback_handlers.on_event_data_path_end =
473 [weak_ptr_this](const legacy_hal::NanDataPathEndInd& msg) {
474 const auto shared_ptr_this = weak_ptr_this.lock();
475 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
476 LOG(ERROR) << "Callback invoked on an invalid object";
477 return;
478 }
479 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
480 for (int i = 0; i < msg.num_ndp_instances; ++i) {
481 if (!callback->eventDataPathTerminated(msg.ndp_instance_id[i]).isOk()) {
482 LOG(ERROR) << "Failed to invoke the callback";
483 }
484 }
485 }
486 };
487
Nate Jiang38e8db52022-12-02 17:30:27 -0800488 callback_handlers.on_event_pairing_request =
489 [weak_ptr_this](const legacy_hal::NanPairingRequestInd& msg) {
490 const auto shared_ptr_this = weak_ptr_this.lock();
491 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
492 LOG(ERROR) << "Callback invoked on an invalid object";
493 return;
494 }
495 NanPairingRequestInd aidl_struct;
496 if (!aidl_struct_util::convertLegacyNanPairingRequestIndToAidl(msg, &aidl_struct)) {
497 LOG(ERROR) << "Failed to convert nan capabilities response";
498 return;
499 }
500
501 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
502 if (!callback->eventPairingRequest(aidl_struct).isOk()) {
503 LOG(ERROR) << "Failed to invoke the callback";
504 }
505 }
506 };
507 callback_handlers.on_event_pairing_confirm =
508 [weak_ptr_this](const legacy_hal::NanPairingConfirmInd& msg) {
509 const auto shared_ptr_this = weak_ptr_this.lock();
510 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
511 LOG(ERROR) << "Callback invoked on an invalid object";
512 return;
513 }
514 NanPairingConfirmInd aidl_struct;
515 if (!aidl_struct_util::convertLegacyNanPairingConfirmIndToAidl(msg, &aidl_struct)) {
516 LOG(ERROR) << "Failed to convert nan capabilities response";
517 return;
518 }
519
520 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
521 if (!callback->eventPairingConfirm(aidl_struct).isOk()) {
522 LOG(ERROR) << "Failed to invoke the callback";
523 }
524 }
525 };
526 callback_handlers.on_event_bootstrapping_request =
527 [weak_ptr_this](const legacy_hal::NanBootstrappingRequestInd& msg) {
528 const auto shared_ptr_this = weak_ptr_this.lock();
529 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
530 LOG(ERROR) << "Callback invoked on an invalid object";
531 return;
532 }
533 NanBootstrappingRequestInd aidl_struct;
534 if (!aidl_struct_util::convertLegacyNanBootstrappingRequestIndToAidl(
535 msg, &aidl_struct)) {
536 LOG(ERROR) << "Failed to convert nan capabilities response";
537 return;
538 }
539
540 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
541 if (!callback->eventBootstrappingRequest(aidl_struct).isOk()) {
542 LOG(ERROR) << "Failed to invoke the callback";
543 }
544 }
545 };
546 callback_handlers.on_event_bootstrapping_confirm =
547 [weak_ptr_this](const legacy_hal::NanBootstrappingConfirmInd& msg) {
548 const auto shared_ptr_this = weak_ptr_this.lock();
549 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
550 LOG(ERROR) << "Callback invoked on an invalid object";
551 return;
552 }
553 NanBootstrappingConfirmInd aidl_struct;
554 if (!aidl_struct_util::convertLegacyNanBootstrappingConfirmIndToAidl(
555 msg, &aidl_struct)) {
556 LOG(ERROR) << "Failed to convert nan capabilities response";
557 return;
558 }
559
560 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
561 if (!callback->eventBootstrappingConfirm(aidl_struct).isOk()) {
562 LOG(ERROR) << "Failed to invoke the callback";
563 }
564 }
565 };
566
Gabriel Birenf3262f92022-07-15 23:25:39 +0000567 callback_handlers.on_event_beacon_sdf_payload =
568 [](const legacy_hal::NanBeaconSdfPayloadInd& /* msg */) {
569 LOG(ERROR) << "on_event_beacon_sdf_payload - should not be called";
570 };
571
572 callback_handlers.on_event_range_request = [](const legacy_hal::NanRangeRequestInd& /* msg */) {
573 LOG(ERROR) << "on_event_range_request - should not be called";
574 };
575
576 callback_handlers.on_event_range_report = [](const legacy_hal::NanRangeReportInd& /* msg */) {
577 LOG(ERROR) << "on_event_range_report - should not be called";
578 };
579
580 callback_handlers.on_event_schedule_update =
581 [weak_ptr_this](const legacy_hal::NanDataPathScheduleUpdateInd& msg) {
582 const auto shared_ptr_this = weak_ptr_this.lock();
583 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
584 LOG(ERROR) << "Callback invoked on an invalid object";
585 return;
586 }
587 NanDataPathScheduleUpdateInd aidl_struct;
588 if (!aidl_struct_util::convertLegacyNanDataPathScheduleUpdateIndToAidl(
589 msg, &aidl_struct)) {
590 LOG(ERROR) << "Failed to convert nan capabilities response";
591 return;
592 }
593
594 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
595 if (!callback->eventDataPathScheduleUpdate(aidl_struct).isOk()) {
596 LOG(ERROR) << "Failed to invoke the callback";
597 }
598 }
599 };
Nate Jiangd6cc3312023-02-14 16:37:54 -0800600 callback_handlers.on_event_suspension_mode_change =
601 [weak_ptr_this](const legacy_hal::NanSuspensionModeChangeInd& msg) {
602 const auto shared_ptr_this = weak_ptr_this.lock();
603 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
604 LOG(ERROR) << "Callback invoked on an invalid object";
605 return;
606 }
607 NanSuspensionModeChangeInd aidl_struct;
608 aidl_struct.isSuspended = msg.is_suspended;
609
610 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
611 if (!callback->eventSuspensionModeChanged(aidl_struct).isOk()) {
612 LOG(ERROR) << "Failed to invoke the callback";
613 }
614 }
615 };
Gabriel Birenf3262f92022-07-15 23:25:39 +0000616
617 legacy_hal::wifi_error legacy_status =
618 legacy_hal_.lock()->nanRegisterCallbackHandlers(ifname_, callback_handlers);
619 if (legacy_status != legacy_hal::WIFI_SUCCESS) {
620 LOG(ERROR) << "Failed to register nan callbacks. Invalidating object";
621 invalidate();
622 }
623
624 // Register for iface state toggle events.
625 iface_util::IfaceEventHandlers event_handlers = {};
626 event_handlers.on_state_toggle_off_on = [weak_ptr_this](const std::string& /* iface_name */) {
627 const auto shared_ptr_this = weak_ptr_this.lock();
628 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
629 LOG(ERROR) << "Callback invoked on an invalid object";
630 return;
631 }
632 // Tell framework that NAN has been disabled.
633 NanStatus status = {NanStatusCode::UNSUPPORTED_CONCURRENCY_NAN_DISABLED, ""};
634 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
635 if (!callback->eventDisabled(status).isOk()) {
636 LOG(ERROR) << "Failed to invoke the callback";
637 }
638 }
639 };
640 iface_util_.lock()->registerIfaceEventHandlers(ifname_, event_handlers);
641}
642
643void WifiNanIface::setWeakPtr(std::weak_ptr<WifiNanIface> ptr) {
644 weak_ptr_this_ = ptr;
645}
646
647void WifiNanIface::invalidate() {
648 if (!isValid()) {
649 return;
650 }
651 // send commands to HAL to actually disable and destroy interfaces
652 legacy_hal_.lock()->nanDisableRequest(ifname_, 0xFFFF);
653 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFE, "aware_data0");
654 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFD, "aware_data1");
655 iface_util_.lock()->unregisterIfaceEventHandlers(ifname_);
656 legacy_hal_.reset();
657 event_cb_handler_.invalidate();
658 is_valid_ = false;
659 if (is_dedicated_iface_) {
660 // If using a dedicated iface, set the iface down.
661 iface_util_.lock()->setUpState(ifname_, false);
662 }
663}
664
665bool WifiNanIface::isValid() {
666 return is_valid_;
667}
668
669std::string WifiNanIface::getName() {
670 return ifname_;
671}
672
673std::set<std::shared_ptr<IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks() {
674 LOG(ERROR) << "Using original getEventCallbacks";
675 return event_cb_handler_.getCallbacks();
676}
677
678ndk::ScopedAStatus WifiNanIface::getName(std::string* _aidl_return) {
679 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
680 &WifiNanIface::getNameInternal, _aidl_return);
681}
682
683ndk::ScopedAStatus WifiNanIface::registerEventCallback(
684 const std::shared_ptr<IWifiNanIfaceEventCallback>& callback) {
685 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
686 &WifiNanIface::registerEventCallbackInternal, callback);
687}
688
689ndk::ScopedAStatus WifiNanIface::getCapabilitiesRequest(char16_t in_cmdId) {
690 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
691 &WifiNanIface::getCapabilitiesRequestInternal, in_cmdId);
692}
693
694ndk::ScopedAStatus WifiNanIface::enableRequest(char16_t in_cmdId, const NanEnableRequest& in_msg1,
695 const NanConfigRequestSupplemental& in_msg2) {
696 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
697 &WifiNanIface::enableRequestInternal, in_cmdId, in_msg1, in_msg2);
698}
699
700ndk::ScopedAStatus WifiNanIface::configRequest(char16_t in_cmdId, const NanConfigRequest& in_msg1,
701 const NanConfigRequestSupplemental& in_msg2) {
702 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
703 &WifiNanIface::configRequestInternal, in_cmdId, in_msg1, in_msg2);
704}
705
706ndk::ScopedAStatus WifiNanIface::disableRequest(char16_t in_cmdId) {
707 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
708 &WifiNanIface::disableRequestInternal, in_cmdId);
709}
710
711ndk::ScopedAStatus WifiNanIface::startPublishRequest(char16_t in_cmdId,
712 const NanPublishRequest& in_msg) {
713 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
714 &WifiNanIface::startPublishRequestInternal, in_cmdId, in_msg);
715}
716
717ndk::ScopedAStatus WifiNanIface::stopPublishRequest(char16_t in_cmdId, int8_t in_sessionId) {
718 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
719 &WifiNanIface::stopPublishRequestInternal, in_cmdId, in_sessionId);
720}
721
722ndk::ScopedAStatus WifiNanIface::startSubscribeRequest(char16_t in_cmdId,
723 const NanSubscribeRequest& in_msg) {
724 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
725 &WifiNanIface::startSubscribeRequestInternal, in_cmdId, in_msg);
726}
727
728ndk::ScopedAStatus WifiNanIface::stopSubscribeRequest(char16_t in_cmdId, int8_t in_sessionId) {
729 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
730 &WifiNanIface::stopSubscribeRequestInternal, in_cmdId, in_sessionId);
731}
732
733ndk::ScopedAStatus WifiNanIface::transmitFollowupRequest(char16_t in_cmdId,
734 const NanTransmitFollowupRequest& in_msg) {
735 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
736 &WifiNanIface::transmitFollowupRequestInternal, in_cmdId, in_msg);
737}
738
739ndk::ScopedAStatus WifiNanIface::createDataInterfaceRequest(char16_t in_cmdId,
740 const std::string& in_ifaceName) {
741 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
742 &WifiNanIface::createDataInterfaceRequestInternal, in_cmdId,
743 in_ifaceName);
744}
745
746ndk::ScopedAStatus WifiNanIface::deleteDataInterfaceRequest(char16_t in_cmdId,
747 const std::string& in_ifaceName) {
748 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
749 &WifiNanIface::deleteDataInterfaceRequestInternal, in_cmdId,
750 in_ifaceName);
751}
752
753ndk::ScopedAStatus WifiNanIface::initiateDataPathRequest(char16_t in_cmdId,
754 const NanInitiateDataPathRequest& in_msg) {
755 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
756 &WifiNanIface::initiateDataPathRequestInternal, in_cmdId, in_msg);
757}
758
759ndk::ScopedAStatus WifiNanIface::respondToDataPathIndicationRequest(
760 char16_t in_cmdId, const NanRespondToDataPathIndicationRequest& in_msg) {
761 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
762 &WifiNanIface::respondToDataPathIndicationRequestInternal, in_cmdId,
763 in_msg);
764}
765
766ndk::ScopedAStatus WifiNanIface::terminateDataPathRequest(char16_t in_cmdId,
767 int32_t in_ndpInstanceId) {
768 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
769 &WifiNanIface::terminateDataPathRequestInternal, in_cmdId,
770 in_ndpInstanceId);
771}
772
Nate Jiang38e8db52022-12-02 17:30:27 -0800773ndk::ScopedAStatus WifiNanIface::initiatePairingRequest(char16_t in_cmdId,
774 const NanPairingRequest& in_msg) {
775 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
776 &WifiNanIface::initiatePairingRequestInternal, in_cmdId, in_msg);
777}
778
779ndk::ScopedAStatus WifiNanIface::respondToPairingIndicationRequest(
780 char16_t in_cmdId, const NanRespondToPairingIndicationRequest& in_msg) {
781 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
782 &WifiNanIface::respondToPairingIndicationRequestInternal, in_cmdId,
783 in_msg);
784}
785
Nate Jiangbae6fdd2023-02-10 17:16:40 -0800786ndk::ScopedAStatus WifiNanIface::terminatePairingRequest(char16_t in_cmdId,
787 int32_t in_ndpInstanceId) {
788 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
789 &WifiNanIface::terminatePairingRequestInternal, in_cmdId,
790 in_ndpInstanceId);
791}
792
Nate Jiang38e8db52022-12-02 17:30:27 -0800793ndk::ScopedAStatus WifiNanIface::initiateBootstrappingRequest(
794 char16_t in_cmdId, const NanBootstrappingRequest& in_msg) {
795 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
796 &WifiNanIface::initiateBootstrappingRequestInternal, in_cmdId, in_msg);
797}
798
799ndk::ScopedAStatus WifiNanIface::respondToBootstrappingIndicationRequest(
800 char16_t in_cmdId, const NanBootstrappingResponse& in_msg) {
801 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
802 &WifiNanIface::respondToBootstrappingIndicationRequestInternal, in_cmdId,
803 in_msg);
804}
805
Phill Hayers02a97242022-12-15 16:05:14 +0000806ndk::ScopedAStatus WifiNanIface::suspendRequest(char16_t in_cmdId, int8_t in_sessionId) {
807 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
808 &WifiNanIface::suspendRequestInternal, in_cmdId, in_sessionId);
809}
810
811ndk::ScopedAStatus WifiNanIface::resumeRequest(char16_t in_cmdId, int8_t in_sessionId) {
812 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
813 &WifiNanIface::resumeRequestInternal, in_cmdId, in_sessionId);
814}
815
Gabriel Birenf3262f92022-07-15 23:25:39 +0000816std::pair<std::string, ndk::ScopedAStatus> WifiNanIface::getNameInternal() {
817 return {ifname_, ndk::ScopedAStatus::ok()};
818}
819
820ndk::ScopedAStatus WifiNanIface::registerEventCallbackInternal(
821 const std::shared_ptr<IWifiNanIfaceEventCallback>& callback) {
822 if (!event_cb_handler_.addCallback(callback)) {
823 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
824 }
825 return ndk::ScopedAStatus::ok();
826}
827
828ndk::ScopedAStatus WifiNanIface::getCapabilitiesRequestInternal(char16_t cmd_id) {
829 legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->nanGetCapabilities(ifname_, cmd_id);
830 return createWifiStatusFromLegacyError(legacy_status);
831}
832
833ndk::ScopedAStatus WifiNanIface::enableRequestInternal(char16_t cmd_id,
834 const NanEnableRequest& msg1,
835 const NanConfigRequestSupplemental& msg2) {
836 legacy_hal::NanEnableRequest legacy_msg;
837 if (!aidl_struct_util::convertAidlNanEnableRequestToLegacy(msg1, msg2, &legacy_msg)) {
838 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
839 }
840 legacy_hal::wifi_error legacy_status =
841 legacy_hal_.lock()->nanEnableRequest(ifname_, cmd_id, legacy_msg);
842 return createWifiStatusFromLegacyError(legacy_status);
843}
844
845ndk::ScopedAStatus WifiNanIface::configRequestInternal(char16_t cmd_id,
846 const NanConfigRequest& msg1,
847 const NanConfigRequestSupplemental& msg2) {
848 legacy_hal::NanConfigRequest legacy_msg;
849 if (!aidl_struct_util::convertAidlNanConfigRequestToLegacy(msg1, msg2, &legacy_msg)) {
850 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
851 }
852 legacy_hal::wifi_error legacy_status =
853 legacy_hal_.lock()->nanConfigRequest(ifname_, cmd_id, legacy_msg);
854 return createWifiStatusFromLegacyError(legacy_status);
855}
856
857ndk::ScopedAStatus WifiNanIface::disableRequestInternal(char16_t cmd_id) {
858 legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->nanDisableRequest(ifname_, cmd_id);
859 return createWifiStatusFromLegacyError(legacy_status);
860}
861
862ndk::ScopedAStatus WifiNanIface::startPublishRequestInternal(char16_t cmd_id,
863 const NanPublishRequest& msg) {
864 legacy_hal::NanPublishRequest legacy_msg;
865 if (!aidl_struct_util::convertAidlNanPublishRequestToLegacy(msg, &legacy_msg)) {
866 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
867 }
868 legacy_hal::wifi_error legacy_status =
869 legacy_hal_.lock()->nanPublishRequest(ifname_, cmd_id, legacy_msg);
870 return createWifiStatusFromLegacyError(legacy_status);
871}
872
873ndk::ScopedAStatus WifiNanIface::stopPublishRequestInternal(char16_t cmd_id, int8_t sessionId) {
874 legacy_hal::NanPublishCancelRequest legacy_msg;
875 legacy_msg.publish_id = sessionId;
876 legacy_hal::wifi_error legacy_status =
877 legacy_hal_.lock()->nanPublishCancelRequest(ifname_, cmd_id, legacy_msg);
878 return createWifiStatusFromLegacyError(legacy_status);
879}
880
881ndk::ScopedAStatus WifiNanIface::startSubscribeRequestInternal(char16_t cmd_id,
882 const NanSubscribeRequest& msg) {
883 legacy_hal::NanSubscribeRequest legacy_msg;
884 if (!aidl_struct_util::convertAidlNanSubscribeRequestToLegacy(msg, &legacy_msg)) {
885 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
886 }
887 legacy_hal::wifi_error legacy_status =
888 legacy_hal_.lock()->nanSubscribeRequest(ifname_, cmd_id, legacy_msg);
889 return createWifiStatusFromLegacyError(legacy_status);
890}
891
892ndk::ScopedAStatus WifiNanIface::stopSubscribeRequestInternal(char16_t cmd_id, int8_t sessionId) {
893 legacy_hal::NanSubscribeCancelRequest legacy_msg;
894 legacy_msg.subscribe_id = sessionId;
895 legacy_hal::wifi_error legacy_status =
896 legacy_hal_.lock()->nanSubscribeCancelRequest(ifname_, cmd_id, legacy_msg);
897 return createWifiStatusFromLegacyError(legacy_status);
898}
899
900ndk::ScopedAStatus WifiNanIface::transmitFollowupRequestInternal(
901 char16_t cmd_id, const NanTransmitFollowupRequest& msg) {
902 legacy_hal::NanTransmitFollowupRequest legacy_msg;
903 if (!aidl_struct_util::convertAidlNanTransmitFollowupRequestToLegacy(msg, &legacy_msg)) {
904 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
905 }
906 legacy_hal::wifi_error legacy_status =
907 legacy_hal_.lock()->nanTransmitFollowupRequest(ifname_, cmd_id, legacy_msg);
908 return createWifiStatusFromLegacyError(legacy_status);
909}
910
911ndk::ScopedAStatus WifiNanIface::createDataInterfaceRequestInternal(char16_t cmd_id,
912 const std::string& iface_name) {
913 legacy_hal::wifi_error legacy_status =
914 legacy_hal_.lock()->nanDataInterfaceCreate(ifname_, cmd_id, iface_name);
915 return createWifiStatusFromLegacyError(legacy_status);
916}
917ndk::ScopedAStatus WifiNanIface::deleteDataInterfaceRequestInternal(char16_t cmd_id,
918 const std::string& iface_name) {
919 legacy_hal::wifi_error legacy_status =
920 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, cmd_id, iface_name);
921 return createWifiStatusFromLegacyError(legacy_status);
922}
923ndk::ScopedAStatus WifiNanIface::initiateDataPathRequestInternal(
924 char16_t cmd_id, const NanInitiateDataPathRequest& msg) {
925 legacy_hal::NanDataPathInitiatorRequest legacy_msg;
926 if (!aidl_struct_util::convertAidlNanDataPathInitiatorRequestToLegacy(msg, &legacy_msg)) {
927 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
928 }
929 legacy_hal::wifi_error legacy_status =
930 legacy_hal_.lock()->nanDataRequestInitiator(ifname_, cmd_id, legacy_msg);
931 return createWifiStatusFromLegacyError(legacy_status);
932}
933ndk::ScopedAStatus WifiNanIface::respondToDataPathIndicationRequestInternal(
934 char16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg) {
935 legacy_hal::NanDataPathIndicationResponse legacy_msg;
936 if (!aidl_struct_util::convertAidlNanDataPathIndicationResponseToLegacy(msg, &legacy_msg)) {
937 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
938 }
939 legacy_hal::wifi_error legacy_status =
940 legacy_hal_.lock()->nanDataIndicationResponse(ifname_, cmd_id, legacy_msg);
941 return createWifiStatusFromLegacyError(legacy_status);
942}
943ndk::ScopedAStatus WifiNanIface::terminateDataPathRequestInternal(char16_t cmd_id,
944 int32_t ndpInstanceId) {
945 legacy_hal::wifi_error legacy_status =
946 legacy_hal_.lock()->nanDataEnd(ifname_, cmd_id, ndpInstanceId);
947 return createWifiStatusFromLegacyError(legacy_status);
948}
Nate Jiang38e8db52022-12-02 17:30:27 -0800949ndk::ScopedAStatus WifiNanIface::initiatePairingRequestInternal(char16_t cmd_id,
950 const NanPairingRequest& msg) {
951 legacy_hal::NanPairingRequest legacy_msg;
952 if (!aidl_struct_util::convertAidlNanPairingInitiatorRequestToLegacy(msg, &legacy_msg)) {
953 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
954 }
955 legacy_hal::wifi_error legacy_status =
956 legacy_hal_.lock()->nanPairingRequest(ifname_, cmd_id, legacy_msg);
957 return createWifiStatusFromLegacyError(legacy_status);
958}
959ndk::ScopedAStatus WifiNanIface::respondToPairingIndicationRequestInternal(
960 char16_t cmd_id, const NanRespondToPairingIndicationRequest& msg) {
961 legacy_hal::NanPairingIndicationResponse legacy_msg;
962 if (!aidl_struct_util::convertAidlNanPairingIndicationResponseToLegacy(msg, &legacy_msg)) {
963 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
964 }
965 legacy_hal::wifi_error legacy_status =
966 legacy_hal_.lock()->nanPairingIndicationResponse(ifname_, cmd_id, legacy_msg);
967 return createWifiStatusFromLegacyError(legacy_status);
968}
Nate Jiangbae6fdd2023-02-10 17:16:40 -0800969ndk::ScopedAStatus WifiNanIface::terminatePairingRequestInternal(char16_t cmd_id,
970 int32_t ndpInstanceId) {
971 legacy_hal::wifi_error legacy_status =
972 legacy_hal_.lock()->nanPairingEnd(ifname_, cmd_id, ndpInstanceId);
973 return createWifiStatusFromLegacyError(legacy_status);
974}
Nate Jiang38e8db52022-12-02 17:30:27 -0800975ndk::ScopedAStatus WifiNanIface::initiateBootstrappingRequestInternal(
976 char16_t cmd_id, const NanBootstrappingRequest& msg) {
977 legacy_hal::NanBootstrappingRequest legacy_msg;
978 if (!aidl_struct_util::convertAidlNanBootstrappingInitiatorRequestToLegacy(msg, &legacy_msg)) {
979 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
980 }
981 legacy_hal::wifi_error legacy_status =
982 legacy_hal_.lock()->nanBootstrappingRequest(ifname_, cmd_id, legacy_msg);
983 return createWifiStatusFromLegacyError(legacy_status);
984}
985ndk::ScopedAStatus WifiNanIface::respondToBootstrappingIndicationRequestInternal(
986 char16_t cmd_id, const NanBootstrappingResponse& msg) {
987 legacy_hal::NanBootstrappingIndicationResponse legacy_msg;
988 if (!aidl_struct_util::convertAidlNanBootstrappingIndicationResponseToLegacy(msg,
989 &legacy_msg)) {
990 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
991 }
992 legacy_hal::wifi_error legacy_status =
993 legacy_hal_.lock()->nanBootstrappingIndicationResponse(ifname_, cmd_id, legacy_msg);
994 return createWifiStatusFromLegacyError(legacy_status);
995}
Phill Hayers02a97242022-12-15 16:05:14 +0000996ndk::ScopedAStatus WifiNanIface::suspendRequestInternal(char16_t cmd_id, int8_t sessionId) {
997 legacy_hal::NanSuspendRequest legacy_msg;
998 legacy_msg.publish_subscribe_id = sessionId;
999 legacy_hal::wifi_error legacy_status =
1000 legacy_hal_.lock()->nanSuspendRequest(ifname_, cmd_id, legacy_msg);
1001 return createWifiStatusFromLegacyError(legacy_status);
1002}
1003ndk::ScopedAStatus WifiNanIface::resumeRequestInternal(char16_t cmd_id, int8_t sessionId) {
1004 legacy_hal::NanResumeRequest legacy_msg;
1005 legacy_msg.publish_subscribe_id = sessionId;
1006 legacy_hal::wifi_error legacy_status =
1007 legacy_hal_.lock()->nanResumeRequest(ifname_, cmd_id, legacy_msg);
1008 return createWifiStatusFromLegacyError(legacy_status);
1009}
Gabriel Birenf3262f92022-07-15 23:25:39 +00001010} // namespace wifi
1011} // namespace hardware
1012} // namespace android
1013} // namespace aidl