Use the hostapd_test_utils helper methods in am: c6cacf6149
am: b2d1a3b4c7
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/24589850 Change-Id: Icb5e286949dc7a8399c31ee498c00241a6b66acf Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
12e28a2bce
1 changed files with 11 additions and 68 deletions
|
@ -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");
|
||||
|
@ -83,79 +84,21 @@ class HostapdAidl : public testing::TestWithParam<std::string> {
|
|||
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];
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue