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

Commit b683609c authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5180536 from 412352b3 to pi-platform-release

Change-Id: I378cf141149edc38d0e65749085821427b973578
parents c5193fce 412352b3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -661,8 +661,8 @@ static R extract(Return<R> ret) {
        code;                                          \
    }

TEST_IO_STREAM(GetFrameCount, "Check that the stream frame count == the one it was opened with",
               ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount())))
TEST_IO_STREAM(GetFrameCount, "Check that getting stream frame count does not crash the HAL.",
               ASSERT_TRUE(stream->getFrameCount().isOk()))

TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with",
               ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate())))
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ cc_test {
        "libicuuc_stubdata",
        "libxml2",
    ],
    shared_libs: [
        "libfmq",
    ],
    header_libs: [
        "android.hardware.audio.common.util@all-versions",
    ],
+103 −21
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@
#include <fcntl.h>
#include <unistd.h>

#include <hwbinder/IPCThreadState.h>

#include <VtsHalHidlTargetTestBase.h>

#include <android-base/logging.h>
@@ -38,6 +40,8 @@
#include <android/hardware/audio/4.0/IPrimaryDevice.h>
#include <android/hardware/audio/4.0/types.h>
#include <android/hardware/audio/common/4.0/types.h>
#include <fmq/EventFlag.h>
#include <fmq/MessageQueue.h>

#include <common/all-versions/VersionUtils.h>

@@ -55,13 +59,17 @@ using std::vector;
using std::list;

using ::android::sp;
using ::android::hardware::Return;
using ::android::hardware::EventFlag;
using ::android::hardware::hidl_bitfield;
using ::android::hardware::hidl_enum_iterator;
using ::android::hardware::hidl_handle;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::kSynchronizedReadWrite;
using ::android::hardware::IPCThreadState;
using ::android::hardware::MessageQueue;
using ::android::hardware::MQDescriptorSync;
using ::android::hardware::Return;
using ::android::hardware::audio::V4_0::AudioDrain;
using ::android::hardware::audio::V4_0::DeviceAddress;
using ::android::hardware::audio::V4_0::IDevice;
@@ -71,6 +79,7 @@ using TtyMode = ::android::hardware::audio::V4_0::IPrimaryDevice::TtyMode;
using ::android::hardware::audio::V4_0::IDevicesFactory;
using ::android::hardware::audio::V4_0::IStream;
using ::android::hardware::audio::V4_0::IStreamIn;
using ::android::hardware::audio::V4_0::MessageQueueFlagBits;
using ::android::hardware::audio::V4_0::TimeSpec;
using ReadParameters = ::android::hardware::audio::V4_0::IStreamIn::ReadParameters;
using ReadStatus = ::android::hardware::audio::V4_0::IStreamIn::ReadStatus;
@@ -164,6 +173,7 @@ TEST_F(AudioHidlTest, OpenDeviceInvalidParameter) {

TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
    doc::test("Calling openDevice(\"primary\") should return the primary device.");
    {
        Result result;
        sp<IDevice> baseDevice;
        ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice)));
@@ -173,6 +183,15 @@ TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
        Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice);
        ASSERT_TRUE(primaryDevice.isOk());
        ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr);
    }  // Destroy local IDevice proxy
    // FIXME: there is no way to know when the remote IDevice is being destroyed
    //        Binder does not support testing if an object is alive, thus
    //        wait for 100ms to let the binder destruction propagates and
    //        the remote device has the time to be destroyed.
    //        flushCommand makes sure all local command are sent, thus should reduce
    //        the latency between local and remote destruction.
    IPCThreadState::self()->flushCommands();
    usleep(100);
}

//////////////////////////////////////////////////////////////////////////////
@@ -489,7 +508,7 @@ TEST_F(AudioPrimaryHidlTest, getParameters) {
}

//////////////////////////////////////////////////////////////////////////////
/////////////////////////////// getMicrophones ///////////////////////////////
/////////////////////////// get(Active)Microphones ///////////////////////////
//////////////////////////////////////////////////////////////////////////////

TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
@@ -497,6 +516,76 @@ TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
    hidl_vec<MicrophoneInfo> microphones;
    ASSERT_OK(device->getMicrophones(returnIn(res, microphones)));
    ASSERT_OK(res);
    if (microphones.size() > 0) {
        // When there is microphone on the phone, try to open an input stream
        // and query for the active microphones.
        doc::test(
            "Make sure getMicrophones always succeeds"
            "and getActiveMicrophones always succeeds when recording from these microphones.");
        AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE;
        AudioConfig config{};
        config.channelMask = mkBitfield(AudioChannelMask::IN_MONO);
        config.sampleRateHz = 8000;
        config.format = AudioFormat::PCM_16_BIT;
        auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE);
        const SinkMetadata initialMetadata = {{{AudioSource::MIC, 1 /* gain */}}};
        EventFlag* efGroup;
        for (auto microphone : microphones) {
            if (microphone.deviceAddress.device != AudioDevice::IN_BUILTIN_MIC) {
                continue;
            }
            sp<IStreamIn> stream;
            AudioConfig suggestedConfig{};
            ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, config, flags,
                                              initialMetadata,
                                              returnIn(res, stream, suggestedConfig)));
            if (res != Result::OK) {
                ASSERT_TRUE(stream == nullptr);
                AudioConfig suggestedConfigRetry{};
                ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress,
                                                  suggestedConfig, flags, initialMetadata,
                                                  returnIn(res, stream, suggestedConfigRetry)));
            }
            ASSERT_OK(res);
            hidl_vec<MicrophoneInfo> activeMicrophones;
            Result readRes;
            typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ;
            typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ;
            std::unique_ptr<CommandMQ> commandMQ;
            std::unique_ptr<DataMQ> dataMQ;
            size_t frameSize = stream->getFrameSize();
            size_t frameCount = stream->getBufferSize() / frameSize;
            ASSERT_OK(stream->prepareForReading(
                frameSize, frameCount, [&](auto r, auto& c, auto& d, auto&, auto&) {
                    readRes = r;
                    if (readRes == Result::OK) {
                        commandMQ.reset(new CommandMQ(c));
                        dataMQ.reset(new DataMQ(d));
                        if (dataMQ->isValid() && dataMQ->getEventFlagWord()) {
                            EventFlag::createEventFlag(dataMQ->getEventFlagWord(), &efGroup);
                        }
                    }
                }));
            ASSERT_OK(readRes);
            ReadParameters params;
            params.command = IStreamIn::ReadCommand::READ;
            ASSERT_TRUE(commandMQ != nullptr);
            ASSERT_TRUE(commandMQ->isValid());
            ASSERT_TRUE(commandMQ->write(&params));
            efGroup->wake(static_cast<uint32_t>(MessageQueueFlagBits::NOT_FULL));
            uint32_t efState = 0;
            efGroup->wait(static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY), &efState);
            if (efState & static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY)) {
                ASSERT_OK(stream->getActiveMicrophones(returnIn(res, activeMicrophones)));
                ASSERT_OK(res);
                ASSERT_NE(0U, activeMicrophones.size());
            }
            stream->close();
            if (efGroup) {
                EventFlag::deleteEventFlag(&efGroup);
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////
@@ -734,8 +823,8 @@ static R extract(Return<R> ret) {
        code;                                          \
    }

TEST_IO_STREAM(GetFrameCount, "Check that the stream frame count == the one it was opened with",
               ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount())))
TEST_IO_STREAM(GetFrameCount, "Check that getting stream frame count does not crash the HAL.",
               ASSERT_TRUE(stream->getFrameCount().isOk()))

TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with",
               ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate())))
@@ -1104,14 +1193,6 @@ TEST_P(InputStreamTest, updateSinkMetadata) {
    ASSERT_OK(stream->updateSinkMetadata(initialMetadata));
}

TEST_P(InputStreamTest, getActiveMicrophones) {
    doc::test("Getting active microphones should always succeed");
    hidl_vec<MicrophoneInfo> microphones;
    ASSERT_OK(device->getMicrophones(returnIn(res, microphones)));
    ASSERT_OK(res);
    ASSERT_TRUE(microphones.size() > 0);
}

