Use the hostapd_test_utils helper methods in am: c6cacf6149 am: b2d1a3b4c7 am: 12e28a2bce

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/24589850

Change-Id: I85d9f37d0222bbe77fbcd5e8a592ab12d83d9c65
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Gabriel Biren 2023-09-01 04:55:32 +00:00 committed by Automerger Merge Worker
commit 4ac4abb781

View file

@ -32,6 +32,7 @@
#include <wifi_hidl_test_utils_1_5.h>
#include <wifi_hidl_test_utils_1_6.h>
#include "hostapd_test_utils.h"
#include "wifi_aidl_test_utils.h"
using aidl::android::hardware::wifi::hostapd::BandMask;
@ -56,10 +57,7 @@ const std::string kInvalidMaxPassphrase =
const int kIfaceChannel = 6;
const int kIfaceInvalidChannel = 567;
const std::vector<uint8_t> kTestZeroMacAddr(6, 0x0);
const Ieee80211ReasonCode kTestDisconnectReasonCode =
Ieee80211ReasonCode::WLAN_REASON_UNSPECIFIED;
const std::string kWifiAidlInstanceNameStr = std::string() + IWifi::descriptor + "/default";
const char* kWifiAidlInstanceName = kWifiAidlInstanceNameStr.c_str();
const Ieee80211ReasonCode kTestDisconnectReasonCode = Ieee80211ReasonCode::WLAN_REASON_UNSPECIFIED;
inline BandMask operator|(BandMask a, BandMask b) {
return static_cast<BandMask>(static_cast<int32_t>(a) |
@ -70,10 +68,13 @@ inline BandMask operator|(BandMask a, BandMask b) {
class HostapdAidl : public testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
hostapd = IHostapd::fromBinder(ndk::SpAIBinder(
AServiceManager_waitForService(GetParam().c_str())));
disableHalsAndFramework();
initializeHostapdAndVendorHal(GetParam());
hostapd = getHostapd(GetParam());
ASSERT_NE(hostapd, nullptr);
EXPECT_TRUE(hostapd->setDebugParams(DebugLevel::EXCESSIVE).isOk());
isAcsSupport = testing::checkSubstringInCommandOutput(
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_acs_supported");
@ -81,81 +82,23 @@ class HostapdAidl : public testing::TestWithParam<std::string> {
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_wpa3_sae_supported");
isBridgedSupport = testing::checkSubstringInCommandOutput(
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_bridged_ap_supported");
if (!isAidlServiceAvailable(kWifiAidlInstanceName)) {
const std::vector<std::string> instances = android::hardware::getAllHalInstanceNames(
::android::hardware::wifi::V1_0::IWifi::descriptor);
EXPECT_NE(0, instances.size());
wifiHidlInstanceName = instances[0];
}
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_bridged_ap_supported");
}
virtual void TearDown() override {
stopVendorHal();
hostapd->terminate();
// Wait 3 seconds to allow terminate to complete
sleep(3);
stopHostapdAndVendorHal();
startWifiFramework();
}
std::shared_ptr<IHostapd> hostapd;
std::string wifiHidlInstanceName;
bool isAcsSupport;
bool isWpa3SaeSupport;
bool isBridgedSupport;
void stopVendorHal() {
if (isAidlServiceAvailable(kWifiAidlInstanceName)) {
// HIDL and AIDL versions of getWifi() take different arguments
// i.e. const char* vs string
if (getWifi(kWifiAidlInstanceName) != nullptr) {
stopWifiService(kWifiAidlInstanceName);
}
} else {
if (getWifi(wifiHidlInstanceName) != nullptr) {
stopWifi(wifiHidlInstanceName);
}
}
}
std::string setupApIfaceAndGetName(bool isBridged) {
if (isAidlServiceAvailable(kWifiAidlInstanceName)) {
return setupApIfaceAndGetNameAidl(isBridged);
} else {
return setupApIfaceAndGetNameHidl(isBridged);
}
}
std::string setupApIfaceAndGetNameAidl(bool isBridged) {
std::shared_ptr<IWifiApIface> wifi_ap_iface;
if (isBridged) {
wifi_ap_iface = getBridgedWifiApIface(kWifiAidlInstanceName);
} else {
wifi_ap_iface = getWifiApIface(kWifiAidlInstanceName);
}
EXPECT_NE(nullptr, wifi_ap_iface.get());
std::string ap_iface_name;
auto status = wifi_ap_iface->getName(&ap_iface_name);
EXPECT_TRUE(status.isOk());
return ap_iface_name;
}
std::string setupApIfaceAndGetNameHidl(bool isBridged) {
android::sp<::android::hardware::wifi::V1_0::IWifiApIface> wifi_ap_iface;
if (isBridged) {
wifi_ap_iface = getBridgedWifiApIface_1_6(wifiHidlInstanceName);
} else {
wifi_ap_iface = getWifiApIface_1_5(wifiHidlInstanceName);
}
EXPECT_NE(nullptr, wifi_ap_iface.get());
const auto& status_and_name = HIDL_INVOKE(wifi_ap_iface, getName);
EXPECT_EQ(android::hardware::wifi::V1_0::WifiStatusCode::SUCCESS,
status_and_name.first.code);
return status_and_name.second;
}
IfaceParams getIfaceParamsWithoutAcs(std::string iface_name) {
IfaceParams iface_params;
ChannelParams channelParams;