1 /*
2 * Copyright (C) 2017 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 #include <general_test/wifi_capabilities_test.h>
17
18 #include <shared/send_message.h>
19 #include "chre_api/chre.h"
20
21 namespace general_test {
22
WifiCapabilitiesTest()23 WifiCapabilitiesTest::WifiCapabilitiesTest() : Test(CHRE_API_VERSION_1_1) {}
24
setUp(uint32_t messageSize,const void *)25 void WifiCapabilitiesTest::setUp(uint32_t messageSize,
26 const void * /* message */) {
27 if (messageSize != 0) {
28 nanoapp_testing::sendFatalFailureToHost(
29 "Expected 0 byte message, got more bytes:", &messageSize);
30 } else {
31 uint32_t allCapabilities = CHRE_WIFI_CAPABILITIES_NONE;
32
33 if (mApiVersion >= CHRE_API_VERSION_1_1) {
34 allCapabilities |= CHRE_WIFI_CAPABILITIES_SCAN_MONITORING |
35 CHRE_WIFI_CAPABILITIES_ON_DEMAND_SCAN;
36 }
37 if (mApiVersion >= CHRE_API_VERSION_1_2) {
38 allCapabilities |= CHRE_WIFI_CAPABILITIES_RADIO_CHAIN_PREF |
39 CHRE_WIFI_CAPABILITIES_RTT_RANGING;
40 }
41 if (mApiVersion >= CHRE_API_VERSION_1_6) {
42 allCapabilities |= CHRE_WIFI_CAPABILITIES_NAN_SUB;
43 }
44
45 // Call the new API
46 uint32_t capabilities = chreWifiGetCapabilities();
47
48 // Clear out known capabilities, any remaining are unknown
49 if ((capabilities & ~allCapabilities) != 0) {
50 if (mApiVersion > CHRE_API_VERSION_1_2) {
51 nanoapp_testing::sendFatalFailureToHost(
52 "New version with unknown capabilities encountered:",
53 &capabilities);
54 } else {
55 nanoapp_testing::sendFatalFailureToHost(
56 "Received unexpected capabilities:", &capabilities);
57 }
58 } else {
59 nanoapp_testing::sendSuccessToHost();
60 }
61 }
62 }
63
handleEvent(uint32_t,uint16_t eventType,const void *)64 void WifiCapabilitiesTest::handleEvent(uint32_t /* senderInstanceId */,
65 uint16_t eventType,
66 const void * /* eventData */) {
67 unexpectedEvent(eventType);
68 }
69
70 } // namespace general_test
71