mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Use the hostapd_test_utils helper methods in am: c6cacf6149 am: b2d1a3b4c7 am: 9af8f6c18d
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/24589850 Change-Id: Ibced01c90f8eedd1e8e0f4eb980334140b3513bf Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include <wifi_hidl_test_utils_1_5.h>
|
#include <wifi_hidl_test_utils_1_5.h>
|
||||||
#include <wifi_hidl_test_utils_1_6.h>
|
#include <wifi_hidl_test_utils_1_6.h>
|
||||||
|
|
||||||
|
#include "hostapd_test_utils.h"
|
||||||
#include "wifi_aidl_test_utils.h"
|
#include "wifi_aidl_test_utils.h"
|
||||||
|
|
||||||
using aidl::android::hardware::wifi::hostapd::BandMask;
|
using aidl::android::hardware::wifi::hostapd::BandMask;
|
||||||
@@ -56,10 +57,7 @@ const std::string kInvalidMaxPassphrase =
|
|||||||
const int kIfaceChannel = 6;
|
const int kIfaceChannel = 6;
|
||||||
const int kIfaceInvalidChannel = 567;
|
const int kIfaceInvalidChannel = 567;
|
||||||
const std::vector<uint8_t> kTestZeroMacAddr(6, 0x0);
|
const std::vector<uint8_t> kTestZeroMacAddr(6, 0x0);
|
||||||
const Ieee80211ReasonCode kTestDisconnectReasonCode =
|
const Ieee80211ReasonCode kTestDisconnectReasonCode = Ieee80211ReasonCode::WLAN_REASON_UNSPECIFIED;
|
||||||
Ieee80211ReasonCode::WLAN_REASON_UNSPECIFIED;
|
|
||||||
const std::string kWifiAidlInstanceNameStr = std::string() + IWifi::descriptor + "/default";
|
|
||||||
const char* kWifiAidlInstanceName = kWifiAidlInstanceNameStr.c_str();
|
|
||||||
|
|
||||||
inline BandMask operator|(BandMask a, BandMask b) {
|
inline BandMask operator|(BandMask a, BandMask b) {
|
||||||
return static_cast<BandMask>(static_cast<int32_t>(a) |
|
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> {
|
class HostapdAidl : public testing::TestWithParam<std::string> {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
hostapd = IHostapd::fromBinder(ndk::SpAIBinder(
|
disableHalsAndFramework();
|
||||||
AServiceManager_waitForService(GetParam().c_str())));
|
initializeHostapdAndVendorHal(GetParam());
|
||||||
|
|
||||||
|
hostapd = getHostapd(GetParam());
|
||||||
ASSERT_NE(hostapd, nullptr);
|
ASSERT_NE(hostapd, nullptr);
|
||||||
EXPECT_TRUE(hostapd->setDebugParams(DebugLevel::EXCESSIVE).isOk());
|
EXPECT_TRUE(hostapd->setDebugParams(DebugLevel::EXCESSIVE).isOk());
|
||||||
|
|
||||||
isAcsSupport = testing::checkSubstringInCommandOutput(
|
isAcsSupport = testing::checkSubstringInCommandOutput(
|
||||||
"/system/bin/cmd wifi get-softap-supported-features",
|
"/system/bin/cmd wifi get-softap-supported-features",
|
||||||
"wifi_softap_acs_supported");
|
"wifi_softap_acs_supported");
|
||||||
@@ -81,81 +82,23 @@ class HostapdAidl : public testing::TestWithParam<std::string> {
|
|||||||
"/system/bin/cmd wifi get-softap-supported-features",
|
"/system/bin/cmd wifi get-softap-supported-features",
|
||||||
"wifi_softap_wpa3_sae_supported");
|
"wifi_softap_wpa3_sae_supported");
|
||||||
isBridgedSupport = testing::checkSubstringInCommandOutput(
|
isBridgedSupport = testing::checkSubstringInCommandOutput(
|
||||||
"/system/bin/cmd wifi get-softap-supported-features",
|
"/system/bin/cmd wifi get-softap-supported-features",
|
||||||
"wifi_softap_bridged_ap_supported");
|
"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 {
|
virtual void TearDown() override {
|
||||||
stopVendorHal();
|
|
||||||
hostapd->terminate();
|
hostapd->terminate();
|
||||||
// Wait 3 seconds to allow terminate to complete
|
// Wait 3 seconds to allow terminate to complete
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
stopHostapdAndVendorHal();
|
||||||
|
startWifiFramework();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<IHostapd> hostapd;
|
std::shared_ptr<IHostapd> hostapd;
|
||||||
std::string wifiHidlInstanceName;
|
|
||||||
bool isAcsSupport;
|
bool isAcsSupport;
|
||||||
bool isWpa3SaeSupport;
|
bool isWpa3SaeSupport;
|
||||||
bool isBridgedSupport;
|
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 getIfaceParamsWithoutAcs(std::string iface_name) {
|
||||||
IfaceParams iface_params;
|
IfaceParams iface_params;
|
||||||
ChannelParams channelParams;
|
ChannelParams channelParams;
|
||||||
|
|||||||
Reference in New Issue
Block a user