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

Commit 5fa6a055 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10277391 from 94734588 to udc-qpr1-release

Change-Id: Ib033ad705387b19e3041823fb797029a4718b312
parents 5e764c62 94734588
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -23,6 +23,28 @@ package {
    default_applicable_licenses: ["hardware_interfaces_license"],
}

cc_library_static {
    name: "VtsHalWifiV1_6TargetTestUtil",
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: [
        "wifi_hidl_test_utils_1_6.cpp",
    ],
    export_include_dirs: [
        ".",
    ],
    shared_libs: [
        "libnativehelper",
    ],
    static_libs: [
        "VtsHalWifiV1_0TargetTestUtil",
        "android.hardware.wifi@1.0",
        "android.hardware.wifi@1.3",
        "android.hardware.wifi@1.5",
        "android.hardware.wifi@1.6",
        "libwifi-system-iface",
    ],
}

cc_test {
    name: "VtsHalWifiV1_6TargetTest",
    defaults: ["VtsHalTargetTestDefaults"],
+87 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

#include <VtsHalHidlTargetCallbackBase.h>

#undef NAN  // NAN is defined in bionic/libc/include/math.h:38

#include <android/hardware/wifi/1.5/IWifiApIface.h>
#include <android/hardware/wifi/1.6/IWifiChip.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>

#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"

using ::android::sp;
using ::android::hardware::wifi::V1_0::ChipModeId;
using ::android::hardware::wifi::V1_0::WifiStatusCode;
using ::android::hardware::wifi::V1_5::IWifiApIface;
using ::android::hardware::wifi::V1_6::IfaceConcurrencyType;
using ::android::hardware::wifi::V1_6::IWifiChip;

namespace {

bool findAnyModeSupportingConcurrencyType(IfaceConcurrencyType desired_type,
                                          const std::vector<IWifiChip::ChipMode>& modes,
                                          ChipModeId* mode_id) {
    for (const auto& mode : modes) {
        for (const auto& combination : mode.availableCombinations) {
            for (const auto& iface_limit : combination.limits) {
                const auto& iface_types = iface_limit.types;
                if (std::find(iface_types.begin(), iface_types.end(), desired_type) !=
                    iface_types.end()) {
                    *mode_id = mode.id;
                    return true;
                }
            }
        }
    }
    return false;
}

bool configureChipToSupportConcurrencyType(const sp<IWifiChip>& wifi_chip,
                                           IfaceConcurrencyType type,
                                           ChipModeId* configured_mode_id) {
    const auto& status_and_modes = HIDL_INVOKE(wifi_chip, getAvailableModes_1_6);
    if (status_and_modes.first.code != WifiStatusCode::SUCCESS) {
        return false;
    }
    if (!findAnyModeSupportingConcurrencyType(type, status_and_modes.second, configured_mode_id)) {
        return false;
    }
    if (HIDL_INVOKE(wifi_chip, configureChip, *configured_mode_id).code !=
        WifiStatusCode::SUCCESS) {
        return false;
    }
    return true;
}

sp<IWifiChip> getWifiChip_1_6(const std::string& instance_name) {
    return IWifiChip::castFrom(getWifiChip(instance_name));
}

}  // namespace

sp<IWifiApIface> getBridgedWifiApIface_1_6(const std::string& instance_name) {
    ChipModeId mode_id;
    sp<IWifiChip> wifi_chip = getWifiChip_1_6(instance_name);
    if (!wifi_chip.get()) return nullptr;
    configureChipToSupportConcurrencyType(wifi_chip, IfaceConcurrencyType::AP_BRIDGED, &mode_id);
    const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createBridgedApIface);
    return IWifiApIface::castFrom(status_and_iface.second);
}
+25 −0
Original line number Diff line number Diff line
/*
 * 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/hardware/wifi/1.5/IWifiApIface.h>
#include <android/hardware/wifi/1.6/IWifiChip.h>

#include <VtsHalHidlTargetTestEnvBase.h>

android::sp<android::hardware::wifi::V1_5::IWifiApIface> getBridgedWifiApIface_1_6(
        const std::string& instance_name);
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ cc_test {
        "android.hardware.wifi.hostapd-V1-ndk",
        "VtsHalWifiV1_0TargetTestUtil",
        "VtsHalWifiV1_5TargetTestUtil",
        "VtsHalWifiV1_6TargetTestUtil",
        "VtsHalWifiHostapdV1_0TargetTestUtil",
        "android.hardware.wifi.hostapd@1.0",
        "android.hardware.wifi.hostapd@1.1",
@@ -34,6 +35,7 @@ cc_test {
        "android.hardware.wifi@1.3",
        "android.hardware.wifi@1.4",
        "android.hardware.wifi@1.5",
        "android.hardware.wifi@1.6",
        "android.hardware.wifi-V1-ndk",
        "libwifi-system-iface",
        "VtsHalWifiTargetTestUtil",
+2 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include <hostapd_hidl_test_utils.h>
#include <wifi_hidl_test_utils.h>
#include <wifi_hidl_test_utils_1_5.h>
#include <wifi_hidl_test_utils_1_6.h>

#include "wifi_aidl_test_utils.h"

@@ -143,7 +144,7 @@ class HostapdAidl : public testing::TestWithParam<std::string> {
    std::string setupApIfaceAndGetNameHidl(bool isBridged) {
        android::sp<::android::hardware::wifi::V1_0::IWifiApIface> wifi_ap_iface;
        if (isBridged) {
            wifi_ap_iface = getBridgedWifiApIface_1_5(wifiHidlInstanceName);
            wifi_ap_iface = getBridgedWifiApIface_1_6(wifiHidlInstanceName);
        } else {
            wifi_ap_iface = getWifiApIface_1_5(wifiHidlInstanceName);
        }