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

Commit 8f7074c8 authored by Roshan Pius's avatar Roshan Pius
Browse files

supplicant 1.0 (vts): Add ifaces at init for 1.1 HAL service

This was previously present in the .rc files for the 1.0 HAL. For
devices running the 1.1 HAL, we'll now add the interfaces at init for
testing the 1.0 functionality.

Bug: 65711261
Test: make vts -j30 BUILD_GOOGLE_VTS=true TARGET_PRODUCT=aosp_arm64 &&
vts-tradefed run commandAndExit vts --skip-all-system-status-check
--primary-abi-only --skip-preconditions --module VtsHalWifiSupplicantV1_0Target
-l INFO

Change-Id: I2137e9286c4496d7f8ddeb705c34b2d13b4ed3dc
parent b21613bd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ cc_library_static {
    static_libs: [
        "VtsHalWifiV1_0TargetTestUtil",
        "android.hardware.wifi.supplicant@1.0",
        "android.hardware.wifi.supplicant@1.1",
        "android.hardware.wifi@1.0",
        "libcrypto",
        "libgmock",
@@ -46,6 +47,7 @@ cc_test {
        "VtsHalWifiV1_0TargetTestUtil",
        "VtsHalWifiSupplicantV1_0TargetTestUtil",
        "android.hardware.wifi.supplicant@1.0",
        "android.hardware.wifi.supplicant@1.1",
        "android.hardware.wifi@1.0",
        "libcrypto",
        "libgmock",
+62 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <cutils/properties.h>

#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android/hidl/manager/1.0/IServiceNotification.h>
@@ -90,6 +91,18 @@ bool findIfaceOfType(sp<ISupplicant> supplicant, IfaceType desired_type,
    }
    return false;
}

std::string getStaIfaceName() {
    std::array<char, PROPERTY_VALUE_MAX> buffer;
    property_get("wifi.interface", buffer.data(), "wlan0");
    return buffer.data();
}

std::string getP2pIfaceName() {
    std::array<char, PROPERTY_VALUE_MAX> buffer;
    property_get("wifi.direct.interface", buffer.data(), "p2p0");
    return buffer.data();
}
}  // namespace

// Utility class to wait for wpa_supplicant's HIDL service registration.
@@ -165,9 +178,56 @@ void startSupplicantAndWaitForHidlService() {
    ASSERT_TRUE(notification_listener->waitForHidlService(200, service_name));
}

bool is_1_1(const sp<ISupplicant>& supplicant) {
    sp<::android::hardware::wifi::supplicant::V1_1::ISupplicant>
        supplicant_1_1 =
            ::android::hardware::wifi::supplicant::V1_1::ISupplicant::castFrom(
                supplicant);
    return supplicant_1_1.get() != nullptr;
}

void addSupplicantStaIface_1_1(const sp<ISupplicant>& supplicant) {
    sp<::android::hardware::wifi::supplicant::V1_1::ISupplicant>
        supplicant_1_1 =
            ::android::hardware::wifi::supplicant::V1_1::ISupplicant::castFrom(
                supplicant);
    ASSERT_TRUE(supplicant_1_1.get());
    ISupplicant::IfaceInfo info = {IfaceType::STA, getStaIfaceName()};
    supplicant_1_1->addInterface(
        info, [&](const SupplicantStatus& status,
                  const sp<ISupplicantIface>& /* iface */) {
            ASSERT_TRUE(
                (SupplicantStatusCode::SUCCESS == status.code) ||
                (SupplicantStatusCode::FAILURE_IFACE_EXISTS == status.code));
        });
}

void addSupplicantP2pIface_1_1(const sp<ISupplicant>& supplicant) {
    sp<::android::hardware::wifi::supplicant::V1_1::ISupplicant>
        supplicant_1_1 =
            ::android::hardware::wifi::supplicant::V1_1::ISupplicant::castFrom(
                supplicant);
    ASSERT_TRUE(supplicant_1_1.get());
    ISupplicant::IfaceInfo info = {IfaceType::P2P, getP2pIfaceName()};
    supplicant_1_1->addInterface(
        info, [&](const SupplicantStatus& status,
                  const sp<ISupplicantIface>& /* iface */) {
            ASSERT_TRUE(
                (SupplicantStatusCode::SUCCESS == status.code) ||
                (SupplicantStatusCode::FAILURE_IFACE_EXISTS == status.code));
        });
}

sp<ISupplicant> getSupplicant() {
    return ::testing::VtsHalHidlTargetTestBase::getService<ISupplicant>(
    sp<ISupplicant> supplicant =
        ::testing::VtsHalHidlTargetTestBase::getService<ISupplicant>(
            gEnv->getServiceName<ISupplicant>());
    // For 1.1 supplicant, we need to add interfaces at initialization.
    if (is_1_1(supplicant)) {
        addSupplicantStaIface_1_1(supplicant);
        addSupplicantP2pIface_1_1(supplicant);
    }
    return supplicant;
}

sp<ISupplicantStaIface> getSupplicantStaIface() {
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIface.h>
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>

#include <VtsHalHidlTargetTestEnvBase.h>