Merge "Use the PDL library for HCI packets" into udc-mainline-prod
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
index 75d6252..56f285d 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
@@ -41,10 +41,9 @@
using ::android::wifi_system::HostapdManager;
using ::android::wifi_system::SupplicantManager;
-namespace {
// Helper function to initialize the driver and firmware to AP mode
// using the vendor HAL HIDL interface.
-void initilializeDriverAndFirmware(const std::string& wifi_instance_name) {
+void initializeDriverAndFirmware(const std::string& wifi_instance_name) {
if (getWifi(wifi_instance_name) != nullptr) {
sp<IWifiChip> wifi_chip = getWifiChip(wifi_instance_name);
ChipModeId mode_id;
@@ -57,21 +56,20 @@
// Helper function to deinitialize the driver and firmware
// using the vendor HAL HIDL interface.
-void deInitilializeDriverAndFirmware(const std::string& wifi_instance_name) {
+void deInitializeDriverAndFirmware(const std::string& wifi_instance_name) {
if (getWifi(wifi_instance_name) != nullptr) {
stopWifi(wifi_instance_name);
} else {
LOG(WARNING) << __func__ << ": Vendor HAL not supported";
}
}
-} // namespace
void stopSupplicantIfNeeded(const std::string& instance_name) {
SupplicantManager supplicant_manager;
if (supplicant_manager.IsSupplicantRunning()) {
LOG(INFO) << "Supplicant is running, stop supplicant first.";
ASSERT_TRUE(supplicant_manager.StopSupplicant());
- deInitilializeDriverAndFirmware(instance_name);
+ deInitializeDriverAndFirmware(instance_name);
ASSERT_FALSE(supplicant_manager.IsSupplicantRunning());
}
}
@@ -80,13 +78,13 @@
HostapdManager hostapd_manager;
ASSERT_TRUE(hostapd_manager.StopHostapd());
- deInitilializeDriverAndFirmware(instance_name);
+ deInitializeDriverAndFirmware(instance_name);
}
void startHostapdAndWaitForHidlService(
const std::string& wifi_instance_name,
const std::string& hostapd_instance_name) {
- initilializeDriverAndFirmware(wifi_instance_name);
+ initializeDriverAndFirmware(wifi_instance_name);
HostapdManager hostapd_manager;
ASSERT_TRUE(hostapd_manager.StartHostapd());
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
index 5cb4f01..893de1e 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
@@ -33,5 +33,9 @@
bool is_1_1(const android::sp<android::hardware::wifi::hostapd::V1_0::IHostapd>&
hostapd);
+// Used to initialize/deinitialize the driver and firmware at the
+// beginning and end of each test.
+void initializeDriverAndFirmware(const std::string& wifi_instance_name);
+void deInitializeDriverAndFirmware(const std::string& wifi_instance_name);
#endif /* HOSTAPD_HIDL_TEST_UTILS_H */
diff --git a/wifi/hostapd/aidl/vts/functional/Android.bp b/wifi/hostapd/aidl/vts/functional/Android.bp
index 33318a4..ff35056 100644
--- a/wifi/hostapd/aidl/vts/functional/Android.bp
+++ b/wifi/hostapd/aidl/vts/functional/Android.bp
@@ -37,6 +37,7 @@
"android.hardware.wifi@1.5",
"android.hardware.wifi@1.6",
"android.hardware.wifi-V1-ndk",
+ "libwifi-system",
"libwifi-system-iface",
"VtsHalWifiTargetTestUtil",
],
diff --git a/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp b/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp
index efd1538..137537d 100644
--- a/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp
+++ b/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp
@@ -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 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 @@
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 @@
"/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;
diff --git a/wifi/hostapd/aidl/vts/functional/hostapd_aidl_test_utils.h b/wifi/hostapd/aidl/vts/functional/hostapd_aidl_test_utils.h
new file mode 100644
index 0000000..93540b2
--- /dev/null
+++ b/wifi/hostapd/aidl/vts/functional/hostapd_aidl_test_utils.h
@@ -0,0 +1,80 @@
+/*
+ * 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 <aidl/android/hardware/wifi/IWifi.h>
+#include <android-base/logging.h>
+
+#include "wifi_aidl_test_utils.h"
+
+namespace {
+
+const std::string kWifiInstanceNameStr = std::string() + IWifi::descriptor + "/default";
+const char* kWifiInstanceName = kWifiInstanceNameStr.c_str();
+
+} // namespace
+
+namespace HostapdAidlTestUtils {
+
+bool useAidlService() {
+ return isAidlServiceAvailable(kWifiInstanceName);
+}
+
+void startAndConfigureVendorHal() {
+ if (getWifi(kWifiInstanceName) != nullptr) {
+ std::shared_ptr<IWifiChip> wifi_chip = getWifiChip(kWifiInstanceName);
+ int mode_id;
+ EXPECT_TRUE(configureChipToSupportConcurrencyType(wifi_chip, IfaceConcurrencyType::AP,
+ &mode_id));
+ } else {
+ LOG(ERROR) << "Unable to initialize Vendor HAL";
+ }
+}
+
+void stopVendorHal() {
+ if (getWifi(kWifiInstanceName) != nullptr) {
+ stopWifiService(kWifiInstanceName);
+ } else {
+ LOG(ERROR) << "Unable to stop Vendor HAL";
+ }
+}
+
+std::string setupApIfaceAndGetName(bool isBridged) {
+ std::shared_ptr<IWifiApIface> wifi_ap_iface;
+ if (isBridged) {
+ wifi_ap_iface = getBridgedWifiApIface(kWifiInstanceName);
+ } else {
+ wifi_ap_iface = getWifiApIface(kWifiInstanceName);
+ }
+
+ EXPECT_TRUE(wifi_ap_iface.get() != nullptr);
+ if (!wifi_ap_iface.get()) {
+ LOG(ERROR) << "Unable to create iface. isBridged=" << isBridged;
+ return "";
+ }
+
+ std::string ap_iface_name;
+ auto status = wifi_ap_iface->getName(&ap_iface_name);
+ EXPECT_TRUE(status.isOk());
+ if (!status.isOk()) {
+ LOG(ERROR) << "Unable to retrieve iface name. isBridged=" << isBridged;
+ return "";
+ }
+ return ap_iface_name;
+}
+
+} // namespace HostapdAidlTestUtils
diff --git a/wifi/hostapd/aidl/vts/functional/hostapd_legacy_test_utils.h b/wifi/hostapd/aidl/vts/functional/hostapd_legacy_test_utils.h
new file mode 100644
index 0000000..fb59dc2
--- /dev/null
+++ b/wifi/hostapd/aidl/vts/functional/hostapd_legacy_test_utils.h
@@ -0,0 +1,71 @@
+/*
+ * 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 <android-base/logging.h>
+
+#include "hostapd_hidl_test_utils.h"
+#include "wifi_hidl_test_utils.h"
+
+using ::android::hardware::wifi::V1_0::WifiStatus;
+
+namespace {
+
+std::string getWifiInstanceName() {
+ const std::vector<std::string> instances = android::hardware::getAllHalInstanceNames(
+ ::android::hardware::wifi::V1_0::IWifi::descriptor);
+ EXPECT_NE(0, instances.size());
+ return instances.size() != 0 ? instances[0] : "";
+}
+
+} // namespace
+
+namespace HostapdLegacyTestUtils {
+
+void startAndConfigureVendorHal() {
+ initializeDriverAndFirmware(getWifiInstanceName());
+}
+
+void stopVendorHal() {
+ deInitializeDriverAndFirmware(getWifiInstanceName());
+}
+
+std::string setupApIfaceAndGetName(bool isBridged) {
+ android::sp<::android::hardware::wifi::V1_0::IWifiApIface> wifi_ap_iface;
+ if (isBridged) {
+ wifi_ap_iface = getBridgedWifiApIface_1_6(getWifiInstanceName());
+ } else {
+ wifi_ap_iface = getWifiApIface_1_5(getWifiInstanceName());
+ }
+
+ EXPECT_TRUE(wifi_ap_iface.get() != nullptr);
+ if (!wifi_ap_iface.get()) {
+ LOG(ERROR) << "Unable to create iface. isBridged=" << isBridged;
+ return "";
+ }
+
+ const auto& status_and_name = HIDL_INVOKE(wifi_ap_iface, getName);
+ EXPECT_TRUE(status_and_name.first.code ==
+ android::hardware::wifi::V1_0::WifiStatusCode::SUCCESS);
+ if (status_and_name.first.code != android::hardware::wifi::V1_0::WifiStatusCode::SUCCESS) {
+ LOG(ERROR) << "Unable to retrieve iface name. isBridged=" << isBridged;
+ return "";
+ }
+ return status_and_name.second;
+}
+
+} // namespace HostapdLegacyTestUtils
diff --git a/wifi/hostapd/aidl/vts/functional/hostapd_test_utils.h b/wifi/hostapd/aidl/vts/functional/hostapd_test_utils.h
new file mode 100644
index 0000000..feee2c8
--- /dev/null
+++ b/wifi/hostapd/aidl/vts/functional/hostapd_test_utils.h
@@ -0,0 +1,122 @@
+/*
+ * 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 <aidl/android/hardware/wifi/hostapd/BnHostapd.h>
+#include <android-base/logging.h>
+#include <wifi_system/hostapd_manager.h>
+#include <wifi_system/supplicant_manager.h>
+
+#include "hostapd_aidl_test_utils.h"
+#include "hostapd_legacy_test_utils.h"
+
+using aidl::android::hardware::wifi::hostapd::IHostapd;
+using android::wifi_system::HostapdManager;
+using android::wifi_system::SupplicantManager;
+
+namespace {
+
+void startAndConfigureVendorHal() {
+ if (HostapdAidlTestUtils::useAidlService()) {
+ HostapdAidlTestUtils::startAndConfigureVendorHal();
+ } else {
+ HostapdLegacyTestUtils::startAndConfigureVendorHal();
+ }
+}
+
+void stopVendorHal() {
+ if (HostapdAidlTestUtils::useAidlService()) {
+ HostapdAidlTestUtils::stopVendorHal();
+ } else {
+ HostapdLegacyTestUtils::stopVendorHal();
+ }
+}
+
+void stopHostapd() {
+ HostapdManager hostapd_manager;
+ ASSERT_TRUE(hostapd_manager.StopHostapd());
+}
+
+void waitForSupplicantState(bool enable) {
+ SupplicantManager supplicant_manager;
+ int count = 50; // wait at most 5 seconds
+ while (count-- > 0) {
+ if (supplicant_manager.IsSupplicantRunning() == enable) {
+ return;
+ }
+ usleep(100000); // 100 ms
+ }
+ LOG(ERROR) << "Unable to " << (enable ? "start" : "stop") << " supplicant";
+}
+
+void toggleWifiFramework(bool enable) {
+ if (enable) {
+ std::system("svc wifi enable");
+ std::system("cmd wifi set-scan-always-available enabled");
+ waitForSupplicantState(true);
+ } else {
+ std::system("svc wifi disable");
+ std::system("cmd wifi set-scan-always-available disabled");
+ waitForSupplicantState(false);
+ }
+}
+
+} // namespace
+
+std::shared_ptr<IHostapd> getHostapd(const std::string& hostapd_instance_name) {
+ return IHostapd::fromBinder(
+ ndk::SpAIBinder(AServiceManager_waitForService(hostapd_instance_name.c_str())));
+}
+
+/**
+ * Disable the Wifi framework, hostapd, and vendor HAL.
+ *
+ * Note: The framework should be disabled to avoid having
+ * any other clients to the HALs during testing.
+ */
+void disableHalsAndFramework() {
+ toggleWifiFramework(false);
+ stopHostapd();
+ stopVendorHal();
+
+ // Wait for the services to stop.
+ sleep(3);
+}
+
+void initializeHostapdAndVendorHal(const std::string& hostapd_instance_name) {
+ startAndConfigureVendorHal();
+ HostapdManager hostapd_manager;
+ ASSERT_TRUE(hostapd_manager.StartHostapd());
+ getHostapd(hostapd_instance_name);
+}
+
+void stopHostapdAndVendorHal() {
+ stopHostapd();
+ stopVendorHal();
+}
+
+void startWifiFramework() {
+ toggleWifiFramework(true);
+}
+
+std::string setupApIfaceAndGetName(bool isBridged) {
+ if (HostapdAidlTestUtils::useAidlService()) {
+ return HostapdAidlTestUtils::setupApIfaceAndGetName(isBridged);
+ } else {
+ return HostapdLegacyTestUtils::setupApIfaceAndGetName(isBridged);
+ }
+}