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

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

Snap for 4731145 from 3c50fab0 to pi-release

Change-Id: I715d042786e189575e5ce9a0f7c231883589cf5f
parents de4546f0 3c50fab0
Loading
Loading
Loading
Loading
+62 −16
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ using ::android::hardware::audio::V4_0::AudioDrain;
using ::android::hardware::audio::V4_0::DeviceAddress;
using ::android::hardware::audio::V4_0::IDevice;
using ::android::hardware::audio::V4_0::IPrimaryDevice;
using Rotation = ::android::hardware::audio::V4_0::IPrimaryDevice::Rotation;
using TtyMode = ::android::hardware::audio::V4_0::IPrimaryDevice::TtyMode;
using ::android::hardware::audio::V4_0::IDevicesFactory;
using ::android::hardware::audio::V4_0::IStream;
@@ -95,6 +96,11 @@ using ::android::hardware::audio::common::utils::mkBitfield;

using namespace ::android::hardware::audio::common::test::utility;

// Typical accepted results from interface methods
static auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
static auto okOrNotSupportedOrInvalidArgs = {Result::OK, Result::NOT_SUPPORTED,
                                             Result::INVALID_ARGUMENTS};

class AudioHidlTestEnvironment : public ::Environment {
   public:
    virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); }
@@ -439,11 +445,7 @@ INSTANTIATE_TEST_CASE_P(
TEST_F(AudioPrimaryHidlTest, setScreenState) {
    doc::test("Check that the hal can receive the screen state");
    for (bool turnedOn : {false, true, true, false, false}) {
        auto ret = device->setScreenState(turnedOn);
        ASSERT_IS_OK(ret);
        Result result = ret;
        auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
        ASSERT_RESULT(okOrNotSupported, result);
        ASSERT_RESULT(okOrNotSupported, device->setScreenState(turnedOn));
    }
}

@@ -783,7 +785,7 @@ TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as sup
               testCapabilityGetter("getSupportedFormat", stream.get(), &getSupportedFormats,
                                    &IStream::getFormat, &IStream::setFormat))

static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
static void testGetDevices(IStream* stream, AudioDevice expectedDevice) {
    hidl_vec<DeviceAddress> devices;
    Result res;
    ASSERT_OK(stream->getDevices(returnIn(res, devices)));
@@ -798,11 +800,11 @@ static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
        << "\n  Actual: " << ::testing::PrintToString(device);
}

TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with",
TEST_IO_STREAM(GetDevices, "Check that the stream device == the one it was opened with",
               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
                                          : testGetDevice(stream.get(), address.device))
                                          : testGetDevices(stream.get(), address.device))

static void testSetDevice(IStream* stream, const DeviceAddress& address) {
static void testSetDevices(IStream* stream, const DeviceAddress& address) {
    DeviceAddress otherAddress = address;
    otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
                                                                      : AudioDevice::IN_BUILTIN_MIC;
@@ -811,9 +813,9 @@ static void testSetDevice(IStream* stream, const DeviceAddress& address) {
    ASSERT_OK(stream->setDevices({address}));  // Go back to the original value
}

TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
                                          : testSetDevice(stream.get(), address))
                                          : testSetDevices(stream.get(), address))

static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) {
    uint32_t sampleRateHz;
@@ -833,10 +835,8 @@ TEST_IO_STREAM(GetAudioProperties,
               "Check that the stream audio properties == the ones it was opened with",
               testGetAudioProperties(stream.get(), audioConfig))

static auto invalidArgsOrNotSupportedOrOK = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED,
                                             Result::OK};
TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value",
               ASSERT_RESULT(invalidArgsOrNotSupportedOrOK, stream->setHwAvSync(666)))
               ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, stream->setHwAvSync(666)))

