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

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

Snap for 7571196 from 0bb1ef2e to sc-v2-release

Change-Id: I257a340b72b37d16b8efcdc998c687a9b3297512
parents 623caef0 0bb1ef2e
Loading
Loading
Loading
Loading
+6 −17
Original line number Diff line number Diff line
@@ -53,6 +53,11 @@ TEST_P(AudioHidlDeviceTest, GetMicrophonesTest) {
        GTEST_SKIP() << "getMicrophones is not supported";  // returns
    }
    ASSERT_OK(res);

#if MAJOR_VERSION <= 6
    // In V7, 'getActiveMicrophones' is tested by the 'MicrophoneInfoInputStream'
    // test which uses the actual configuration of the device.

    if (microphones.size() > 0) {
        // When there is microphone on the phone, try to open an input stream
        // and query for the active microphones.
@@ -60,30 +65,13 @@ TEST_P(AudioHidlDeviceTest, GetMicrophonesTest) {
            "Make sure getMicrophones always succeeds"
            "and getActiveMicrophones always succeeds when recording from these microphones.");
        AudioConfig config{};
#if MAJOR_VERSION <= 6
        config.channelMask = mkEnumBitfield(AudioChannelMask::IN_MONO);
        config.sampleRateHz = 8000;
        config.format = AudioFormat::PCM_16_BIT;
        auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE);
        const SinkMetadata initMetadata = {{{.source = AudioSource::MIC, .gain = 1}}};
#elif MAJOR_VERSION >= 7
        config.base.channelMask = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_IN_MONO);
        config.base.sampleRateHz = 8000;
        config.base.format = toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT);
        hidl_vec<hidl_string> flags;
        const SinkMetadata initMetadata = {
                {{.source = toString(xsd::AudioSource::AUDIO_SOURCE_MIC),
                  .gain = 1,
                  .tags = {},
                  .channelMask = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_IN_MONO)}}};
#endif
        for (auto microphone : microphones) {
#if MAJOR_VERSION <= 6
            if (microphone.deviceAddress.device != AudioDevice::IN_BUILTIN_MIC) {
#elif MAJOR_VERSION >= 7
            if (xsd::stringToAudioDevice(microphone.deviceAddress.deviceType) !=
                xsd::AudioDevice::AUDIO_DEVICE_IN_BUILTIN_MIC) {
#endif
                continue;
            }
            sp<IStreamIn> stream;
@@ -106,6 +94,7 @@ TEST_P(AudioHidlDeviceTest, GetMicrophonesTest) {
            EXPECT_NE(0U, activeMicrophones.size());
        }
    }
#endif  // MAJOR_VERSION <= 6
}

TEST_P(AudioHidlDeviceTest, SetConnectedState) {
+61 −0
Original line number Diff line number Diff line
@@ -839,3 +839,64 @@ INSTANTIATE_TEST_CASE_P(PcmOnlyConfigInputStream, PcmOnlyConfigInputStreamTest,
                        ::testing::ValuesIn(getInputDevicePcmOnlyConfigParameters()),
                        &DeviceConfigParameterToString);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PcmOnlyConfigInputStreamTest);

static const std::vector<DeviceConfigParameter>& getBuiltinMicConfigParameters() {
    static const std::vector<DeviceConfigParameter> parameters = [] {
        auto allParams = getInputDeviceConfigParameters();
        std::vector<DeviceConfigParameter> builtinMicParams;
        std::copy_if(allParams.begin(), allParams.end(), std::back_inserter(builtinMicParams),
                     [](auto cfg) {
                         // The built in mic may participate in various scenarios:
                         // FAST, HW_HOTWORD, MMAP NOIRQ, which are indicated by flags.
                         // We are only interested in testing the simplest scenario w/o any flags.
                         if (!std::get<PARAM_FLAGS>(cfg).empty()) return false;
                         auto maybeSourceDevice = getCachedPolicyConfig().getSourceDeviceForMixPort(
                                 std::get<PARAM_DEVICE_NAME>(std::get<PARAM_DEVICE>(cfg)),
                                 std::get<PARAM_PORT_NAME>(cfg));
                         return maybeSourceDevice.has_value() &&
                                xsd::stringToAudioDevice(maybeSourceDevice.value().deviceType) ==
                                        xsd::AudioDevice::AUDIO_DEVICE_IN_BUILTIN_MIC;
                     });
        return builtinMicParams;
    }();
    return parameters;
}

class MicrophoneInfoInputStreamTest : public InputStreamTest {};

