Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd150ea1 authored by Gabriel Biren's avatar Gabriel Biren
Browse files

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
parent bfc99319
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -214,3 +214,7 @@ int32_t getChipCapabilities(const std::shared_ptr<IWifiChip>& wifi_chip) {
    }
    return 0;
}

bool isAidlServiceAvailable(const char* instance_name) {
    return AServiceManager_isDeclared(instance_name);
}
+1 −0
Original line number Diff line number Diff line
@@ -46,3 +46,4 @@ bool configureChipToSupportConcurrencyType(const std::shared_ptr<IWifiChip>& wif
void stopWifiService(const char* instance_name);
int32_t getChipCapabilities(const std::shared_ptr<IWifiChip>& wifi_chip);
bool checkStatusCode(ndk::ScopedAStatus* status, WifiStatusCode expected_code);
bool isAidlServiceAvailable(const char* instance_name);
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ cc_test {
        "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",
+52 −10
Original line number Diff line number Diff line
@@ -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 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();

inline BandMask operator|(BandMask a, BandMask b) {
    return static_cast<BandMask>(static_cast<int32_t>(a) |
@@ -77,33 +82,70 @@ 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());
        wifiInstanceName = instances[0];
            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());

+6 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ cc_test {
        "VtsHalWifiV1_0TargetTestUtil",
        "VtsHalWifiV1_5TargetTestUtil",
        "VtsHalWifiSupplicantV1_0TargetTestUtil",
        "android.hardware.wifi-V1-ndk",
        "VtsHalWifiTargetTestUtil",
    ],
    test_suites: [
        "general-tests",
@@ -84,6 +86,8 @@ cc_test {
        "VtsHalWifiV1_0TargetTestUtil",
        "VtsHalWifiV1_5TargetTestUtil",
        "VtsHalWifiSupplicantV1_0TargetTestUtil",
        "android.hardware.wifi-V1-ndk",
        "VtsHalWifiTargetTestUtil",
    ],
    test_suites: [
        "general-tests",
@@ -118,6 +122,8 @@ cc_test {
        "VtsHalWifiV1_0TargetTestUtil",
        "VtsHalWifiV1_5TargetTestUtil",
        "VtsHalWifiSupplicantV1_0TargetTestUtil",
        "android.hardware.wifi-V1-ndk",
        "VtsHalWifiTargetTestUtil",
    ],
    test_suites: [
        "general-tests",
Loading