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

Commit 7c52c76c authored by Gabriel Biren's avatar Gabriel Biren
Browse files

Move vendor data helper functions to

wifi_aidl_test_utils.

Allows these methods to be used for
VTS tests across all Wifi HAL services.
Previously, they were only available to
the Supplicant tests.

Bug: 322815584
Test: atest VtsHalWifiSupplicantStaNetworkTargetTest \
            VtsHalWifiSupplicantP2pIfaceTargetTest
Change-Id: I2ef8fe528aa35bc2109a0f845432dec88962f21b
parent e2d1465d
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -62,6 +62,23 @@ bool configureChipToSupportConcurrencyTypeInternal(const std::shared_ptr<IWifiCh
    int mode_id;
    return configureChipToSupportConcurrencyTypeInternal(wifi_chip, type, &mode_id);
}

OuiKeyedData generateOuiKeyedData(int oui) {
    PersistableBundle bundle;
    bundle.putString("stringKey", "stringValue");
    bundle.putInt("intKey", 12345);

    OuiKeyedData data;
    data.oui = oui;
    data.vendorData = bundle;
    return data;
}

// Wraps generateOuiKeyedData result in std::optional
std::optional<OuiKeyedData> generateOuiKeyedDataOptional(int oui) {
    return std::optional<OuiKeyedData>{generateOuiKeyedData(oui)};
}

}  // namespace

bool checkStatusCode(ndk::ScopedAStatus* status, WifiStatusCode expected_code) {
@@ -238,3 +255,20 @@ int32_t getChipFeatureSet(const std::shared_ptr<IWifiChip>& wifi_chip) {
bool isAidlServiceAvailable(const char* instance_name) {
    return AServiceManager_isDeclared(instance_name);
}

std::vector<OuiKeyedData> generateOuiKeyedDataList(int size) {
    std::vector<OuiKeyedData> dataList;
    for (int i = 0; i < size; i++) {
        dataList.push_back(generateOuiKeyedData(i + 1));
    }
    return dataList;
}

// Generate OuiKeyedData list fully wrapped in std::optional
std::optional<std::vector<std::optional<OuiKeyedData>>> generateOuiKeyedDataListOptional(int size) {
    std::vector<std::optional<OuiKeyedData>> dataList;
    for (int i = 0; i < size; i++) {
        dataList.push_back(generateOuiKeyedDataOptional(i + 1));
    }
    return std::optional<std::vector<std::optional<OuiKeyedData>>>{dataList};
}
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <aidl/android/hardware/wifi/IWifi.h>
#include <aidl/android/hardware/wifi/IWifiChip.h>
#include <android/binder_manager.h>
#include <android/persistable_bundle_aidl.h>
#include <wifi_system/interface_tool.h>

using aidl::android::hardware::wifi::IfaceConcurrencyType;
@@ -30,6 +31,8 @@ using aidl::android::hardware::wifi::IWifiChip;
using aidl::android::hardware::wifi::IWifiNanIface;
using aidl::android::hardware::wifi::IWifiStaIface;
using aidl::android::hardware::wifi::WifiStatusCode;
using aidl::android::hardware::wifi::common::OuiKeyedData;
using aidl::android::os::PersistableBundle;

// Helper functions to obtain references to the various AIDL interface objects.
std::shared_ptr<IWifi> getWifi(const char* instance_name);
@@ -50,3 +53,6 @@ void stopWifiService(const char* instance_name);
int32_t getChipFeatureSet(const std::shared_ptr<IWifiChip>& wifi_chip);
bool checkStatusCode(ndk::ScopedAStatus* status, WifiStatusCode expected_code);
bool isAidlServiceAvailable(const char* instance_name);
// Generate test vendor data.
std::vector<OuiKeyedData> generateOuiKeyedDataList(int size);
std::optional<std::vector<std::optional<OuiKeyedData>>> generateOuiKeyedDataListOptional(int size);
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <cutils/properties.h>

#include "supplicant_test_utils.h"
#include "wifi_aidl_test_utils.h"

using aidl::android::hardware::wifi::supplicant::BnSupplicantP2pIfaceCallback;
using aidl::android::hardware::wifi::supplicant::DebugLevel;
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <cutils/properties.h>

#include "supplicant_test_utils.h"
#include "wifi_aidl_test_utils.h"

using aidl::android::hardware::wifi::supplicant::AuthAlgMask;
using aidl::android::hardware::wifi::supplicant::BnSupplicantStaNetworkCallback;
+0 −37
Original line number Diff line number Diff line
@@ -16,18 +16,14 @@

#pragma once

#include <android/persistable_bundle_aidl.h>

#include "supplicant_aidl_test_utils.h"
#include "supplicant_legacy_test_utils.h"

using aidl::android::hardware::wifi::common::OuiKeyedData;
using aidl::android::hardware::wifi::supplicant::IfaceInfo;
using aidl::android::hardware::wifi::supplicant::ISupplicant;
using aidl::android::hardware::wifi::supplicant::ISupplicantP2pIface;
using aidl::android::hardware::wifi::supplicant::ISupplicantStaIface;
using aidl::android::hardware::wifi::supplicant::KeyMgmtMask;
using aidl::android::os::PersistableBundle;

std::string getStaIfaceName() {
    std::array<char, PROPERTY_VALUE_MAX> buffer;
@@ -101,36 +97,3 @@ std::array<uint8_t, 6> vecToArrayMacAddr(std::vector<uint8_t> vectorAddr) {
    std::copy(vectorAddr.begin(), vectorAddr.begin() + 6, arrayAddr.begin());
    return arrayAddr;
}

OuiKeyedData generateOuiKeyedData(int oui) {
    PersistableBundle bundle;
    bundle.putString("stringKey", "stringValue");
    bundle.putInt("intKey", 12345);

    OuiKeyedData data;
    data.oui = oui;
    data.vendorData = bundle;
    return data;
}

std::vector<OuiKeyedData> generateOuiKeyedDataList(int size) {
    std::vector<OuiKeyedData> dataList;
    for (int i = 0; i < size; i++) {
        dataList.push_back(generateOuiKeyedData(i + 1));
    }
    return dataList;
}

// Wraps generateOuiKeyedData result in std::optional
std::optional<OuiKeyedData> generateOuiKeyedDataOptional(int oui) {
    return std::optional<OuiKeyedData>{generateOuiKeyedData(oui)};
}

// Generate OuiKeyedData list fully wrapped in std::optional
std::optional<std::vector<std::optional<OuiKeyedData>>> generateOuiKeyedDataListOptional(int size) {
    std::vector<std::optional<OuiKeyedData>> dataList;
    for (int i = 0; i < size; i++) {
        dataList.push_back(generateOuiKeyedDataOptional(i + 1));
    }
    return std::optional<std::vector<std::optional<OuiKeyedData>>>{dataList};
}