blob: ff9f4224df3fc185a61ea1ba87ba8fadad2152b8 [file] [log] [blame]
Roshan Pius3e2d6712016-10-06 13:16:23 -07001/*
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 Pius3e2d6712016-10-06 13:16:23 -070017#include <android-base/logging.h>
18
Roshan Pius907d4a22016-10-27 12:48:12 -070019#include "hidl_return_util.h"
Roshan Piusf5f51fd2016-12-01 13:54:24 -080020#include "hidl_struct_util.h"
Roshan Pius907d4a22016-10-27 12:48:12 -070021#include "wifi_nan_iface.h"
Roshan Pius734fea02016-10-11 08:30:28 -070022#include "wifi_status_util.h"
Roshan Pius3e2d6712016-10-06 13:16:23 -070023
24namespace android {
25namespace hardware {
26namespace wifi {
Jong Wook Kimda830c92018-07-23 15:29:38 -070027namespace V1_3 {
Roshan Pius3e2d6712016-10-06 13:16:23 -070028namespace implementation {
Roshan Pius907d4a22016-10-27 12:48:12 -070029using hidl_return_util::validateAndCall;
Roshan Pius3e2d6712016-10-06 13:16:23 -070030
Roshan Pius6cedc972016-10-28 10:11:17 -070031WifiNanIface::WifiNanIface(
32 const std::string& ifname,
Roshan Pius356d5a62019-05-17 15:07:34 -070033 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
34 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util)
35 : ifname_(ifname),
36 legacy_hal_(legacy_hal),
37 iface_util_(iface_util),
38 is_valid_(true) {
Roshan Piusabcf78f2017-10-06 16:30:38 -070039 // Register all the callbacks here. these should be valid for the lifetime
40 // of the object. Whenever the mode changes legacy HAL will remove
41 // all of these callbacks.
42 legacy_hal::NanCallbackHandlers callback_handlers;
43 android::wp<WifiNanIface> weak_ptr_this(this);
Roshan Piusf5f51fd2016-12-01 13:54:24 -080044
Roshan Piusabcf78f2017-10-06 16:30:38 -070045 // Callback for response.
46 callback_handlers
47 .on_notify_response = [weak_ptr_this](
48 legacy_hal::transaction_id id,
49 const legacy_hal::NanResponseMsg& msg) {
50 const auto shared_ptr_this = weak_ptr_this.promote();
51 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
52 LOG(ERROR) << "Callback invoked on an invalid object";
Etan Cohenf01bcaa2016-12-25 09:42:21 -080053 return;
54 }
Roshan Piusabcf78f2017-10-06 16:30:38 -070055 WifiNanStatus wifiNanStatus;
56 if (!hidl_struct_util::convertLegacyNanResponseHeaderToHidl(
57 msg, &wifiNanStatus)) {
58 LOG(ERROR) << "Failed to convert nan response header";
59 return;
Etan Cohenf01bcaa2016-12-25 09:42:21 -080060 }
Etan Cohenf01bcaa2016-12-25 09:42:21 -080061
Roshan Piusabcf78f2017-10-06 16:30:38 -070062 switch (msg.response_type) {
63 case legacy_hal::NAN_RESPONSE_ENABLED: {
64 for (const auto& callback :
65 shared_ptr_this->getEventCallbacks()) {
66 if (!callback->notifyEnableResponse(id, wifiNanStatus)
67 .isOk()) {
68 LOG(ERROR) << "Failed to invoke the callback";
69 }
70 }
71 break;
Etan Cohenf01bcaa2016-12-25 09:42:21 -080072 }
Roshan Piusabcf78f2017-10-06 16:30:38 -070073 case legacy_hal::NAN_RESPONSE_DISABLED: {
74 for (const auto& callback :
75 shared_ptr_this->getEventCallbacks()) {
76 if (!callback->notifyDisableResponse(id, wifiNanStatus)
77 .isOk()) {
78 LOG(ERROR) << "Failed to invoke the callback";
79 }
80 }
81 break;
82 }
83 case legacy_hal::NAN_RESPONSE_PUBLISH: {
84 for (const auto& callback :
85 shared_ptr_this->getEventCallbacks()) {
86 if (!callback
87 ->notifyStartPublishResponse(
88 id, wifiNanStatus,
89 msg.body.publish_response.publish_id)
90 .isOk()) {
91 LOG(ERROR) << "Failed to invoke the callback";
92 }
93 }
94 break;
95 }
96 case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: {
97 for (const auto& callback :
98 shared_ptr_this->getEventCallbacks()) {
99 if (!callback->notifyStopPublishResponse(id, wifiNanStatus)
100 .isOk()) {
101 LOG(ERROR) << "Failed to invoke the callback";
102 }
103 }
104 break;
105 }
106 case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: {
107 for (const auto& callback :
108 shared_ptr_this->getEventCallbacks()) {
109 if (!callback
110 ->notifyTransmitFollowupResponse(id, wifiNanStatus)
111 .isOk()) {
112 LOG(ERROR) << "Failed to invoke the callback";
113 }
114 }
115 break;
116 }
117 case legacy_hal::NAN_RESPONSE_SUBSCRIBE: {
118 for (const auto& callback :
119 shared_ptr_this->getEventCallbacks()) {
120 if (!callback
121 ->notifyStartSubscribeResponse(
122 id, wifiNanStatus,
123 msg.body.subscribe_response.subscribe_id)
124 .isOk()) {
125 LOG(ERROR) << "Failed to invoke the callback";
126 }
127 }
128 break;
129 }
130 case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: {
131 for (const auto& callback :
132 shared_ptr_this->getEventCallbacks()) {
133 if (!callback
134 ->notifyStopSubscribeResponse(id, wifiNanStatus)
135 .isOk()) {
136 LOG(ERROR) << "Failed to invoke the callback";
137 }
138 }
139 break;
140 }
141 case legacy_hal::NAN_RESPONSE_CONFIG: {
142 for (const auto& callback :
143 shared_ptr_this->getEventCallbacks()) {
144 if (!callback->notifyConfigResponse(id, wifiNanStatus)
145 .isOk()) {
146 LOG(ERROR) << "Failed to invoke the callback";
147 }
148 }
149 break;
150 }
151 case legacy_hal::NAN_GET_CAPABILITIES: {
152 NanCapabilities hidl_struct;
153 if (!hidl_struct_util::
154 convertLegacyNanCapabilitiesResponseToHidl(
155 msg.body.nan_capabilities, &hidl_struct)) {
156 LOG(ERROR) << "Failed to convert nan capabilities response";
157 return;
158 }
159 for (const auto& callback :
160 shared_ptr_this->getEventCallbacks()) {
161 if (!callback
162 ->notifyCapabilitiesResponse(id, wifiNanStatus,
163 hidl_struct)
164 .isOk()) {
165 LOG(ERROR) << "Failed to invoke the callback";
166 }
167 }
168 break;
169 }
170 case legacy_hal::NAN_DP_INTERFACE_CREATE: {
171 for (const auto& callback :
172 shared_ptr_this->getEventCallbacks()) {
173 if (!callback
174 ->notifyCreateDataInterfaceResponse(id,
175 wifiNanStatus)
176 .isOk()) {
177 LOG(ERROR) << "Failed to invoke the callback";
178 }
179 }
180 break;
181 }
182 case legacy_hal::NAN_DP_INTERFACE_DELETE: {
183 for (const auto& callback :
184 shared_ptr_this->getEventCallbacks()) {
185 if (!callback
186 ->notifyDeleteDataInterfaceResponse(id,
187 wifiNanStatus)
188 .isOk()) {
189 LOG(ERROR) << "Failed to invoke the callback";
190 }
191 }
192 break;
193 }
194 case legacy_hal::NAN_DP_INITIATOR_RESPONSE: {
195 for (const auto& callback :
196 shared_ptr_this->getEventCallbacks()) {
197 if (!callback
198 ->notifyInitiateDataPathResponse(
199 id, wifiNanStatus,
200 msg.body.data_request_response.ndp_instance_id)
201 .isOk()) {
202 LOG(ERROR) << "Failed to invoke the callback";
203 }
204 }
205 break;
206 }
207 case legacy_hal::NAN_DP_RESPONDER_RESPONSE: {
208 for (const auto& callback :
209 shared_ptr_this->getEventCallbacks()) {
210 if (!callback
211 ->notifyRespondToDataPathIndicationResponse(
212 id, wifiNanStatus)
213 .isOk()) {
214 LOG(ERROR) << "Failed to invoke the callback";
215 }
216 }
217 break;
218 }
219 case legacy_hal::NAN_DP_END: {
220 for (const auto& callback :
221 shared_ptr_this->getEventCallbacks()) {
222 if (!callback
223 ->notifyTerminateDataPathResponse(id,
224 wifiNanStatus)
225 .isOk()) {
226 LOG(ERROR) << "Failed to invoke the callback";
227 }
228 }
229 break;
230 }
231 case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD:
232 /* fall through */
233 case legacy_hal::NAN_RESPONSE_TCA:
234 /* fall through */
235 case legacy_hal::NAN_RESPONSE_STATS:
236 /* fall through */
237 case legacy_hal::NAN_RESPONSE_ERROR:
238 /* fall through */
239 default:
240 LOG(ERROR) << "Unknown or unhandled response type: "
241 << msg.response_type;
242 return;
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800243 }
Roshan Piusabcf78f2017-10-06 16:30:38 -0700244 };
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800245
Roshan Piusabcf78f2017-10-06 16:30:38 -0700246 callback_handlers.on_event_disc_eng_event =
247 [weak_ptr_this](const legacy_hal::NanDiscEngEventInd& msg) {
248 const auto shared_ptr_this = weak_ptr_this.promote();
249 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
250 LOG(ERROR) << "Callback invoked on an invalid object";
251 return;
252 }
253 NanClusterEventInd hidl_struct;
254 // event types defined identically - hence can be cast
255 hidl_struct.eventType = (NanClusterEventType)msg.event_type;
256 hidl_struct.addr = msg.data.mac_addr.addr;
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800257
Roshan Piusabcf78f2017-10-06 16:30:38 -0700258 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
259 if (!callback->eventClusterEvent(hidl_struct).isOk()) {
260 LOG(ERROR) << "Failed to invoke the callback";
261 }
262 }
263 };
Etan Cohenc190f932017-02-17 13:06:55 -0800264
Roshan Piusabcf78f2017-10-06 16:30:38 -0700265 callback_handlers.on_event_disabled =
266 [weak_ptr_this](const legacy_hal::NanDisabledInd& msg) {
267 const auto shared_ptr_this = weak_ptr_this.promote();
268 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
269 LOG(ERROR) << "Callback invoked on an invalid object";
270 return;
271 }
272 WifiNanStatus status;
273 hidl_struct_util::convertToWifiNanStatus(
274 msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status);
Etan Cohenc190f932017-02-17 13:06:55 -0800275
Roshan Piusabcf78f2017-10-06 16:30:38 -0700276 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
277 if (!callback->eventDisabled(status).isOk()) {
278 LOG(ERROR) << "Failed to invoke the callback";
279 }
280 }
281 };
282
283 callback_handlers.on_event_publish_terminated =
284 [weak_ptr_this](const legacy_hal::NanPublishTerminatedInd& msg) {
285 const auto shared_ptr_this = weak_ptr_this.promote();
286 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
287 LOG(ERROR) << "Callback invoked on an invalid object";
288 return;
289 }
290 WifiNanStatus status;
291 hidl_struct_util::convertToWifiNanStatus(
292 msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status);
293
294 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
295 if (!callback->eventPublishTerminated(msg.publish_id, status)
296 .isOk()) {
297 LOG(ERROR) << "Failed to invoke the callback";
298 }
299 }
300 };
301
302 callback_handlers.on_event_subscribe_terminated =
303 [weak_ptr_this](const legacy_hal::NanSubscribeTerminatedInd& msg) {
304 const auto shared_ptr_this = weak_ptr_this.promote();
305 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
306 LOG(ERROR) << "Callback invoked on an invalid object";
307 return;
308 }
309 WifiNanStatus status;
310 hidl_struct_util::convertToWifiNanStatus(
311 msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status);
312
313 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
314 if (!callback
315 ->eventSubscribeTerminated(msg.subscribe_id, status)
316 .isOk()) {
317 LOG(ERROR) << "Failed to invoke the callback";
318 }
319 }
320 };
321
322 callback_handlers.on_event_match =
323 [weak_ptr_this](const legacy_hal::NanMatchInd& msg) {
324 const auto shared_ptr_this = weak_ptr_this.promote();
325 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
326 LOG(ERROR) << "Callback invoked on an invalid object";
327 return;
328 }
329 NanMatchInd hidl_struct;
330 if (!hidl_struct_util::convertLegacyNanMatchIndToHidl(
331 msg, &hidl_struct)) {
332 LOG(ERROR) << "Failed to convert nan capabilities response";
333 return;
334 }
335
336 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
337 if (!callback->eventMatch(hidl_struct).isOk()) {
338 LOG(ERROR) << "Failed to invoke the callback";
339 }
340 }
341 };
342
343 callback_handlers.on_event_match_expired =
344 [weak_ptr_this](const legacy_hal::NanMatchExpiredInd& msg) {
345 const auto shared_ptr_this = weak_ptr_this.promote();
346 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
347 LOG(ERROR) << "Callback invoked on an invalid object";
348 return;
349 }
350 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
351 if (!callback
352 ->eventMatchExpired(msg.publish_subscribe_id,
353 msg.requestor_instance_id)
354 .isOk()) {
355 LOG(ERROR) << "Failed to invoke the callback";
356 }
357 }
358 };
359
360 callback_handlers.on_event_followup =
361 [weak_ptr_this](const legacy_hal::NanFollowupInd& msg) {
362 const auto shared_ptr_this = weak_ptr_this.promote();
363 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
364 LOG(ERROR) << "Callback invoked on an invalid object";
365 return;
366 }
367 NanFollowupReceivedInd hidl_struct;
368 if (!hidl_struct_util::convertLegacyNanFollowupIndToHidl(
369 msg, &hidl_struct)) {
370 LOG(ERROR) << "Failed to convert nan capabilities response";
371 return;
372 }
373
374 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
375 if (!callback->eventFollowupReceived(hidl_struct).isOk()) {
376 LOG(ERROR) << "Failed to invoke the callback";
377 }
378 }
379 };
380
381 callback_handlers.on_event_transmit_follow_up =
382 [weak_ptr_this](const legacy_hal::NanTransmitFollowupInd& msg) {
383 const auto shared_ptr_this = weak_ptr_this.promote();
384 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
385 LOG(ERROR) << "Callback invoked on an invalid object";
386 return;
387 }
388 WifiNanStatus status;
389 hidl_struct_util::convertToWifiNanStatus(
390 msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status);
391
392 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
393 if (!callback->eventTransmitFollowup(msg.id, status).isOk()) {
394 LOG(ERROR) << "Failed to invoke the callback";
395 }
396 }
397 };
398
399 callback_handlers.on_event_data_path_request =
400 [weak_ptr_this](const legacy_hal::NanDataPathRequestInd& msg) {
401 const auto shared_ptr_this = weak_ptr_this.promote();
402 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
403 LOG(ERROR) << "Callback invoked on an invalid object";
404 return;
405 }
406 NanDataPathRequestInd hidl_struct;
407 if (!hidl_struct_util::convertLegacyNanDataPathRequestIndToHidl(
408 msg, &hidl_struct)) {
409 LOG(ERROR) << "Failed to convert nan capabilities response";
410 return;
411 }
412
413 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
414 if (!callback->eventDataPathRequest(hidl_struct).isOk()) {
415 LOG(ERROR) << "Failed to invoke the callback";
416 }
417 }
418 };
419
420 callback_handlers.on_event_data_path_confirm =
421 [weak_ptr_this](const legacy_hal::NanDataPathConfirmInd& msg) {
422 const auto shared_ptr_this = weak_ptr_this.promote();
423 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
424 LOG(ERROR) << "Callback invoked on an invalid object";
425 return;
426 }
Jong Wook Kimda830c92018-07-23 15:29:38 -0700427 V1_2::NanDataPathConfirmInd hidl_struct;
Roshan Piusabcf78f2017-10-06 16:30:38 -0700428 if (!hidl_struct_util::convertLegacyNanDataPathConfirmIndToHidl(
429 msg, &hidl_struct)) {
430 LOG(ERROR) << "Failed to convert nan capabilities response";
431 return;
432 }
433
Etan Cohen44a8bf92018-04-09 13:32:40 -0700434 for (const auto& callback :
435 shared_ptr_this->getEventCallbacks_1_2()) {
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800436 if (!callback->eventDataPathConfirm_1_2(hidl_struct).isOk()) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700437 LOG(ERROR) << "Failed to invoke the callback";
438 }
439 }
440 };
441
442 callback_handlers.on_event_data_path_end =
443 [weak_ptr_this](const legacy_hal::NanDataPathEndInd& msg) {
444 const auto shared_ptr_this = weak_ptr_this.promote();
445 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
446 LOG(ERROR) << "Callback invoked on an invalid object";
447 return;
448 }
449 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
450 for (int i = 0; i < msg.num_ndp_instances; ++i) {
451 if (!callback
452 ->eventDataPathTerminated(msg.ndp_instance_id[i])
453 .isOk()) {
454 LOG(ERROR) << "Failed to invoke the callback";
455 }
456 }
457 }
458 };
459
460 callback_handlers.on_event_beacon_sdf_payload =
461 [weak_ptr_this](const legacy_hal::NanBeaconSdfPayloadInd& /* msg */) {
462 LOG(ERROR) << "on_event_beacon_sdf_payload - should not be called";
463 };
464
465 callback_handlers.on_event_range_request =
466 [weak_ptr_this](const legacy_hal::NanRangeRequestInd& /* msg */) {
467 LOG(ERROR) << "on_event_range_request - should not be called";
468 };
469
470 callback_handlers.on_event_range_report =
471 [weak_ptr_this](const legacy_hal::NanRangeReportInd& /* msg */) {
472 LOG(ERROR) << "on_event_range_report - should not be called";
473 };
474
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800475 callback_handlers
476 .on_event_schedule_update = [weak_ptr_this](
477 const legacy_hal::
478 NanDataPathScheduleUpdateInd& msg) {
479 const auto shared_ptr_this = weak_ptr_this.promote();
480 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
481 LOG(ERROR) << "Callback invoked on an invalid object";
482 return;
483 }
Jong Wook Kimda830c92018-07-23 15:29:38 -0700484 V1_2::NanDataPathScheduleUpdateInd hidl_struct;
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800485 if (!hidl_struct_util::convertLegacyNanDataPathScheduleUpdateIndToHidl(
486 msg, &hidl_struct)) {
487 LOG(ERROR) << "Failed to convert nan capabilities response";
488 return;
489 }
490
Etan Cohen44a8bf92018-04-09 13:32:40 -0700491 for (const auto& callback : shared_ptr_this->getEventCallbacks_1_2()) {
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800492 if (!callback->eventDataPathScheduleUpdate(hidl_struct).isOk()) {
493 LOG(ERROR) << "Failed to invoke the callback";
494 }
495 }
496 };
Etan Cohen1bf15f12017-12-12 16:15:16 -0800497
Roshan Piusabcf78f2017-10-06 16:30:38 -0700498 legacy_hal::wifi_error legacy_status =
499 legacy_hal_.lock()->nanRegisterCallbackHandlers(ifname_,
500 callback_handlers);
501 if (legacy_status != legacy_hal::WIFI_SUCCESS) {
502 LOG(ERROR) << "Failed to register nan callbacks. Invalidating object";
503 invalidate();
504 }
Roshan Pius356d5a62019-05-17 15:07:34 -0700505
506 // Register for iface state toggle events.
507 iface_util::IfaceEventHandlers event_handlers = {};
508 event_handlers.on_state_toggle_off_on =
509 [weak_ptr_this](const std::string& /* iface_name */) {
510 const auto shared_ptr_this = weak_ptr_this.promote();
511 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
512 LOG(ERROR) << "Callback invoked on an invalid object";
513 return;
514 }
515 // Tell framework that NAN has been disabled.
516 WifiNanStatus status = {
517 NanStatusType::UNSUPPORTED_CONCURRENCY_NAN_DISABLED, ""};
518 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
519 if (!callback->eventDisabled(status).isOk()) {
520 LOG(ERROR) << "Failed to invoke the callback";
521 }
522 }
523 };
524 iface_util_.lock()->registerIfaceEventHandlers(ifname_, event_handlers);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800525}
Roshan Pius3e2d6712016-10-06 13:16:23 -0700526
527void WifiNanIface::invalidate() {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700528 // send commands to HAL to actually disable and destroy interfaces
529 legacy_hal_.lock()->nanDisableRequest(ifname_, 0xFFFF);
530 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFE, "aware_data0");
531 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFD, "aware_data1");
Roshan Pius356d5a62019-05-17 15:07:34 -0700532 iface_util_.lock()->unregisterIfaceEventHandlers(ifname_);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700533 legacy_hal_.reset();
534 event_cb_handler_.invalidate();
Etan Cohen44a8bf92018-04-09 13:32:40 -0700535 event_cb_handler_1_2_.invalidate();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700536 is_valid_ = false;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700537}
538
Roshan Piusabcf78f2017-10-06 16:30:38 -0700539bool WifiNanIface::isValid() { return is_valid_; }
Roshan Pius907d4a22016-10-27 12:48:12 -0700540
Roshan Pius675609b2017-10-31 14:24:58 -0700541std::string WifiNanIface::getName() { return ifname_; }
542
Etan Cohen44a8bf92018-04-09 13:32:40 -0700543std::set<sp<V1_0::IWifiNanIfaceEventCallback>>
544WifiNanIface::getEventCallbacks() {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700545 return event_cb_handler_.getCallbacks();
Roshan Piusd37341f2017-01-31 13:13:28 -0800546}
547
Etan Cohen44a8bf92018-04-09 13:32:40 -0700548std::set<sp<V1_2::IWifiNanIfaceEventCallback>>
549WifiNanIface::getEventCallbacks_1_2() {
550 return event_cb_handler_1_2_.getCallbacks();
551}
552
Roshan Pius734fea02016-10-11 08:30:28 -0700553Return<void> WifiNanIface::getName(getName_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700554 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
555 &WifiNanIface::getNameInternal, hidl_status_cb);
Roshan Pius3e2d6712016-10-06 13:16:23 -0700556}
557
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800558Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700559 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
560 &WifiNanIface::getTypeInternal, hidl_status_cb);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800561}
562
Roshan Pius0c92d442016-10-27 17:38:53 -0700563Return<void> WifiNanIface::registerEventCallback(
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800564 const sp<V1_0::IWifiNanIfaceEventCallback>& callback,
Roshan Pius0c92d442016-10-27 17:38:53 -0700565 registerEventCallback_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700566 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
567 &WifiNanIface::registerEventCallbackInternal,
568 hidl_status_cb, callback);
Roshan Pius0c92d442016-10-27 17:38:53 -0700569}
570
Roshan Piusabcf78f2017-10-06 16:30:38 -0700571Return<void> WifiNanIface::getCapabilitiesRequest(
572 uint16_t cmd_id, getCapabilitiesRequest_cb hidl_status_cb) {
573 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
574 &WifiNanIface::getCapabilitiesRequestInternal,
575 hidl_status_cb, cmd_id);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800576}
577
578Return<void> WifiNanIface::enableRequest(uint16_t cmd_id,
Roshan Pius0c92d442016-10-27 17:38:53 -0700579 const NanEnableRequest& msg,
580 enableRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700581 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
582 &WifiNanIface::enableRequestInternal, hidl_status_cb,
583 cmd_id, msg);
Roshan Pius0c92d442016-10-27 17:38:53 -0700584}
585
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800586Return<void> WifiNanIface::configRequest(uint16_t cmd_id,
Roshan Pius0c92d442016-10-27 17:38:53 -0700587 const NanConfigRequest& msg,
588 configRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700589 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
590 &WifiNanIface::configRequestInternal, hidl_status_cb,
591 cmd_id, msg);
Roshan Pius0c92d442016-10-27 17:38:53 -0700592}
593
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800594Return<void> WifiNanIface::disableRequest(uint16_t cmd_id,
595 disableRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700596 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
597 &WifiNanIface::disableRequestInternal,
598 hidl_status_cb, cmd_id);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800599}
600
Roshan Piusabcf78f2017-10-06 16:30:38 -0700601Return<void> WifiNanIface::startPublishRequest(
602 uint16_t cmd_id, const NanPublishRequest& msg,
603 startPublishRequest_cb hidl_status_cb) {
604 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
605 &WifiNanIface::startPublishRequestInternal,
606 hidl_status_cb, cmd_id, msg);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800607}
608
609Return<void> WifiNanIface::stopPublishRequest(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700610 uint16_t cmd_id, uint8_t sessionId, stopPublishRequest_cb hidl_status_cb) {
611 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
612 &WifiNanIface::stopPublishRequestInternal,
613 hidl_status_cb, cmd_id, sessionId);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800614}
615
616Return<void> WifiNanIface::startSubscribeRequest(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700617 uint16_t cmd_id, const NanSubscribeRequest& msg,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800618 startSubscribeRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700619 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
620 &WifiNanIface::startSubscribeRequestInternal,
621 hidl_status_cb, cmd_id, msg);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800622}
623
624Return<void> WifiNanIface::stopSubscribeRequest(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700625 uint16_t cmd_id, uint8_t sessionId,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800626 stopSubscribeRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700627 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
628 &WifiNanIface::stopSubscribeRequestInternal,
629 hidl_status_cb, cmd_id, sessionId);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800630}
631
632Return<void> WifiNanIface::transmitFollowupRequest(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700633 uint16_t cmd_id, const NanTransmitFollowupRequest& msg,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800634 transmitFollowupRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700635 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
636 &WifiNanIface::transmitFollowupRequestInternal,
637 hidl_status_cb, cmd_id, msg);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800638}
639
640Return<void> WifiNanIface::createDataInterfaceRequest(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700641 uint16_t cmd_id, const hidl_string& iface_name,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800642 createDataInterfaceRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700643 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
644 &WifiNanIface::createDataInterfaceRequestInternal,
645 hidl_status_cb, cmd_id, iface_name);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800646}
647
648Return<void> WifiNanIface::deleteDataInterfaceRequest(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700649 uint16_t cmd_id, const hidl_string& iface_name,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800650 deleteDataInterfaceRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700651 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
652 &WifiNanIface::deleteDataInterfaceRequestInternal,
653 hidl_status_cb, cmd_id, iface_name);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800654}
655
656Return<void> WifiNanIface::initiateDataPathRequest(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700657 uint16_t cmd_id, const NanInitiateDataPathRequest& msg,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800658 initiateDataPathRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700659 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
660 &WifiNanIface::initiateDataPathRequestInternal,
661 hidl_status_cb, cmd_id, msg);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800662}
663
664Return<void> WifiNanIface::respondToDataPathIndicationRequest(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700665 uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800666 respondToDataPathIndicationRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700667 return validateAndCall(
668 this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
669 &WifiNanIface::respondToDataPathIndicationRequestInternal,
670 hidl_status_cb, cmd_id, msg);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800671}
672
Roshan Piusabcf78f2017-10-06 16:30:38 -0700673Return<void> WifiNanIface::terminateDataPathRequest(
674 uint16_t cmd_id, uint32_t ndpInstanceId,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800675 terminateDataPathRequest_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700676 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
677 &WifiNanIface::terminateDataPathRequestInternal,
678 hidl_status_cb, cmd_id, ndpInstanceId);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800679}
680
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800681Return<void> WifiNanIface::registerEventCallback_1_2(
Jong Wook Kimda830c92018-07-23 15:29:38 -0700682 const sp<V1_2::IWifiNanIfaceEventCallback>& callback,
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800683 registerEventCallback_1_2_cb hidl_status_cb) {
684 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
685 &WifiNanIface::registerEventCallback_1_2Internal,
686 hidl_status_cb, callback);
687}
688
Etan Cohen9e7a4052017-12-21 13:45:26 -0800689Return<void> WifiNanIface::enableRequest_1_2(
690 uint16_t cmd_id, const NanEnableRequest& msg1,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700691 const V1_2::NanConfigRequestSupplemental& msg2,
Etan Cohen9e7a4052017-12-21 13:45:26 -0800692 enableRequest_1_2_cb hidl_status_cb) {
693 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
694 &WifiNanIface::enableRequest_1_2Internal,
695 hidl_status_cb, cmd_id, msg1, msg2);
696}
697
698Return<void> WifiNanIface::configRequest_1_2(
699 uint16_t cmd_id, const NanConfigRequest& msg1,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700700 const V1_2::NanConfigRequestSupplemental& msg2,
Etan Cohen9e7a4052017-12-21 13:45:26 -0800701 configRequest_1_2_cb hidl_status_cb) {
702 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
703 &WifiNanIface::configRequest_1_2Internal,
704 hidl_status_cb, cmd_id, msg1, msg2);
705}
706
Roshan Pius907d4a22016-10-27 12:48:12 -0700707std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700708 return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
Roshan Pius907d4a22016-10-27 12:48:12 -0700709}
710
711std::pair<WifiStatus, IfaceType> WifiNanIface::getTypeInternal() {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700712 return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN};
Roshan Pius3e2d6712016-10-06 13:16:23 -0700713}
714
Roshan Pius0c92d442016-10-27 17:38:53 -0700715WifiStatus WifiNanIface::registerEventCallbackInternal(
Etan Cohen44a8bf92018-04-09 13:32:40 -0700716 const sp<V1_0::IWifiNanIfaceEventCallback>& callback) {
717 if (!event_cb_handler_.addCallback(callback)) {
718 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
719 }
720 return createWifiStatus(WifiStatusCode::SUCCESS);
Roshan Pius0c92d442016-10-27 17:38:53 -0700721}
722
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800723WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t cmd_id) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700724 legacy_hal::wifi_error legacy_status =
Roshan Piusacededb2017-10-06 14:59:26 -0700725 legacy_hal_.lock()->nanGetCapabilities(ifname_, cmd_id);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700726 return createWifiStatusFromLegacyError(legacy_status);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800727}
728
Etan Cohen9e7a4052017-12-21 13:45:26 -0800729WifiStatus WifiNanIface::enableRequestInternal(
730 uint16_t /* cmd_id */, const NanEnableRequest& /* msg */) {
731 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
Roshan Pius0c92d442016-10-27 17:38:53 -0700732}
733
Etan Cohen9e7a4052017-12-21 13:45:26 -0800734WifiStatus WifiNanIface::configRequestInternal(
735 uint16_t /* cmd_id */, const NanConfigRequest& /* msg */) {
736 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800737}
738
739WifiStatus WifiNanIface::disableRequestInternal(uint16_t cmd_id) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700740 legacy_hal::wifi_error legacy_status =
741 legacy_hal_.lock()->nanDisableRequest(ifname_, cmd_id);
742 return createWifiStatusFromLegacyError(legacy_status);
Roshan Pius0c92d442016-10-27 17:38:53 -0700743}
744
Roshan Piusacededb2017-10-06 14:59:26 -0700745WifiStatus WifiNanIface::startPublishRequestInternal(
746 uint16_t cmd_id, const NanPublishRequest& msg) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700747 legacy_hal::NanPublishRequest legacy_msg;
748 if (!hidl_struct_util::convertHidlNanPublishRequestToLegacy(msg,
749 &legacy_msg)) {
750 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
751 }
752 legacy_hal::wifi_error legacy_status =
753 legacy_hal_.lock()->nanPublishRequest(ifname_, cmd_id, legacy_msg);
754 return createWifiStatusFromLegacyError(legacy_status);
Roshan Pius0c92d442016-10-27 17:38:53 -0700755}
756
Roshan Piusabcf78f2017-10-06 16:30:38 -0700757WifiStatus WifiNanIface::stopPublishRequestInternal(uint16_t cmd_id,
758 uint8_t sessionId) {
759 legacy_hal::NanPublishCancelRequest legacy_msg;
760 legacy_msg.publish_id = sessionId;
761 legacy_hal::wifi_error legacy_status =
762 legacy_hal_.lock()->nanPublishCancelRequest(ifname_, cmd_id,
763 legacy_msg);
764 return createWifiStatusFromLegacyError(legacy_status);
Roshan Pius0c92d442016-10-27 17:38:53 -0700765}
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800766
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800767WifiStatus WifiNanIface::startSubscribeRequestInternal(
768 uint16_t cmd_id, const NanSubscribeRequest& msg) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700769 legacy_hal::NanSubscribeRequest legacy_msg;
770 if (!hidl_struct_util::convertHidlNanSubscribeRequestToLegacy(
771 msg, &legacy_msg)) {
772 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
773 }
774 legacy_hal::wifi_error legacy_status =
775 legacy_hal_.lock()->nanSubscribeRequest(ifname_, cmd_id, legacy_msg);
776 return createWifiStatusFromLegacyError(legacy_status);
Roshan Pius0c92d442016-10-27 17:38:53 -0700777}
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800778
Roshan Piusabcf78f2017-10-06 16:30:38 -0700779WifiStatus WifiNanIface::stopSubscribeRequestInternal(uint16_t cmd_id,
780 uint8_t sessionId) {
781 legacy_hal::NanSubscribeCancelRequest legacy_msg;
782 legacy_msg.subscribe_id = sessionId;
783 legacy_hal::wifi_error legacy_status =
784 legacy_hal_.lock()->nanSubscribeCancelRequest(ifname_, cmd_id,
785 legacy_msg);
786 return createWifiStatusFromLegacyError(legacy_status);
Roshan Pius0c92d442016-10-27 17:38:53 -0700787}
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800788
Roshan Pius0c92d442016-10-27 17:38:53 -0700789WifiStatus WifiNanIface::transmitFollowupRequestInternal(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800790 uint16_t cmd_id, const NanTransmitFollowupRequest& msg) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700791 legacy_hal::NanTransmitFollowupRequest legacy_msg;
792 if (!hidl_struct_util::convertHidlNanTransmitFollowupRequestToLegacy(
793 msg, &legacy_msg)) {
794 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
795 }
796 legacy_hal::wifi_error legacy_status =
797 legacy_hal_.lock()->nanTransmitFollowupRequest(ifname_, cmd_id,
798 legacy_msg);
799 return createWifiStatusFromLegacyError(legacy_status);
Roshan Pius0c92d442016-10-27 17:38:53 -0700800}
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800801
802WifiStatus WifiNanIface::createDataInterfaceRequestInternal(
803 uint16_t cmd_id, const std::string& iface_name) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700804 legacy_hal::wifi_error legacy_status =
805 legacy_hal_.lock()->nanDataInterfaceCreate(ifname_, cmd_id, iface_name);
806 return createWifiStatusFromLegacyError(legacy_status);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800807}
808WifiStatus WifiNanIface::deleteDataInterfaceRequestInternal(
809 uint16_t cmd_id, const std::string& iface_name) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700810 legacy_hal::wifi_error legacy_status =
811 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, cmd_id, iface_name);
812 return createWifiStatusFromLegacyError(legacy_status);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800813}
814WifiStatus WifiNanIface::initiateDataPathRequestInternal(
815 uint16_t cmd_id, const NanInitiateDataPathRequest& msg) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700816 legacy_hal::NanDataPathInitiatorRequest legacy_msg;
817 if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequestToLegacy(
818 msg, &legacy_msg)) {
819 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
820 }
821 legacy_hal::wifi_error legacy_status =
822 legacy_hal_.lock()->nanDataRequestInitiator(ifname_, cmd_id,
823 legacy_msg);
824 return createWifiStatusFromLegacyError(legacy_status);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800825}
826WifiStatus WifiNanIface::respondToDataPathIndicationRequestInternal(
827 uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700828 legacy_hal::NanDataPathIndicationResponse legacy_msg;
829 if (!hidl_struct_util::convertHidlNanDataPathIndicationResponseToLegacy(
830 msg, &legacy_msg)) {
831 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
832 }
833 legacy_hal::wifi_error legacy_status =
834 legacy_hal_.lock()->nanDataIndicationResponse(ifname_, cmd_id,
835 legacy_msg);
836 return createWifiStatusFromLegacyError(legacy_status);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800837}
838WifiStatus WifiNanIface::terminateDataPathRequestInternal(
839 uint16_t cmd_id, uint32_t ndpInstanceId) {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700840 legacy_hal::wifi_error legacy_status =
841 legacy_hal_.lock()->nanDataEnd(ifname_, cmd_id, ndpInstanceId);
842 return createWifiStatusFromLegacyError(legacy_status);
Roshan Pius0c92d442016-10-27 17:38:53 -0700843}
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800844
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800845WifiStatus WifiNanIface::registerEventCallback_1_2Internal(
Etan Cohen44a8bf92018-04-09 13:32:40 -0700846 const sp<V1_2::IWifiNanIfaceEventCallback>& callback) {
847 sp<V1_0::IWifiNanIfaceEventCallback> callback_1_0 = callback;
848 if (!event_cb_handler_.addCallback(callback_1_0)) {
849 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
850 }
851 if (!event_cb_handler_1_2_.addCallback(callback)) {
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800852 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
853 }
854 return createWifiStatus(WifiStatusCode::SUCCESS);
855}
856
Etan Cohen9e7a4052017-12-21 13:45:26 -0800857WifiStatus WifiNanIface::enableRequest_1_2Internal(
858 uint16_t cmd_id, const NanEnableRequest& msg1,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700859 const V1_2::NanConfigRequestSupplemental& msg2) {
Etan Cohen9e7a4052017-12-21 13:45:26 -0800860 legacy_hal::NanEnableRequest legacy_msg;
861 if (!hidl_struct_util::convertHidlNanEnableRequest_1_2ToLegacy(
862 msg1, msg2, &legacy_msg)) {
863 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
864 }
865 legacy_hal::wifi_error legacy_status =
866 legacy_hal_.lock()->nanEnableRequest(ifname_, cmd_id, legacy_msg);
867 return createWifiStatusFromLegacyError(legacy_status);
868}
869
870WifiStatus WifiNanIface::configRequest_1_2Internal(
871 uint16_t cmd_id, const NanConfigRequest& msg1,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700872 const V1_2::NanConfigRequestSupplemental& msg2) {
Etan Cohen9e7a4052017-12-21 13:45:26 -0800873 legacy_hal::NanConfigRequest legacy_msg;
874 if (!hidl_struct_util::convertHidlNanConfigRequest_1_2ToLegacy(
875 msg1, msg2, &legacy_msg)) {
876 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
877 }
878 legacy_hal::wifi_error legacy_status =
879 legacy_hal_.lock()->nanConfigRequest(ifname_, cmd_id, legacy_msg);
880 return createWifiStatusFromLegacyError(legacy_status);
881}
882
Roshan Pius3e2d6712016-10-06 13:16:23 -0700883} // namespace implementation
Jong Wook Kimda830c92018-07-23 15:29:38 -0700884} // namespace V1_3
Roshan Pius3e2d6712016-10-06 13:16:23 -0700885} // namespace wifi
886} // namespace hardware
887} // namespace android