mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "In supplicant VTS test setup, make sure that the wifi hal is stopped before starting wifi." into android12-tests-dev
This commit is contained in:
@@ -38,11 +38,12 @@ class SupplicantHidlTest
|
|||||||
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
// Stop Wi-Fi
|
|
||||||
ASSERT_TRUE(stopWifiFramework()); // stop & wait for wifi to shutdown.
|
|
||||||
|
|
||||||
wifi_instance_name_ = std::get<0>(GetParam());
|
wifi_instance_name_ = std::get<0>(GetParam());
|
||||||
supplicant_instance_name_ = std::get<1>(GetParam());
|
supplicant_instance_name_ = std::get<1>(GetParam());
|
||||||
|
|
||||||
|
// Stop & wait for wifi to shutdown.
|
||||||
|
ASSERT_TRUE(stopWifiFramework(wifi_instance_name_));
|
||||||
|
|
||||||
std::system("/system/bin/start");
|
std::system("/system/bin/start");
|
||||||
ASSERT_TRUE(waitForFrameworkReady());
|
ASSERT_TRUE(waitForFrameworkReady());
|
||||||
isP2pOn_ =
|
isP2pOn_ =
|
||||||
|
|||||||
@@ -28,26 +28,42 @@
|
|||||||
|
|
||||||
using ::android::sp;
|
using ::android::sp;
|
||||||
using ::android::hardware::configureRpcThreadpool;
|
using ::android::hardware::configureRpcThreadpool;
|
||||||
using ::android::hardware::joinRpcThreadpool;
|
|
||||||
using ::android::hardware::hidl_string;
|
using ::android::hardware::hidl_string;
|
||||||
using ::android::hardware::hidl_vec;
|
using ::android::hardware::hidl_vec;
|
||||||
|
using ::android::hardware::joinRpcThreadpool;
|
||||||
using ::android::hardware::Return;
|
using ::android::hardware::Return;
|
||||||
using ::android::hardware::Void;
|
using ::android::hardware::Void;
|
||||||
using ::android::hardware::wifi::V1_0::ChipModeId;
|
using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
|
||||||
using ::android::hardware::wifi::V1_0::IWifiChip;
|
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::ISupplicant;
|
using ::android::hardware::wifi::supplicant::V1_0::ISupplicant;
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantIface;
|
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantIface;
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantNetwork;
|
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantNetwork;
|
||||||
|
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface;
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface;
|
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface;
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
|
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface;
|
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
|
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
|
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
|
||||||
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
|
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
|
||||||
|
using ::android::hardware::wifi::V1_0::ChipModeId;
|
||||||
|
using ::android::hardware::wifi::V1_0::IWifi;
|
||||||
|
using ::android::hardware::wifi::V1_0::IWifiChip;
|
||||||
using ::android::wifi_system::InterfaceTool;
|
using ::android::wifi_system::InterfaceTool;
|
||||||
using ::android::wifi_system::SupplicantManager;
|
using ::android::wifi_system::SupplicantManager;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
bool waitForWifiHalStop(const std::string& wifi_instance_name) {
|
||||||
|
sp<IWifi> wifi = getWifi(wifi_instance_name);
|
||||||
|
int count = 50; /* wait at most 5 seconds for completion */
|
||||||
|
while (count-- > 0) {
|
||||||
|
if (wifi != nullptr && !wifi->isStarted()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
usleep(100000);
|
||||||
|
wifi = getWifi(wifi_instance_name);
|
||||||
|
}
|
||||||
|
LOG(ERROR) << "Wifi HAL was not stopped";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool waitForSupplicantState(bool is_running) {
|
bool waitForSupplicantState(bool is_running) {
|
||||||
SupplicantManager supplicant_manager;
|
SupplicantManager supplicant_manager;
|
||||||
int count = 50; /* wait at most 5 seconds for completion */
|
int count = 50; /* wait at most 5 seconds for completion */
|
||||||
@@ -144,10 +160,10 @@ bool startWifiFramework() {
|
|||||||
return waitForSupplicantStart(); // wait for wifi to start.
|
return waitForSupplicantStart(); // wait for wifi to start.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool stopWifiFramework() {
|
bool stopWifiFramework(const std::string& wifi_instance_name) {
|
||||||
std::system("svc wifi disable");
|
std::system("svc wifi disable");
|
||||||
std::system("cmd wifi set-scan-always-available disabled");
|
std::system("cmd wifi set-scan-always-available disabled");
|
||||||
return waitForSupplicantStop(); // wait for wifi to shutdown.
|
return waitForSupplicantStop() && waitForWifiHalStop(wifi_instance_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopSupplicant() { stopSupplicant(""); }
|
void stopSupplicant() { stopSupplicant(""); }
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
bool startWifiFramework();
|
bool startWifiFramework();
|
||||||
|
|
||||||
// Used to stop the android wifi framework before every test.
|
// Used to stop the android wifi framework before every test.
|
||||||
bool stopWifiFramework();
|
bool stopWifiFramework(const std::string& wifi_instance_name);
|
||||||
|
|
||||||
void stopSupplicant(const std::string& wifi_instance_name);
|
void stopSupplicant(const std::string& wifi_instance_name);
|
||||||
// Used to configure the chip, driver and start wpa_supplicant before every
|
// Used to configure the chip, driver and start wpa_supplicant before every
|
||||||
@@ -72,12 +72,13 @@ class SupplicantHidlTestBase
|
|||||||
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
// Stop Wi-Fi
|
wifi_v1_0_instance_name_ =
|
||||||
ASSERT_TRUE(stopWifiFramework()); // stop & wait for wifi to shutdown.
|
std::get<0>(GetParam()); // should always be v1.0 wifi
|
||||||
|
|
||||||
// should always be v1.0 wifi
|
|
||||||
wifi_v1_0_instance_name_ = std::get<0>(GetParam());
|
|
||||||
supplicant_instance_name_ = std::get<1>(GetParam());
|
supplicant_instance_name_ = std::get<1>(GetParam());
|
||||||
|
|
||||||
|
// Stop & wait for wifi to shutdown.
|
||||||
|
ASSERT_TRUE(stopWifiFramework(wifi_v1_0_instance_name_));
|
||||||
|
|
||||||
std::system("/system/bin/start");
|
std::system("/system/bin/start");
|
||||||
ASSERT_TRUE(waitForFrameworkReady());
|
ASSERT_TRUE(waitForFrameworkReady());
|
||||||
isP2pOn_ =
|
isP2pOn_ =
|
||||||
|
|||||||
Reference in New Issue
Block a user