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

Commit 115f9d85 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8822995 from 68768886 to tm-qpr1-release

Change-Id: Ib7596a185ffa33ada1dde86b6b97b97a6d0abd40
parents ce3061a9 68768886
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -898,7 +898,7 @@ status_t HidlUtils::audioTransportsToHal(const hidl_vec<AudioTransport>& transpo
    for (const auto& transport : transports) {
        switch (transport.audioCapability.getDiscriminator()) {
            case AudioTransport::AudioCapability::hidl_discriminator::profile:
                if (halPort->num_audio_profiles > AUDIO_PORT_MAX_AUDIO_PROFILES) {
                if (halPort->num_audio_profiles >= AUDIO_PORT_MAX_AUDIO_PROFILES) {
                    ALOGE("%s, too many audio profiles", __func__);
                    result = BAD_VALUE;
                    break;
@@ -914,7 +914,8 @@ status_t HidlUtils::audioTransportsToHal(const hidl_vec<AudioTransport>& transpo
                                result);
                break;
            case AudioTransport::AudioCapability::hidl_discriminator::edid:
                if (halPort->num_extra_audio_descriptors > AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS) {
                if (halPort->num_extra_audio_descriptors >=
                    AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS) {
                    ALOGE("%s, too many extra audio descriptors", __func__);
                    result = BAD_VALUE;
                    break;
+33 −9
Original line number Diff line number Diff line
@@ -954,6 +954,18 @@ TEST(HidlUtils, ConvertAudioPortConfig) {
    EXPECT_TRUE(audio_port_configs_are_equal(&halConfig, &halConfigBack));
}

static AudioProfile generateValidAudioProfile() {
    AudioProfile profile;
    profile.format = toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT);
    profile.sampleRates.resize(2);
    profile.sampleRates[0] = 44100;
    profile.sampleRates[1] = 48000;
    profile.channelMasks.resize(2);
    profile.channelMasks[0] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_MONO);
    profile.channelMasks[1] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO);
    return profile;
}

TEST(HidlUtils, ConvertInvalidAudioTransports) {
    hidl_vec<AudioTransport> invalid;
    struct audio_port_v7 halInvalid = {};
@@ -973,20 +985,32 @@ TEST(HidlUtils, ConvertInvalidAudioTransports) {
    invalid[0].audioCapability.edid(hidl_vec<uint8_t>(EXTRA_AUDIO_DESCRIPTOR_SIZE + 1));
    invalid[1].encapsulationType = "random string";
    EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid));

    // The size of audio profile must not be greater than the maximum value.
    invalid.resize(0);
    invalid.resize(AUDIO_PORT_MAX_AUDIO_PROFILES + 1);
    for (size_t i = 0; i < invalid.size(); ++i) {
        invalid[i].audioCapability.profile(generateValidAudioProfile());
        invalid[i].encapsulationType =
                toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_NONE);
    }
    EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid));

    // The size of extra audio descriptors must not be greater than the maximum value.
    invalid.resize(0);
    invalid.resize(AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS + 1);
    for (size_t i = 0; i < invalid.size(); ++i) {
        invalid[i].audioCapability.edid({0x11, 0x06, 0x01});
        invalid[i].encapsulationType =
                toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_IEC61937);
    }
    EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid));
}

TEST(HidlUtils, ConvertAudioTransports) {
    hidl_vec<AudioTransport> transports;
    transports.resize(2);
    AudioProfile profile;
    profile.format = toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT);
    profile.sampleRates.resize(2);
    profile.sampleRates[0] = 44100;
    profile.sampleRates[1] = 48000;
    profile.channelMasks.resize(2);
    profile.channelMasks[0] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_MONO);
    profile.channelMasks[1] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO);
    transports[0].audioCapability.profile(profile);
    transports[0].audioCapability.profile(generateValidAudioProfile());
    hidl_vec<uint8_t> shortAudioDescriptor({0x11, 0x06, 0x01});
    transports[0].encapsulationType =
            toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_NONE);
+21 −0
Original line number Diff line number Diff line
@@ -44,6 +44,27 @@ cc_test {
    ],
}

cc_library_static {
    name: "VtsHalWifiV1_4TargetTestUtil",
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: [
        "wifi_hidl_test_utils_1_4.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.4",
        "libwifi-system-iface",
    ],
}

// SoftAP-specific tests, similar to VtsHalWifiApV1_0TargetTest.
cc_test {
    name: "VtsHalWifiApV1_4TargetTest",
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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>
#include <android-base/logging.h>

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

#include <android/hardware/wifi/1.4/IWifi.h>
#include <android/hardware/wifi/1.4/IWifiApIface.h>
#include <android/hardware/wifi/1.4/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::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::wifi::V1_0::ChipModeId;
using ::android::hardware::wifi::V1_0::IfaceType;
using ::android::hardware::wifi::V1_4::IWifiApIface;
using ::android::hardware::wifi::V1_4::IWifiChip;

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

sp<IWifiApIface> getWifiApIface_1_4(const std::string& instance_name) {
    LOG(INFO) << "getWifiApIface_1_4";
    ChipModeId mode_id;
    sp<IWifiChip> wifi_chip_ = getWifiChip_1_4(instance_name);
    configureChipToSupportIfaceType(wifi_chip_, IfaceType::AP, &mode_id);
    const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createApIface);
    LOG(INFO) << "getWifiApIface_1_4 done to status_and_iface";
    return IWifiApIface::castFrom(status_and_iface.second);
}
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.4/IWifi.h>
#include <android/hardware/wifi/1.4/IWifiApIface.h>
#include <android/hardware/wifi/1.4/IWifiChip.h>

#include <getopt.h>

#include <VtsHalHidlTargetTestEnvBase.h>
// Helper functions to obtain references to the various HIDL interface objects.
// Note: We only have a single instance of each of these objects currently.
// These helper functions should be modified to return vectors if we support
// multiple instances.
android::sp<android::hardware::wifi::V1_4::IWifiChip> getWifiChip_1_4(
        const std::string& instance_name);
android::sp<android::hardware::wifi::V1_4::IWifiApIface> getWifiApIface_1_4(
        const std::string& instance_name);
Loading