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

Commit 845b3662 authored by Vlad Popa's avatar Vlad Popa
Browse files

CSD: fix setting rs2 to invalid value

When using hal csd interfaces we updated the RS2 even though the hal
method returned and error.

Test: atest SoundDoseHelperTest
Bug: 311328967
Change-Id: I81a6e763bd2314b675bcaa6680750285b00fe670
parent 23c2a376
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -144,15 +144,24 @@ void SoundDoseManager::setOutputRs2UpperBound(float rs2Value) {
    const std::lock_guard _l(mLock);

    if (mHalSoundDose.size() > 0) {
        bool success = true;
        for (auto& halSoundDose : mHalSoundDose) {
            // using the HAL sound dose interface
            if (!halSoundDose.second->setOutputRs2UpperBound(rs2Value).isOk()) {
                ALOGE("%s: Cannot set RS2 value for momentary exposure %f", __func__, rs2Value);
                continue;
                success = false;
                break;
            }
        }

        if (success) {
            mRs2UpperBound = rs2Value;
        } else {
            // restore all RS2 upper bounds to the previous value
            for (auto& halSoundDose : mHalSoundDose) {
                halSoundDose.second->setOutputRs2UpperBound(mRs2UpperBound);
            }
        }
        return;
    }