TEST_P(MicrophoneInfoInputStreamTest, GetActiveMicrophones) {
    doc::test(
            "Make sure getActiveMicrophones always succeeds when recording "
            "from the built-in microphone.");
    hidl_vec<MicrophoneInfo> microphones;
    ASSERT_OK(getDevice()->getMicrophones(returnIn(res, microphones)));
    if (res == Result::NOT_SUPPORTED) {
        GTEST_SKIP() << "getMicrophones is not supported";  // returns
    }
    ASSERT_OK(res);

    auto maybeSourceAddress =
            getCachedPolicyConfig().getSourceDeviceForMixPort(getDeviceName(), getMixPortName());
    ASSERT_TRUE(maybeSourceAddress.has_value())
            << "No source device found for mix port " << getMixPortName() << " (module "
            << getDeviceName() << ")";

    for (auto microphone : microphones) {
        if (microphone.deviceAddress == maybeSourceAddress.value()) {
            StreamReader reader(stream.get(), stream->getBufferSize());
            ASSERT_TRUE(reader.start());
            reader.pause();  // This ensures that at least one read has happened.
            EXPECT_FALSE(reader.hasError());

            hidl_vec<MicrophoneInfo> activeMicrophones;
            ASSERT_OK(stream->getActiveMicrophones(returnIn(res, activeMicrophones)));
            ASSERT_OK(res);
            EXPECT_NE(0U, activeMicrophones.size());
        }
    }
}

INSTANTIATE_TEST_CASE_P(MicrophoneInfoInputStream, MicrophoneInfoInputStreamTest,
                        ::testing::ValuesIn(getBuiltinMicConfigParameters()),
                        &DeviceConfigParameterToString);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MicrophoneInfoInputStreamTest);
+20 −15
Original line number Diff line number Diff line
@@ -249,35 +249,40 @@ TEST_P(GnssHalTest, TestGnssAntennaInfo) {

/*
 * TestGnssSvInfoFields:
 * Gets 1 location and a GnssSvInfo, and verifies
 * 1. basebandCN0DbHz is valid.
 * Gets 1 location and a (non-empty) GnssSvInfo, and verifies basebandCN0DbHz is valid.
 */
TEST_P(GnssHalTest, TestGnssSvInfoFields) {
    gnss_cb_->location_cbq_.reset();
    gnss_cb_->sv_info_list_cbq_.reset();
    StartAndCheckFirstLocation(/* min_interval_msec= */ 1000, /* low_power_mode= */ false);
    int location_called_count = gnss_cb_->location_cbq_.calledCount();

    // Tolerate 1 less sv status to handle edge cases in reporting.
    int sv_info_list_cbq_size = gnss_cb_->sv_info_list_cbq_.size();
    EXPECT_GE(sv_info_list_cbq_size, 0);
    ALOGD("Observed %d GnssSvStatus, while awaiting one location (%d received)",
          sv_info_list_cbq_size, location_called_count);

    // Get the last sv_info_list
    std::list<hidl_vec<IGnssCallback_2_1::GnssSvInfo>> sv_info_vec_list;
    gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_vec_list, sv_info_list_cbq_size, 1);
    hidl_vec<IGnssCallback_2_1::GnssSvInfo> last_sv_info_list = sv_info_vec_list.back();

          gnss_cb_->sv_info_list_cbq_.size(), location_called_count);

    // Wait for up to kNumSvInfoLists events for kTimeoutSeconds for each event.
    int kTimeoutSeconds = 2;
    int kNumSvInfoLists = 4;
    std::list<hidl_vec<IGnssCallback_2_1::GnssSvInfo>> sv_info_lists;
    hidl_vec<IGnssCallback_2_1::GnssSvInfo> last_sv_info_list;

    do {
        EXPECT_GT(gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_lists, kNumSvInfoLists,
                                                       kTimeoutSeconds),
                  0);
        last_sv_info_list = sv_info_lists.back();
    } while (last_sv_info_list.size() == 0);

    ALOGD("last_sv_info size = %d", (int)last_sv_info_list.size());
    bool nonZeroCn0Found = false;
    for (auto sv_info : last_sv_info_list) {
        ASSERT_TRUE(sv_info.basebandCN0DbHz >= 0.0 && sv_info.basebandCN0DbHz <= 65.0);
        EXPECT_TRUE(sv_info.basebandCN0DbHz >= 0.0 && sv_info.basebandCN0DbHz <= 65.0);
        if (sv_info.basebandCN0DbHz > 0.0) {
            nonZeroCn0Found = true;
        }
    }
    // Assert at least one value is non-zero. Zero is ok in status as it's possibly
    // reporting a searched but not found satellite.
    ASSERT_TRUE(nonZeroCn0Found);
    EXPECT_TRUE(nonZeroCn0Found);
    StopAndClearLocations();
}

+1 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ cc_test {
        "libkeymint_vts_test_utils",
        "libpuresoftkeymasterdevice",
    ],
    test_config: "VtsRemotelyProvisionedComponentTests.xml",
    test_suites: [
        "general-tests",
        "vts",
+34 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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.
-->
<configuration description="Runs VtsHalRemotelyProvisionedComponentTargetTest.">
    <option name="test-suite-tag" value="apct" />
    <option name="test-suite-tag" value="apct-native" />

    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>

    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
        <option name="cleanup" value="true" />
        <option name="push-file"
            key="VtsHalRemotelyProvisionedComponentTargetTest"
            value="/data/local/tmp/VtsHalRemotelyProvisionedComponentTargetTest" />
    </target_preparer>

    <test class="com.android.tradefed.testtype.GTest" >
        <option name="native-test-device-path" value="/data/local/tmp" />
        <option name="module-name" value="VtsHalRemotelyProvisionedComponentTargetTest" />
        <option name="native-test-timeout" value="900000"/> <!-- 15 minutes -->
    </test>
</configuration>