1 /*
2 * Copyright (C) 2021 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 <VtsHalHidlTargetCallbackBase.h>
18 #include <android-base/logging.h>
19
20 #undef NAN // NAN is defined in bionic/libc/include/math.h:38
21
22 #include <android/hardware/wifi/1.5/IWifi.h>
23 #include <android/hardware/wifi/1.5/IWifiApIface.h>
24 #include <android/hardware/wifi/1.5/IWifiChip.h>
25 #include <gtest/gtest.h>
26 #include <hidl/GtestPrinter.h>
27 #include <hidl/ServiceManagement.h>
28
29 #include "wifi_hidl_call_util.h"
30 #include "wifi_hidl_test_utils.h"
31
32 using ::android::sp;
33 using ::android::hardware::hidl_string;
34 using ::android::hardware::hidl_vec;
35 using ::android::hardware::Return;
36 using ::android::hardware::Void;
37 using ::android::hardware::wifi::V1_0::ChipModeId;
38 using ::android::hardware::wifi::V1_0::IfaceType;
39 using ::android::hardware::wifi::V1_5::IWifiApIface;
40 using ::android::hardware::wifi::V1_5::IWifiChip;
41
getWifiChip_1_5(const std::string & instance_name)42 sp<IWifiChip> getWifiChip_1_5(const std::string& instance_name) {
43 return IWifiChip::castFrom(getWifiChip(instance_name));
44 }
45
getWifiApIface_1_5(const std::string & instance_name)46 sp<IWifiApIface> getWifiApIface_1_5(const std::string& instance_name) {
47 ChipModeId mode_id;
48 sp<IWifiChip> wifi_chip_ = getWifiChip_1_5(instance_name);
49 configureChipToSupportIfaceType(wifi_chip_, IfaceType::AP, &mode_id);
50 const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createApIface);
51 return IWifiApIface::castFrom(status_and_iface.second);
52 }
53
getBridgedWifiApIface_1_5(const std::string & instance_name)54 sp<IWifiApIface> getBridgedWifiApIface_1_5(const std::string& instance_name) {
55 ChipModeId mode_id;
56 sp<IWifiChip> wifi_chip_ = getWifiChip_1_5(instance_name);
57 configureChipToSupportIfaceType(wifi_chip_, IfaceType::AP, &mode_id);
58 const auto& status_and_iface =
59 HIDL_INVOKE(wifi_chip_, createBridgedApIface);
60 return IWifiApIface::castFrom(status_and_iface.second);
61 }
62