static void checkGetHwAVSync(IDevice* device) {
    Result res;
@@ -882,7 +882,7 @@ TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing param
               // error code when a key is not supported.
               // To allow implementation to just wrapped the legacy one, consider OK as a
               // valid result for setting a non existing parameter.
               ASSERT_RESULT(invalidArgsOrNotSupportedOrOK,
               ASSERT_RESULT(okOrNotSupportedOrInvalidArgs,
                             stream->setParameters({}, {{"non existing key", "0"}})))

TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error",
@@ -1147,7 +1147,6 @@ static bool isAsyncModeSupported(IStreamOut* stream) {
    auto res = stream->setCallback(new MockOutCallbacks);
    stream->clearCallback();  // try to restore the no callback state, ignore
                              // any error
    auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
    EXPECT_RESULT(okOrNotSupported, res);
    return res.isOk() ? res == Result::OK : false;
}
@@ -1257,6 +1256,11 @@ TEST_P(OutputStreamTest, GetPresentationPositionStop) {
    ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime);
}

TEST_P(OutputStreamTest, SelectPresentation) {
    doc::test("Verify that presentation selection does not crash");
    ASSERT_RESULT(okOrNotSupported, stream->selectPresentation(0, 0));
}

//////////////////////////////////////////////////////////////////////////////
/////////////////////////////// PrimaryDevice ////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -1283,6 +1287,42 @@ TEST_F(AudioPrimaryHidlTest, setMode) {
    }
}

TEST_F(AudioPrimaryHidlTest, setBtHfpSampleRate) {
    doc::test(
        "Make sure setBtHfpSampleRate either succeeds or "
        "indicates that it is not supported at all, or that the provided value is invalid");
    for (auto samplingRate : {8000, 16000, 22050, 24000}) {
        ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, device->setBtHfpSampleRate(samplingRate));
    }
}

TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) {
    doc::test(
        "Make sure setBtHfpVolume is either not supported or "
        "only succeed if volume is in [0,1]");
    auto ret = device->setBtHfpVolume(0.0);
    if (ret == Result::NOT_SUPPORTED) {
        doc::partialTest("setBtHfpVolume is not supported");
        return;
    }
    testUnitaryGain([](float volume) { return device->setBtHfpVolume(volume); });
}

TEST_F(AudioPrimaryHidlTest, setBtScoHeadsetDebugName) {
    doc::test(
        "Make sure setBtScoHeadsetDebugName either succeeds or "
        "indicates that it is not supported");
    ASSERT_RESULT(okOrNotSupported, device->setBtScoHeadsetDebugName("test"));
}

TEST_F(AudioPrimaryHidlTest, updateRotation) {
    doc::test("Check that the hal can receive the current rotation");
    for (Rotation rotation : {Rotation::DEG_0, Rotation::DEG_90, Rotation::DEG_180,
                              Rotation::DEG_270, Rotation::DEG_0}) {
        ASSERT_RESULT(okOrNotSupported, device->updateRotation(rotation));
    }
}

TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) {
    doc::test("Query and set the BT SCO NR&EC state");
    testOptionalAccessors("BtScoNrecEnabled", {true, false, true},
@@ -1297,6 +1337,12 @@ TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) {
                          &IPrimaryDevice::getBtScoWidebandEnabled);
}

TEST_F(BoolAccessorPrimaryHidlTest, setGetBtHfpEnabled) {
    doc::test("Query and set the BT HFP state");
    testOptionalAccessors("BtHfpEnabled", {true, false, true}, &IPrimaryDevice::setBtHfpEnabled,
                          &IPrimaryDevice::getBtHfpEnabled);
}

