Update VTS test dependencies.
Supplicant and Hostapd tests have a dependency on
the Vendor HAL in order to do setup/cleanup,
such as bringing up an interface.
This change will make the tests compatible with either
the HIDL or AIDL Vendor HAL, depending on which
is available.
Bug: 205044134
Test: atest VtsHalHostapdTargetTest
atest VtsHalWifiSupplicantStaIfaceTargetTest \
VtsHalWifiSupplicantStaNetworkTargetTest \
VtsHalWifiSupplicantP2pIfaceTargetTest
Tests were run using both the HIDL and AIDL
Vendor HALs.
Change-Id: I1f6b15016414a0bf614703315b47b5b47d3a1e50
diff --git a/wifi/hostapd/aidl/vts/functional/Android.bp b/wifi/hostapd/aidl/vts/functional/Android.bp
index e61d397..1942db1 100644
--- a/wifi/hostapd/aidl/vts/functional/Android.bp
+++ b/wifi/hostapd/aidl/vts/functional/Android.bp
@@ -34,6 +34,9 @@
"android.hardware.wifi@1.3",
"android.hardware.wifi@1.4",
"android.hardware.wifi@1.5",
+ "android.hardware.wifi-V1-ndk",
+ "libwifi-system-iface",
+ "VtsHalWifiTargetTestUtil",
],
test_suites: [
"general-tests",
diff --git a/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp b/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp
index bd2649f..69f1b76 100644
--- a/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp
+++ b/wifi/hostapd/aidl/vts/functional/VtsHalHostapdTargetTest.cpp
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <aidl/android/hardware/wifi/IWifi.h>
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/hostapd/1.3/IHostapd.h>
@@ -30,6 +31,8 @@
#include <wifi_hidl_test_utils.h>
#include <wifi_hidl_test_utils_1_5.h>
+#include "wifi_aidl_test_utils.h"
+
using aidl::android::hardware::wifi::hostapd::BandMask;
using aidl::android::hardware::wifi::hostapd::BnHostapdCallback;
using aidl::android::hardware::wifi::hostapd::ChannelBandwidth;
@@ -54,6 +57,8 @@
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();
inline BandMask operator|(BandMask a, BandMask b) {
return static_cast<BandMask>(static_cast<int32_t>(a) |
@@ -77,33 +82,70 @@
isBridgedSupport = testing::checkSubstringInCommandOutput(
"/system/bin/cmd wifi get-softap-supported-features",
"wifi_softap_bridged_ap_supported");
- const std::vector<std::string> instances = android::hardware::getAllHalInstanceNames(
- ::android::hardware::wifi::V1_0::IWifi::descriptor);
- EXPECT_NE(0, instances.size());
- wifiInstanceName = instances[0];
+ 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 {
- if (getWifi(wifiInstanceName) != nullptr) {
- stopWifi(wifiInstanceName);
- }
+ stopVendorHal();
hostapd->terminate();
// Wait 3 seconds to allow terminate to complete
sleep(3);
}
std::shared_ptr<IHostapd> hostapd;
- std::string wifiInstanceName;
+ 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_5(wifiInstanceName);
+ wifi_ap_iface = getBridgedWifiApIface_1_5(wifiHidlInstanceName);
} else {
- wifi_ap_iface = getWifiApIface_1_5(wifiInstanceName);
+ wifi_ap_iface = getWifiApIface_1_5(wifiHidlInstanceName);
}
EXPECT_NE(nullptr, wifi_ap_iface.get());