1 /*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Nanache 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 <android-base/logging.h>
18
19 #include <VtsCoreUtil.h>
20 #include <android/hardware/wifi/1.5/IWifi.h>
21 #include <android/hardware/wifi/1.5/IWifiNanIface.h>
22 #include <android/hardware/wifi/1.5/IWifiNanIfaceEventCallback.h>
23 #include <android/hardware/wifi/1.6/IWifiNanIface.h>
24 #include <gtest/gtest.h>
25 #include <hidl/GtestPrinter.h>
26 #include <hidl/ServiceManagement.h>
27 #include <chrono>
28 #include <condition_variable>
29 #include <mutex>
30
31 #include "wifi_hidl_call_util.h"
32 #include "wifi_hidl_test_utils.h"
33
34 using namespace ::android::hardware::wifi::V1_0;
35 using namespace ::android::hardware::wifi::V1_2;
36 using namespace ::android::hardware::wifi::V1_4;
37 using namespace ::android::hardware::wifi::V1_5;
38 using ::android::sp;
39 using ::android::hardware::Return;
40 using ::android::hardware::Void;
41
42 #define TIMEOUT_PERIOD 10
43
getWifiNanIface_1_5(const std::string & instance_name)44 android::sp<android::hardware::wifi::V1_5::IWifiNanIface> getWifiNanIface_1_5(
45 const std::string& instance_name) {
46 return android::hardware::wifi::V1_5::IWifiNanIface::castFrom(
47 getWifiNanIface(instance_name));
48 }
49
50 /**
51 * Fixture to use for all NAN Iface HIDL interface tests.
52 */
53 class WifiNanIfaceHidlTest : public ::testing::TestWithParam<std::string> {
54 public:
SetUp()55 virtual void SetUp() override {
56 if (!::testing::deviceSupportsFeature("android.hardware.wifi.aware"))
57 GTEST_SKIP() << "Skipping this test since NAN is not supported.";
58 // Make sure to start with a clean state
59 stopWifi(GetInstanceName());
60
61 iwifiNanIface = getWifiNanIface_1_5(GetInstanceName());
62 ASSERT_NE(nullptr, iwifiNanIface.get());
63 ASSERT_EQ(WifiStatusCode::SUCCESS,
64 HIDL_INVOKE(iwifiNanIface, registerEventCallback_1_5,
65 new WifiNanIfaceEventCallback(*this))
66 .code);
67 }
68
TearDown()69 virtual void TearDown() override { stopWifi(GetInstanceName()); }
70
71 /* Used as a mechanism to inform the test about data/event callback */
notify()72 inline void notify() {
73 std::unique_lock<std::mutex> lock(mtx_);
74 count_++;
75 cv_.notify_one();
76 }
77
78 enum CallbackType {
79 INVALID = -2,
80 ANY_CALLBACK = -1,
81
82 NOTIFY_CAPABILITIES_RESPONSE = 0,
83 NOTIFY_ENABLE_RESPONSE,
84 NOTIFY_CONFIG_RESPONSE,
85 NOTIFY_DISABLE_RESPONSE,
86 NOTIFY_START_PUBLISH_RESPONSE,
87 NOTIFY_STOP_PUBLISH_RESPONSE,
88 NOTIFY_START_SUBSCRIBE_RESPONSE,
89 NOTIFY_STOP_SUBSCRIBE_RESPONSE,
90 NOTIFY_TRANSMIT_FOLLOWUP_RESPONSE,
91 NOTIFY_CREATE_DATA_INTERFACE_RESPONSE,
92 NOTIFY_DELETE_DATA_INTERFACE_RESPONSE,
93 NOTIFY_INITIATE_DATA_PATH_RESPONSE,
94 NOTIFY_RESPOND_TO_DATA_PATH_INDICATION_RESPONSE,
95 NOTIFY_TERMINATE_DATA_PATH_RESPONSE,
96 NOTIFY_CAPABILITIES_RESPONSE_1_5,
97
98 EVENT_CLUSTER_EVENT,
99 EVENT_DISABLED,
100 EVENT_PUBLISH_TERMINATED,
101 EVENT_SUBSCRIBE_TERMINATED,
102 EVENT_MATCH,
103 EVENT_MATCH_EXPIRED,
104 EVENT_FOLLOWUP_RECEIVED,
105 EVENT_TRANSMIT_FOLLOWUP,
106 EVENT_DATA_PATH_REQUEST,
107 EVENT_DATA_PATH_CONFIRM,
108 EVENT_DATA_PATH_TERMINATED,
109 EVENT_DATA_PATH_CONFIRM_1_2,
110 EVENT_DATA_PATH_SCHEDULE_UPDATE
111 };
112
113 /* Test code calls this function to wait for data/event callback */
114 /* Must set callbackType = INVALID before call this function */
wait(CallbackType waitForCallbackType)115 inline std::cv_status wait(CallbackType waitForCallbackType) {
116 std::unique_lock<std::mutex> lock(mtx_);
117
118 EXPECT_NE(INVALID, waitForCallbackType); // can't ASSERT in a
119 // non-void-returning method
120
121 std::cv_status status = std::cv_status::no_timeout;
122 auto now = std::chrono::system_clock::now();
123 while (count_ == 0) {
124 status = cv_.wait_until(lock,
125 now + std::chrono::seconds(TIMEOUT_PERIOD));
126 if (status == std::cv_status::timeout) return status;
127 if (waitForCallbackType != ANY_CALLBACK &&
128 callbackType != INVALID &&
129 callbackType != waitForCallbackType) {
130 count_--;
131 }
132 }
133 count_--;
134 return status;
135 }
136
137 class WifiNanIfaceEventCallback
138 : public ::android::hardware::wifi::V1_5::IWifiNanIfaceEventCallback {
139 WifiNanIfaceHidlTest& parent_;
140
141 public:
WifiNanIfaceEventCallback(WifiNanIfaceHidlTest & parent)142 WifiNanIfaceEventCallback(WifiNanIfaceHidlTest& parent)
143 : parent_(parent){};
144
145 virtual ~WifiNanIfaceEventCallback() = default;
146
notifyCapabilitiesResponse(uint16_t id,const WifiNanStatus & status,const::android::hardware::wifi::V1_0::NanCapabilities & capabilities)147 Return<void> notifyCapabilitiesResponse(
148 uint16_t id, const WifiNanStatus& status,
149 const ::android::hardware::wifi::V1_0::NanCapabilities&
150 capabilities) override {
151 parent_.callbackType = NOTIFY_CAPABILITIES_RESPONSE;
152
153 parent_.id = id;
154 parent_.status = status;
155 parent_.capabilities = capabilities;
156
157 parent_.notify();
158 return Void();
159 }
160
notifyCapabilitiesResponse_1_5(uint16_t id,const WifiNanStatus & status,const::android::hardware::wifi::V1_5::NanCapabilities & capabilities)161 Return<void> notifyCapabilitiesResponse_1_5(
162 uint16_t id, const WifiNanStatus& status,
163 const ::android::hardware::wifi::V1_5::NanCapabilities&
164 capabilities) override {
165 parent_.callbackType = NOTIFY_CAPABILITIES_RESPONSE_1_5;
166
167 parent_.id = id;
168 parent_.status = status;
169 parent_.capabilities_1_5 = capabilities;
170
171 parent_.notify();
172 return Void();
173 }
174
notifyEnableResponse(uint16_t id,const WifiNanStatus & status)175 Return<void> notifyEnableResponse(
176 uint16_t id, const WifiNanStatus& status) override {
177 parent_.callbackType = NOTIFY_ENABLE_RESPONSE;
178
179 parent_.id = id;
180 parent_.status = status;
181
182 parent_.notify();
183 return Void();
184 }
185
notifyConfigResponse(uint16_t id,const WifiNanStatus & status)186 Return<void> notifyConfigResponse(
187 uint16_t id, const WifiNanStatus& status) override {
188 parent_.callbackType = NOTIFY_CONFIG_RESPONSE;
189
190 parent_.id = id;
191 parent_.status = status;
192
193 parent_.notify();
194 return Void();
195 }
196
notifyDisableResponse(uint16_t id,const WifiNanStatus & status)197 Return<void> notifyDisableResponse(
198 uint16_t id, const WifiNanStatus& status) override {
199 parent_.callbackType = NOTIFY_DISABLE_RESPONSE;
200
201 parent_.id = id;
202 parent_.status = status;
203
204 parent_.notify();
205 return Void();
206 }
207
notifyStartPublishResponse(uint16_t id,const WifiNanStatus & status,uint8_t sessionId)208 Return<void> notifyStartPublishResponse(uint16_t id,
209 const WifiNanStatus& status,
210 uint8_t sessionId) override {
211 parent_.callbackType = NOTIFY_START_PUBLISH_RESPONSE;
212
213 parent_.id = id;
214 parent_.status = status;
215 parent_.sessionId = sessionId;
216
217 parent_.notify();
218 return Void();
219 }
220
notifyStopPublishResponse(uint16_t id,const WifiNanStatus & status)221 Return<void> notifyStopPublishResponse(
222 uint16_t id, const WifiNanStatus& status) override {
223 parent_.callbackType = NOTIFY_STOP_PUBLISH_RESPONSE;
224
225 parent_.id = id;
226 parent_.status = status;
227
228 parent_.notify();
229 return Void();
230 }
231
notifyStartSubscribeResponse(uint16_t id,const WifiNanStatus & status,uint8_t sessionId)232 Return<void> notifyStartSubscribeResponse(uint16_t id,
233 const WifiNanStatus& status,
234 uint8_t sessionId) override {
235 parent_.callbackType = NOTIFY_START_SUBSCRIBE_RESPONSE;
236
237 parent_.id = id;
238 parent_.status = status;
239 parent_.sessionId = sessionId;
240
241 parent_.notify();
242 return Void();
243 }
244
notifyStopSubscribeResponse(uint16_t id,const WifiNanStatus & status)245 Return<void> notifyStopSubscribeResponse(
246 uint16_t id, const WifiNanStatus& status) override {
247 parent_.callbackType = NOTIFY_STOP_SUBSCRIBE_RESPONSE;
248
249 parent_.id = id;
250 parent_.status = status;
251
252 parent_.notify();
253 return Void();
254 }
255
notifyTransmitFollowupResponse(uint16_t id,const WifiNanStatus & status)256 Return<void> notifyTransmitFollowupResponse(
257 uint16_t id, const WifiNanStatus& status) override {
258 parent_.callbackType = NOTIFY_TRANSMIT_FOLLOWUP_RESPONSE;
259
260 parent_.id = id;
261 parent_.status = status;
262
263 parent_.notify();
264 return Void();
265 }
266
notifyCreateDataInterfaceResponse(uint16_t id,const WifiNanStatus & status)267 Return<void> notifyCreateDataInterfaceResponse(
268 uint16_t id, const WifiNanStatus& status) override {
269 parent_.callbackType = NOTIFY_CREATE_DATA_INTERFACE_RESPONSE;
270
271 parent_.id = id;
272 parent_.status = status;
273
274 parent_.notify();
275 return Void();
276 }
277
notifyDeleteDataInterfaceResponse(uint16_t id,const WifiNanStatus & status)278 Return<void> notifyDeleteDataInterfaceResponse(
279 uint16_t id, const WifiNanStatus& status) override {
280 parent_.callbackType = NOTIFY_DELETE_DATA_INTERFACE_RESPONSE;
281
282 parent_.id = id;
283 parent_.status = status;
284
285 parent_.notify();
286 return Void();
287 }
288
notifyInitiateDataPathResponse(uint16_t id,const WifiNanStatus & status,uint32_t ndpInstanceId)289 Return<void> notifyInitiateDataPathResponse(
290 uint16_t id, const WifiNanStatus& status,
291 uint32_t ndpInstanceId) override {
292 parent_.callbackType = NOTIFY_INITIATE_DATA_PATH_RESPONSE;
293
294 parent_.id = id;
295 parent_.status = status;
296 parent_.ndpInstanceId = ndpInstanceId;
297
298 parent_.notify();
299 return Void();
300 }
301
notifyRespondToDataPathIndicationResponse(uint16_t id,const WifiNanStatus & status)302 Return<void> notifyRespondToDataPathIndicationResponse(
303 uint16_t id, const WifiNanStatus& status) override {
304 parent_.callbackType =
305 NOTIFY_RESPOND_TO_DATA_PATH_INDICATION_RESPONSE;
306
307 parent_.id = id;
308 parent_.status = status;
309
310 parent_.notify();
311 return Void();
312 }
313
notifyTerminateDataPathResponse(uint16_t id,const WifiNanStatus & status)314 Return<void> notifyTerminateDataPathResponse(
315 uint16_t id, const WifiNanStatus& status) override {
316 parent_.callbackType = NOTIFY_TERMINATE_DATA_PATH_RESPONSE;
317
318 parent_.id = id;
319 parent_.status = status;
320
321 parent_.notify();
322 return Void();
323 }
324
eventClusterEvent(const NanClusterEventInd & event)325 Return<void> eventClusterEvent(
326 const NanClusterEventInd& event) override {
327 parent_.callbackType = EVENT_CLUSTER_EVENT;
328
329 parent_.nanClusterEventInd = event;
330
331 parent_.notify();
332 return Void();
333 }
334
eventDisabled(const WifiNanStatus & status)335 Return<void> eventDisabled(const WifiNanStatus& status) override {
336 parent_.callbackType = EVENT_DISABLED;
337
338 parent_.status = status;
339
340 parent_.notify();
341 return Void();
342 }
343
eventPublishTerminated(uint8_t sessionId,const WifiNanStatus & status)344 Return<void> eventPublishTerminated(
345 uint8_t sessionId, const WifiNanStatus& status) override {
346 parent_.callbackType = EVENT_PUBLISH_TERMINATED;
347
348 parent_.sessionId = sessionId;
349 parent_.status = status;
350
351 parent_.notify();
352 return Void();
353 }
354
eventSubscribeTerminated(uint8_t sessionId,const WifiNanStatus & status)355 Return<void> eventSubscribeTerminated(
356 uint8_t sessionId, const WifiNanStatus& status) override {
357 parent_.callbackType = EVENT_SUBSCRIBE_TERMINATED;
358
359 parent_.sessionId = sessionId;
360 parent_.status = status;
361
362 parent_.notify();
363 return Void();
364 }
365
eventMatch(const NanMatchInd & event)366 Return<void> eventMatch(const NanMatchInd& event) override {
367 parent_.callbackType = EVENT_MATCH;
368
369 parent_.nanMatchInd = event;
370
371 parent_.notify();
372 return Void();
373 }
374
eventMatchExpired(uint8_t discoverySessionId,uint32_t peerId)375 Return<void> eventMatchExpired(uint8_t discoverySessionId,
376 uint32_t peerId) override {
377 parent_.callbackType = EVENT_MATCH_EXPIRED;
378
379 parent_.sessionId = discoverySessionId;
380 parent_.peerId = peerId;
381
382 parent_.notify();
383 return Void();
384 }
385
eventFollowupReceived(const NanFollowupReceivedInd & event)386 Return<void> eventFollowupReceived(
387 const NanFollowupReceivedInd& event) override {
388 parent_.callbackType = EVENT_FOLLOWUP_RECEIVED;
389
390 parent_.nanFollowupReceivedInd = event;
391
392 parent_.notify();
393 return Void();
394 }
395
eventTransmitFollowup(uint16_t id,const WifiNanStatus & status)396 Return<void> eventTransmitFollowup(
397 uint16_t id, const WifiNanStatus& status) override {
398 parent_.callbackType = EVENT_TRANSMIT_FOLLOWUP;
399
400 parent_.id = id;
401 parent_.status = status;
402
403 parent_.notify();
404 return Void();
405 }
406
eventDataPathRequest(const NanDataPathRequestInd & event)407 Return<void> eventDataPathRequest(
408 const NanDataPathRequestInd& event) override {
409 parent_.callbackType = EVENT_DATA_PATH_REQUEST;
410
411 parent_.nanDataPathRequestInd = event;
412
413 parent_.notify();
414 return Void();
415 }
416
eventDataPathConfirm(const::android::hardware::wifi::V1_0::NanDataPathConfirmInd & event)417 Return<void> eventDataPathConfirm(
418 const ::android::hardware::wifi::V1_0::NanDataPathConfirmInd& event)
419 override {
420 parent_.callbackType = EVENT_DATA_PATH_CONFIRM;
421
422 parent_.nanDataPathConfirmInd = event;
423
424 parent_.notify();
425 return Void();
426 }
427
eventDataPathTerminated(uint32_t ndpInstanceId)428 Return<void> eventDataPathTerminated(uint32_t ndpInstanceId) override {
429 parent_.callbackType = EVENT_DATA_PATH_TERMINATED;
430
431 parent_.ndpInstanceId = ndpInstanceId;
432
433 parent_.notify();
434 return Void();
435 }
436
eventDataPathConfirm_1_2(const::android::hardware::wifi::V1_2::NanDataPathConfirmInd & event)437 Return<void> eventDataPathConfirm_1_2(
438 const ::android::hardware::wifi::V1_2::NanDataPathConfirmInd& event)
439 override {
440 parent_.callbackType = EVENT_DATA_PATH_CONFIRM_1_2;
441
442 parent_.nanDataPathConfirmInd_1_2 = event;
443
444 parent_.notify();
445 return Void();
446 }
447
eventDataPathScheduleUpdate(const NanDataPathScheduleUpdateInd & event)448 Return<void> eventDataPathScheduleUpdate(
449 const NanDataPathScheduleUpdateInd& event) override {
450 parent_.callbackType = EVENT_DATA_PATH_SCHEDULE_UPDATE;
451
452 parent_.nanDataPathScheduleUpdateInd = event;
453
454 parent_.notify();
455 return Void();
456 }
457 };
458
459 private:
460 // synchronization objects
461 std::mutex mtx_;
462 std::condition_variable cv_;
463 int count_ = 0;
464
465 protected:
466 android::sp<::android::hardware::wifi::V1_5::IWifiNanIface> iwifiNanIface;
467
468 // Data from IWifiNanIfaceEventCallback callbacks: this is the collection of
469 // all arguments to all callbacks. They are set by the callback
470 // (notifications or events) and can be retrieved by tests.
471 CallbackType callbackType;
472 uint16_t id;
473 WifiNanStatus status;
474 uint8_t sessionId;
475 uint32_t ndpInstanceId;
476 NanClusterEventInd nanClusterEventInd;
477 NanMatchInd nanMatchInd;
478 uint32_t peerId;
479 NanFollowupReceivedInd nanFollowupReceivedInd;
480 NanDataPathRequestInd nanDataPathRequestInd;
481 ::android::hardware::wifi::V1_0::NanCapabilities capabilities;
482 ::android::hardware::wifi::V1_5::NanCapabilities capabilities_1_5;
483 ::android::hardware::wifi::V1_0::NanDataPathConfirmInd
484 nanDataPathConfirmInd;
485 ::android::hardware::wifi::V1_2::NanDataPathConfirmInd
486 nanDataPathConfirmInd_1_2;
487 NanDataPathScheduleUpdateInd nanDataPathScheduleUpdateInd;
488
GetInstanceName()489 std::string GetInstanceName() { return GetParam(); }
490 };
491
492 /*
493 * Create:
494 * Ensures that an instance of the IWifiNanIface proxy object is
495 * successfully created.
496 */
TEST_P(WifiNanIfaceHidlTest,Create)497 TEST_P(WifiNanIfaceHidlTest, Create) {
498 // The creation of a proxy object is tested as part of SetUp method.
499 }
500
501 /*
502 * enableRequest_1_5InvalidArgs: validate that fails with invalid arguments
503 */
TEST_P(WifiNanIfaceHidlTest,enableRequest_1_5InvalidArgs)504 TEST_P(WifiNanIfaceHidlTest, enableRequest_1_5InvalidArgs) {
505 uint16_t inputCmdId = 10;
506 callbackType = INVALID;
507 ::android::hardware::wifi::V1_4::NanEnableRequest nanEnableRequest = {};
508 ::android::hardware::wifi::V1_5::NanConfigRequestSupplemental
509 nanConfigRequestSupp = {};
510 const auto& halStatus =
511 HIDL_INVOKE(iwifiNanIface, enableRequest_1_5, inputCmdId,
512 nanEnableRequest, nanConfigRequestSupp);
513 if (halStatus.code != WifiStatusCode::ERROR_NOT_SUPPORTED) {
514 ASSERT_EQ(WifiStatusCode::SUCCESS, halStatus.code);
515
516 // wait for a callback
517 ASSERT_EQ(std::cv_status::no_timeout, wait(NOTIFY_ENABLE_RESPONSE));
518 ASSERT_EQ(NOTIFY_ENABLE_RESPONSE, callbackType);
519 ASSERT_EQ(id, inputCmdId);
520 ASSERT_EQ(status.status, NanStatusType::INVALID_ARGS);
521 }
522 }
523
524 /*
525 * enableRequest_1_5ShimInvalidArgs: validate that fails with invalid arguments
526 * to the shim
527 */
TEST_P(WifiNanIfaceHidlTest,enableRequest_1_5ShimInvalidArgs)528 TEST_P(WifiNanIfaceHidlTest, enableRequest_1_5ShimInvalidArgs) {
529 uint16_t inputCmdId = 10;
530 ::android::hardware::wifi::V1_4::NanEnableRequest nanEnableRequest = {};
531 nanEnableRequest.configParams.numberOfPublishServiceIdsInBeacon =
532 128; // must be <= 127
533 ::android::hardware::wifi::V1_5::NanConfigRequestSupplemental
534 nanConfigRequestSupp = {};
535 const auto& halStatus =
536 HIDL_INVOKE(iwifiNanIface, enableRequest_1_5, inputCmdId,
537 nanEnableRequest, nanConfigRequestSupp);
538 if (halStatus.code != WifiStatusCode::ERROR_NOT_SUPPORTED) {
539 ASSERT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, halStatus.code);
540 }
541 }
542
543 /*
544 * configRequest_1_5InvalidArgs: validate that fails with invalid arguments
545 */
TEST_P(WifiNanIfaceHidlTest,configRequest_1_5InvalidArgs)546 TEST_P(WifiNanIfaceHidlTest, configRequest_1_5InvalidArgs) {
547 uint16_t inputCmdId = 10;
548 callbackType = INVALID;
549 ::android::hardware::wifi::V1_4::NanConfigRequest nanConfigRequest = {};
550 ::android::hardware::wifi::V1_5::NanConfigRequestSupplemental
551 nanConfigRequestSupp = {};
552 const auto& halStatus =
553 HIDL_INVOKE(iwifiNanIface, configRequest_1_5, inputCmdId,
554 nanConfigRequest, nanConfigRequestSupp);
555
556 if (halStatus.code != WifiStatusCode::ERROR_NOT_SUPPORTED) {
557 ASSERT_EQ(WifiStatusCode::SUCCESS, halStatus.code);
558
559 // wait for a callback
560 ASSERT_EQ(std::cv_status::no_timeout, wait(NOTIFY_CONFIG_RESPONSE));
561 ASSERT_EQ(NOTIFY_CONFIG_RESPONSE, callbackType);
562 ASSERT_EQ(id, inputCmdId);
563 ASSERT_EQ(status.status, NanStatusType::INVALID_ARGS);
564 }
565 }
566
567 /*
568 * configRequest_1_5ShimInvalidArgs: validate that fails with invalid arguments
569 * to the shim
570 */
TEST_P(WifiNanIfaceHidlTest,configRequest_1_5ShimInvalidArgs)571 TEST_P(WifiNanIfaceHidlTest, configRequest_1_5ShimInvalidArgs) {
572 uint16_t inputCmdId = 10;
573 ::android::hardware::wifi::V1_4::NanConfigRequest nanConfigRequest = {};
574 nanConfigRequest.numberOfPublishServiceIdsInBeacon = 128; // must be <= 127
575 ::android::hardware::wifi::V1_5::NanConfigRequestSupplemental
576 nanConfigRequestSupp = {};
577 const auto& halStatus =
578 HIDL_INVOKE(iwifiNanIface, configRequest_1_5, inputCmdId,
579 nanConfigRequest, nanConfigRequestSupp);
580 if (halStatus.code != WifiStatusCode::ERROR_NOT_SUPPORTED) {
581 ASSERT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, halStatus.code);
582 }
583 }
584
585 /*
586 * getCapabilitiesRequest: validate that returns capabilities.
587 */
TEST_P(WifiNanIfaceHidlTest,getCapabilitiesRequest_1_5)588 TEST_P(WifiNanIfaceHidlTest, getCapabilitiesRequest_1_5) {
589 sp<::android::hardware::wifi::V1_6::IWifiNanIface> iface_converted =
590 ::android::hardware::wifi::V1_6::IWifiNanIface::castFrom(iwifiNanIface);
591 if (iface_converted != nullptr) {
592 return;
593 }
594 uint16_t inputCmdId = 10;
595 callbackType = INVALID;
596 const auto& halStatus =
597 HIDL_INVOKE(iwifiNanIface, getCapabilitiesRequest_1_5, inputCmdId).code;
598 ASSERT_EQ(WifiStatusCode::SUCCESS, halStatus);
599 // wait for a callback
600 ASSERT_EQ(std::cv_status::no_timeout,
601 wait(NOTIFY_CAPABILITIES_RESPONSE_1_5));
602 ASSERT_EQ(NOTIFY_CAPABILITIES_RESPONSE_1_5, callbackType);
603 ASSERT_EQ(id, inputCmdId);
604
605 // check for reasonable capability values
606 EXPECT_GT(capabilities_1_5.V1_0.maxConcurrentClusters, (unsigned int)0);
607 EXPECT_GT(capabilities_1_5.V1_0.maxPublishes, (unsigned int)0);
608 EXPECT_GT(capabilities_1_5.V1_0.maxSubscribes, (unsigned int)0);
609 EXPECT_EQ(capabilities_1_5.V1_0.maxServiceNameLen, (unsigned int)255);
610 EXPECT_EQ(capabilities_1_5.V1_0.maxMatchFilterLen, (unsigned int)255);
611 EXPECT_GT(capabilities_1_5.V1_0.maxTotalMatchFilterLen, (unsigned int)255);
612 EXPECT_EQ(capabilities_1_5.V1_0.maxServiceSpecificInfoLen,
613 (unsigned int)255);
614 EXPECT_GE(capabilities_1_5.V1_0.maxExtendedServiceSpecificInfoLen,
615 (unsigned int)255);
616 EXPECT_GT(capabilities_1_5.V1_0.maxNdiInterfaces, (unsigned int)0);
617 EXPECT_GT(capabilities_1_5.V1_0.maxNdpSessions, (unsigned int)0);
618 EXPECT_GT(capabilities_1_5.V1_0.maxAppInfoLen, (unsigned int)0);
619 EXPECT_GT(capabilities_1_5.V1_0.maxQueuedTransmitFollowupMsgs,
620 (unsigned int)0);
621 EXPECT_GT(capabilities_1_5.V1_0.maxSubscribeInterfaceAddresses,
622 (unsigned int)0);
623 EXPECT_NE(capabilities_1_5.V1_0.supportedCipherSuites, (unsigned int)0);
624 EXPECT_TRUE(capabilities_1_5.instantCommunicationModeSupportFlag ||
625 !capabilities_1_5.instantCommunicationModeSupportFlag);
626 }
627
628 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WifiNanIfaceHidlTest);
629 INSTANTIATE_TEST_SUITE_P(
630 PerInstance, WifiNanIfaceHidlTest,
631 testing::ValuesIn(android::hardware::getAllHalInstanceNames(
632 ::android::hardware::wifi::V1_5::IWifi::descriptor)),
633 android::hardware::PrintInstanceNameToString);
634