using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>;
TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {
    doc::test("Query and set the TTY mode state");
+11 −1
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

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

#ifdef AUDIO_HAL_VERSION_4_0
#include <cmath>
#endif

namespace android {
namespace hardware {
namespace audio {
@@ -244,7 +248,13 @@ Return<Result> PrimaryDevice::setBtHfpSampleRate(uint32_t sampleRateHz) {
    return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_SET_SAMPLING_RATE, int(sampleRateHz));
}
Return<Result> PrimaryDevice::setBtHfpVolume(float volume) {
    return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_VOLUME, volume);
    if (!all_versions::implementation::isGainNormalized(volume)) {
        ALOGW("Can not set BT HFP volume (%f) outside [0,1]", volume);
        return Result::INVALID_ARGUMENTS;
    }
    // Map the normalized volume onto the range of [0, 15]
    return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_VOLUME,
                             static_cast<int>(std::round(volume * 15)));
}
Return<Result> PrimaryDevice::updateRotation(IPrimaryDevice::Rotation rotation) {
    // legacy API expects the rotation in degree
+22 −18
Original line number Diff line number Diff line
@@ -654,7 +654,8 @@ enum VehicleProperty : int32_t {
     * HVAC current temperature.
     *
     * @change_mode VehiclePropertyChangeMode:ON_CHANGE
     * @access VehiclePropertyAccess:READ_WRITE
     * @access VehiclePropertyAccess:READ
     * @unit VehicleUnit:CELSIUS
     */
    HVAC_TEMPERATURE_CURRENT = (
        0x0502
@@ -667,6 +668,7 @@ enum VehicleProperty : int32_t {
     *
     * @change_mode VehiclePropertyChangeMode:ON_CHANGE
     * @access VehiclePropertyAccess:READ_WRITE
     * @unit VehicleUnit:CELSIUS
     */
    HVAC_TEMPERATURE_SET = (
        0x0503
@@ -791,7 +793,7 @@ enum VehicleProperty : int32_t {
        | VehicleArea:SEAT),

    /**
     * Seat temperature
     * Seat heating/cooling
     *
     * Negative values indicate cooling.
     * 0 indicates off.
@@ -847,9 +849,11 @@ enum VehicleProperty : int32_t {
    /**
     * Temperature units for display
     *
     * Indicates whether the temperature is in Celsius, Fahrenheit, or a
     * different unit from VehicleUnit enum.  This parameter MAY be used for
     * displaying any HVAC temperature in the system.
     * Indicates whether the vehicle is displaying temperature to the user as
     * Celsius or Fahrenheit.
     * This parameter MAY be used for displaying any HVAC temperature in the system.
     * Values must be one of VehicleUnit::CELSIUS or VehicleUnit::FAHRENHEIT
     * Note that internally, all temperatures are represented in floating point Celsius.
     *
     * @change_mode VehiclePropertyChangeMode:ON_CHANGE
     * @access VehiclePropertyAccess:READ_WRITE
@@ -1629,8 +1633,8 @@ enum VehicleProperty : int32_t {
    /**
     * Window Position
     *
     * Max = window up / closed
     * Min = window down / open
     * Min = window up / closed
     * Max = window down / open
     *
     * For a window that may open out of plane (i.e. vent mode of sunroof) this
     * parameter will work with negative values as follows:
@@ -1652,9 +1656,9 @@ enum VehicleProperty : int32_t {
    /**
     * Window Move
     *
     * Max = window up / closed
     * Min = window down / open
     * Magnitude denotes relative speed.  I.e. +2 is faster than +1 in raising
     * Max = Open the window as fast as possible
     * Min = Close the window as fast as possible
     * Magnitude denotes relative speed.  I.e. +2 is faster than +1 in closing
     * the window.
     *
     * For a window that may open out of plane (i.e. vent mode of sunroof) this
@@ -1668,7 +1672,7 @@ enum VehicleProperty : int32_t {
     *   Max = close the vent, automatically stop when vent is closed.
     *   Min = open the vent further, automatically stop when vent is fully open.
     *
     * If window is in the closed position:
     * If sunroof is in the closed position:
     *   Max = open the sunroof, automatically stop when sunroof is fully open.
     *   Min = open the vent, automatically stop when vent is fully open.
     *
+1 −1
Original line number Diff line number Diff line
@@ -299,7 +299,7 @@ f2904a4c108ad1b93eb2fa4e43b82bd01ce1ff26156316e49d1d9fc80dfecaad android.hardwar
3b17c1fdfc389e0abe626c37054954b07201127d890c2bc05d47613ec1f4de4f android.hardware.automotive.evs@1.0::types
b3caf524c46a47d67e6453a34419e1881942d059e146cda740502670e9a752c3 android.hardware.automotive.vehicle@2.0::IVehicle
7ce8728b27600e840cacf0a832f6942819fe535f9d3797ae052d5eef5065921c android.hardware.automotive.vehicle@2.0::IVehicleCallback
848fb32d5ca79dd527d966e67c0af5874b6d7b361246b491e315cf7dea7888ab android.hardware.automotive.vehicle@2.0::types
2e1815967a3e3278a7f304ed7efc04fbc56d0bb65b3126248c3a0d515b93f63d android.hardware.automotive.vehicle@2.0::types
32cc50cc2a7658ec613c0c2dd2accbf6a05113b749852879e818b8b7b438db19 android.hardware.bluetooth.a2dp@1.0::IBluetoothAudioHost
ff4be64d7992f8bec97dff37f35450e79b3430c61f85f54322ce45bef229dc3b android.hardware.bluetooth.a2dp@1.0::IBluetoothAudioOffload
27f22d2e873e6201f9620cf4d8e2facb25bd0dd30a2b911e441b4600d560fa62 android.hardware.bluetooth.a2dp@1.0::types
+25 −7
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ constexpr ChipModeId kV2ChipModeId = 2;
constexpr char kCpioMagic[] = "070701";
constexpr size_t kMaxBufferSizeBytes = 1024 * 1024;
constexpr uint32_t kMaxRingBufferFileAgeSeconds = 60 * 60;
constexpr uint32_t kMaxRingBufferFileNum = 20;
constexpr char kTombstoneFolderPath[] = "/data/vendor/tombstones/wifi/";

template <typename Iface>
@@ -104,7 +105,9 @@ std::string getP2pIfaceName() {
    return buffer.data();
}

// delete files older than a predefined time in the wifi tombstone dir
// delete files that meet either conditions:
// 1. older than a predefined time in the wifi tombstone dir.
// 2. Files in excess to a predefined amount, starting from the oldest ones
bool removeOldFilesInternal() {
    time_t now = time(0);
    const time_t delete_files_before = now - kMaxRingBufferFileAgeSeconds;
@@ -116,6 +119,7 @@ bool removeOldFilesInternal() {
    unique_fd dir_auto_closer(dirfd(dir_dump));
    struct dirent* dp;
    bool success = true;
    std::list<std::pair<const time_t, std::string>> valid_files;
    while ((dp = readdir(dir_dump))) {
        if (dp->d_type != DT_REG) {
            continue;
@@ -129,13 +133,24 @@ bool removeOldFilesInternal() {
            success = false;
            continue;
        }
        if (cur_file_stat.st_mtime >= delete_files_before) {
            continue;
        }
        if (unlink(cur_file_path.c_str()) != 0) {
        const time_t cur_file_time = cur_file_stat.st_mtime;
        valid_files.push_back(
            std::pair<const time_t, std::string>(cur_file_time, cur_file_path));
    }
    valid_files.sort();  // sort the list of files by last modified time from
                         // small to big.
    uint32_t cur_file_count = valid_files.size();
    for (auto cur_file : valid_files) {
        if (cur_file_count > kMaxRingBufferFileNum ||
            cur_file.first < delete_files_before) {
            if (unlink(cur_file.second.c_str()) != 0) {
                LOG(ERROR) << "Error deleting file " << strerror(errno);
                success = false;
            }
            cur_file_count--;
        } else {
            break;
        }
    }
    return success;
}
@@ -309,6 +324,9 @@ WifiChip::WifiChip(
}

void WifiChip::invalidate() {
    if (!writeRingbufferFilesInternal()) {
        LOG(ERROR) << "Error writing files to flash";
    }
    invalidateAndRemoveAllIfaces();
    legacy_hal_.reset();
    event_cb_handler_.invalidate();