From eadd5160d838cb52cffced9bf65f61e4bee5ac78 Mon Sep 17 00:00:00 2001 From: Gabriel Biren Date: Mon, 5 Jun 2023 18:13:31 +0000 Subject: [PATCH] Add a new utility class wifi_hidl_test_utils_1_6 for the Wifi VTS tests. Main method is getBridgedWifiApIface_1_6, which allows us to configure the chip based on the Bridged AP IfaceConcurrencyType, rather than the AP IfaceType like in getBridgedWifiApIface_1_5. Implementations were largely copied from wifi_hidl_test_utils and wifi_hidl_test_utils_1_5. Bug: 283402709 Test: atest VtsHalHostapdTargetTest # tested on a Bluejay device that supports # the AddAccessPointWithDualBandConfig test Change-Id: I2571876149fc14c8de02e1cec9934dd052cada5c Merged-In: I2571876149fc14c8de02e1cec9934dd052cada5c --- wifi/1.6/vts/functional/Android.bp | 22 +++++ .../functional/wifi_hidl_test_utils_1_6.cpp | 87 +++++++++++++++++++ .../vts/functional/wifi_hidl_test_utils_1_6.h | 25 ++++++ wifi/hostapd/aidl/vts/functional/Android.bp | 2 + .../functional/VtsHalHostapdTargetTest.cpp | 3 +- 5 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 wifi/1.6/vts/functional/wifi_hidl_test_utils_1_6.cpp create mode 100644 wifi/1.6/vts/functional/wifi_hidl_test_utils_1_6.h diff --git a/wifi/1.6/vts/functional/Android.bp b/wifi/1.6/vts/functional/Android.bp index 2d126c7e8d..92e6d13483 100644 --- a/wifi/1.6/vts/functional/Android.bp +++ b/wifi/1.6/vts/functional/Android.bp @@ -23,6 +23,28 @@ package { default_applicable_licenses: ["hardware_interfaces_license"], } +cc_library_static { + name: "VtsHalWifiV1_6TargetTestUtil", + defaults: ["VtsHalTargetTestDefaults"], + srcs: [ + "wifi_hidl_test_utils_1_6.cpp", + ], + export_include_dirs: [ + ".", + ], + shared_libs: [ + "libnativehelper", + ], + static_libs: [ + "VtsHalWifiV1_0TargetTestUtil", + "android.hardware.wifi@1.0", + "android.hardware.wifi@1.3", + "android.hardware.wifi@1.5", + "android.hardware.wifi@1.6", + "libwifi-system-iface", + ], +} + cc_test { name: "VtsHalWifiV1_6TargetTest", defaults: ["VtsHalTargetTestDefaults"], diff --git a/wifi/1.6/vts/functional/wifi_hidl_test_utils_1_6.cpp b/wifi/1.6/vts/functional/wifi_hidl_test_utils_1_6.cpp new file mode 100644 index 0000000000..5b8115b7b7 --- /dev/null +++ b/wifi/1.6/vts/functional/wifi_hidl_test_utils_1_6.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#undef NAN // NAN is defined in bionic/libc/include/math.h:38 + +#include +#include +#include +#include +#include + +#include "wifi_hidl_call_util.h" +#include "wifi_hidl_test_utils.h" + +using ::android::sp; +using ::android::hardware::wifi::V1_0::ChipModeId; +using ::android::hardware::wifi::V1_0::WifiStatusCode; +using ::android::hardware::wifi::V1_5::IWifiApIface; +using ::android::hardware::wifi::V1_6::IfaceConcurrencyType; +using ::android::hardware::wifi::V1_6::IWifiChip; + +namespace { + +bool findAnyModeSupportingConcurrencyType(IfaceConcurrencyType desired_type, + const std::vector& modes, + ChipModeId* mode_id) { + for (const auto& mode : modes) { + for (const auto& combination : mode.availableCombinations) { + for (const auto& iface_limit : combination.limits) { + const auto& iface_types = iface_limit.types; + if (std::find(iface_types.begin(), iface_types.end(), desired_type) != + iface_types.end()) { + *mode_id = mode.id; + return true; + } + } + } + } + return false; +} + +bool configureChipToSupportConcurrencyType(const sp& wifi_chip, + IfaceConcurrencyType type, + ChipModeId* configured_mode_id) { + const auto& status_and_modes = HIDL_INVOKE(wifi_chip, getAvailableModes_1_6); + if (status_and_modes.first.code != WifiStatusCode::SUCCESS) { + return false; + } + if (!findAnyModeSupportingConcurrencyType(type, status_and_modes.second, configured_mode_id)) { + return false; + } + if (HIDL_INVOKE(wifi_chip, configureChip, *configured_mode_id).code != + WifiStatusCode::SUCCESS) { + return false; + } + return true; +} + +sp getWifiChip_1_6(const std::string& instance_name) { + return IWifiChip::castFrom(getWifiChip(instance_name)); +} + +} // namespace + +sp getBridgedWifiApIface_1_6(const std::string& instance_name) { + ChipModeId mode_id; + sp wifi_chip = getWifiChip_1_6(instance_name); + if (!wifi_chip.get()) return nullptr; + configureChipToSupportConcurrencyType(wifi_chip, IfaceConcurrencyType::AP_BRIDGED, &mode_id); + const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createBridgedApIface); + return IWifiApIface::castFrom(status_and_iface.second); +} diff --git a/wifi/1.6/vts/functional/wifi_hidl_test_utils_1_6.h b/wifi/1.6/vts/functional/wifi_hidl_test_utils_1_6.h new file mode 100644 index 0000000000..ab8ff3b176 --- /dev/null +++ b/wifi/1.6/vts/functional/wifi_hidl_test_utils_1_6.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include + +android::sp getBridgedWifiApIface_1_6( + const std::string& instance_name); diff --git a/wifi/hostapd/aidl/vts/functional/Android.bp b/wifi/hostapd/aidl/vts/functional/Android.bp index e61d3975bb..a24bcc0684 100644 --- a/wifi/hostapd/aidl/vts/functional/Android.bp +++ b/wifi/hostapd/aidl/vts/functional/Android.bp @@ -23,6 +23,7 @@ cc_test { "android.hardware.wifi.hostapd-V1-ndk", "VtsHalWifiV1_0TargetTestUtil", "VtsHalWifiV1_5TargetTestUtil", + "VtsHalWifiV1_6TargetTestUtil", "VtsHalWifiHostapdV1_0TargetTestUtil", "android.hardware.wifi.hostapd@1.0", "android.hardware.wifi.hostapd@1.1", @@ -34,6 +35,7 @@ cc_test { "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", + "android.hardware.wifi@1.6", ], test_suites: [ "general-tests", diff --git a/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp b/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp index bd2649fc50..1b9c0b08f6 100644 --- a/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp +++ b/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp @@ -29,6 +29,7 @@ #include #include #include +#include using aidl::android::hardware::wifi::hostapd::BandMask; using aidl::android::hardware::wifi::hostapd::BnHostapdCallback; @@ -101,7 +102,7 @@ class HostapdAidl : public testing::TestWithParam { std::string setupApIfaceAndGetName(bool isBridged) { android::sp<::android::hardware::wifi::V1_0::IWifiApIface> wifi_ap_iface; if (isBridged) { - wifi_ap_iface = getBridgedWifiApIface_1_5(wifiInstanceName); + wifi_ap_iface = getBridgedWifiApIface_1_6(wifiInstanceName); } else { wifi_ap_iface = getWifiApIface_1_5(wifiInstanceName); }