//////////////////////////////////////////////////////////////////////////////
///////////////////////////////// StreamOut //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -1402,6 +1483,7 @@ TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) {
        "Make sure setBtHfpVolume is either not supported or "
        "only succeed if volume is in [0,1]");
    auto ret = device->setBtHfpVolume(0.0);
    ASSERT_TRUE(ret.isOk());
    if (ret == Result::NOT_SUPPORTED) {
        doc::partialTest("setBtHfpVolume is not supported");
        return;
+8 −0
Original line number Diff line number Diff line
@@ -1172,6 +1172,14 @@ TEST_F(CameraHidlTest, noHal1AfterP) {
    }
    ASSERT_GT(firstApiLevel, 0); // first_api_level must exist

    // all devices with first API level == 28 and <= 1GB of RAM must set low_ram
    // and thus be allowed to continue using HAL1
    if ((firstApiLevel == HAL1_PHASE_OUT_API_LEVEL) &&
        (property_get_bool("ro.config.low_ram", /*default*/ false))) {
        ALOGI("Hal1 allowed for low ram device");
        return;
    }

    if (firstApiLevel >= HAL1_PHASE_OUT_API_LEVEL) {
        hidl_vec<hidl_string> cameraDeviceNames = getCameraDeviceNames(mProvider);
        for (const auto& name : cameraDeviceNames) {
+51 −26
Original line number Diff line number Diff line
@@ -119,6 +119,11 @@ IGnssConfiguration::BlacklistedSource FindStrongFrequentNonGpsSource(
    struct ComparableBlacklistedSource {
        IGnssConfiguration::BlacklistedSource id;

        ComparableBlacklistedSource() {
            id.constellation = GnssConstellationType::UNKNOWN;
            id.svid = 0;
        }

        bool operator<(const ComparableBlacklistedSource& compare) const {
            return ((id.svid < compare.id.svid) || ((id.svid == compare.id.svid) &&
                                                    (id.constellation < compare.id.constellation)));
@@ -191,18 +196,21 @@ IGnssConfiguration::BlacklistedSource FindStrongFrequentNonGpsSource(
 * 3) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding
 * GnssStatus does not use those satellites.
 * 4a & b) Turns off location, and send in empty blacklist.
 * 5) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding
 * 5a) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding
 * GnssStatus does re-use at least the previously strongest satellite
 * 5b) Retry a few times, in case GNSS search strategy takes a while to reacquire even the
 * formerly strongest satellite
 */
TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
    const int kLocationsToAwait = 3;
    const int kRetriesToUnBlacklist = 10;

    StartAndCheckLocations(kLocationsToAwait);

    // Tolerate 1 less sv status to handle edge cases in reporting.
    EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
    ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
          kLocationsToAwait);
    ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations (%d received)",
          (int)list_gnss_sv_status_.size(), kLocationsToAwait, location_called_count_);

    /*
     * Identify strongest SV seen at least kLocationsToAwait -1 times
@@ -237,13 +245,18 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
    // retry and ensure satellite not used
    list_gnss_sv_status_.clear();

    location_called_count_ = 0;
    StartAndCheckLocations(kLocationsToAwait);

    // early exit if test is being run with insufficient signal
    if (location_called_count_ == 0) {
        ALOGE("0 Gnss locations received - ensure sufficient signal and retry");
    }
    ASSERT_TRUE(location_called_count_ > 0);

    // Tolerate 1 less sv status to handle edge cases in reporting.
    EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
    ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
          kLocationsToAwait);
    ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations (%d received)",
          (int)list_gnss_sv_status_.size(), kLocationsToAwait, location_called_count_);
    for (const auto& gnss_sv_status : list_gnss_sv_status_) {
        for (uint32_t iSv = 0; iSv < gnss_sv_status.numSvs; iSv++) {
            const auto& gnss_sv = gnss_sv_status.gnssSvList[iSv];
@@ -260,17 +273,28 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
    ASSERT_TRUE(result.isOk());
    EXPECT_TRUE(result);

    bool strongest_sv_is_reobserved = false;
    // do several loops awaiting a few locations, allowing non-immediate reacquisition strategies
    int unblacklist_loops_remaining = kRetriesToUnBlacklist;
    while (!strongest_sv_is_reobserved && (unblacklist_loops_remaining-- > 0)) {
        StopAndClearLocations();
        list_gnss_sv_status_.clear();

        StartAndCheckLocations(kLocationsToAwait);

        // early exit loop if test is being run with insufficient signal
        if (location_called_count_ == 0) {
            ALOGE("0 Gnss locations received - ensure sufficient signal and retry");
        }
        ASSERT_TRUE(location_called_count_ > 0);

        // Tolerate 1 less sv status to handle edge cases in reporting.
        EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
    ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
          kLocationsToAwait);
        ALOGD(
            "Clear blacklist, observed %d GnssSvStatus, while awaiting %d Locations"
            ", tries remaining %d",
            (int)list_gnss_sv_status_.size(), kLocationsToAwait, unblacklist_loops_remaining);

    bool strongest_sv_is_reobserved = false;
        for (const auto& gnss_sv_status : list_gnss_sv_status_) {
            for (uint32_t iSv = 0; iSv < gnss_sv_status.numSvs; iSv++) {
                const auto& gnss_sv = gnss_sv_status.gnssSvList[iSv];
@@ -283,6 +307,7 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
            }
            if (strongest_sv_is_reobserved) break;
        }
    }
    EXPECT_TRUE(strongest_sv_is_reobserved);
    StopAndClearLocations();
}
@@ -304,8 +329,8 @@ TEST_F(GnssHalTest, BlacklistConstellation) {

    // Tolerate 1 less sv status to handle edge cases in reporting.
    EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait);
    ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(),
          kLocationsToAwait);
    ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations (%d received)",
          (int)list_gnss_sv_status_.size(), kLocationsToAwait, location_called_count_);

    // Find first non-GPS constellation to blacklist
    GnssConstellationType constellation_to_blacklist = GnssConstellationType::UNKNOWN;
Loading