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

Commit baab5014 authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Cherrypicker Worker
Browse files

libaudiohal@aidl: Screen state and rotation parameters, p. II

aosp/2603929 lacks the actual code for parsing the parameters.
This was not discovered because the test was not in TEST_MAPPING.
This CL fixes both issues.

Bug: 280527932
Test: atest CoreAudioHalAidlTest
(cherry picked from https://android-review.googlesource.com/q/commit:e92c34b099b45d5aeab40a45f0877ea7390ac469)
Merged-In: Ic42765710f0f1482786b2a0b7feed097206edbeb
Change-Id: Ic42765710f0f1482786b2a0b7feed097206edbeb
parent 4f394d61
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@
          "include-filter": "android.nativemedia.aaudio.AAudioTests#AAudioBasic_TestAAudioBasic_TestBasic_LOW_LATENCY__OUTPUT"
          "include-filter": "android.nativemedia.aaudio.AAudioTests#AAudioBasic_TestAAudioBasic_TestBasic_LOW_LATENCY__OUTPUT"
        }
        }
      ]
      ]
    },
    {
      "name": "CoreAudioHalAidlTest"
    }
    }
  ]
  ]
}
}
+41 −0
Original line number Original line Diff line number Diff line
@@ -286,6 +286,9 @@ status_t DeviceHalAidl::setParameters(const String8& kvPairs) {
    if (status_t status = filterAndUpdateBtScoParameters(parameters); status != OK) {
    if (status_t status = filterAndUpdateBtScoParameters(parameters); status != OK) {
        ALOGW("%s: filtering or updating BT SCO parameters failed: %d", __func__, status);
        ALOGW("%s: filtering or updating BT SCO parameters failed: %d", __func__, status);
    }
    }
    if (status_t status = filterAndUpdateScreenParameters(parameters); status != OK) {
        ALOGW("%s: filtering or updating screen parameters failed: %d", __func__, status);
    }


    ALOGW_IF(parameters.size() != 0, "%s: unknown parameters, ignored: \"%s\"",
    ALOGW_IF(parameters.size() != 0, "%s: unknown parameters, ignored: \"%s\"",
            __func__, parameters.toString().c_str());
            __func__, parameters.toString().c_str());
@@ -1253,6 +1256,44 @@ status_t DeviceHalAidl::filterAndUpdateBtScoParameters(AudioParameter &parameter
    return OK;
    return OK;
}
}


status_t DeviceHalAidl::filterAndUpdateScreenParameters(AudioParameter &parameters) {
    TIME_CHECK();
    (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
                    parameters, String8(AudioParameter::keyScreenState),
                    [&](const String8& onOrOff) -> status_t {
                        std::optional<bool> isTurnedOn;
                        if (onOrOff == AudioParameter::valueOn) {
                            isTurnedOn = true;
                        } else if (onOrOff == AudioParameter::valueOff) {
                            isTurnedOn = false;
                        }
                        if (!isTurnedOn.has_value()) {
                            ALOGE("setParameters: parameter key \"%s\" has invalid value \"%s\"",
                                    AudioParameter::keyScreenState, onOrOff.c_str());
                            return BAD_VALUE;
                        }
                        return statusTFromBinderStatus(
                                mModule->updateScreenState(isTurnedOn.value()));
                    }));
    (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<int>(
                    parameters, String8(AudioParameter::keyScreenRotation),
            [&](int rotationDegrees) -> status_t {
                IModule::ScreenRotation rotation;
                switch (rotationDegrees) {
                    case 0: rotation = IModule::ScreenRotation::DEG_0; break;
                    case 90: rotation = IModule::ScreenRotation::DEG_90; break;
                    case 180: rotation = IModule::ScreenRotation::DEG_180; break;
                    case 270: rotation = IModule::ScreenRotation::DEG_270; break;
                    default:
                        ALOGE("setParameters: parameter key \"%s\" has invalid value %d",
                                AudioParameter::keyScreenRotation, rotationDegrees);
                        return BAD_VALUE;
                }
                return statusTFromBinderStatus(mModule->updateScreenRotation(rotation));
            }));
    return OK;
}

status_t DeviceHalAidl::findOrCreatePatch(
status_t DeviceHalAidl::findOrCreatePatch(
        const AudioPatch& requestedPatch, AudioPatch* patch, bool* created) {
        const AudioPatch& requestedPatch, AudioPatch* patch, bool* created) {
    std::set<int32_t> sourcePortConfigIds(requestedPatch.sourcePortConfigIds.begin(),
    std::set<int32_t> sourcePortConfigIds(requestedPatch.sourcePortConfigIds.begin(),
+1 −0
Original line number Original line Diff line number Diff line
@@ -218,6 +218,7 @@ class DeviceHalAidl : public DeviceHalInterface, public ConversionHelperAidl,
    status_t filterAndUpdateBtHfpParameters(AudioParameter &parameters);
    status_t filterAndUpdateBtHfpParameters(AudioParameter &parameters);
    status_t filterAndUpdateBtLeParameters(AudioParameter &parameters);
    status_t filterAndUpdateBtLeParameters(AudioParameter &parameters);
    status_t filterAndUpdateBtScoParameters(AudioParameter &parameters);
    status_t filterAndUpdateBtScoParameters(AudioParameter &parameters);
    status_t filterAndUpdateScreenParameters(AudioParameter &parameters);
    status_t findOrCreatePatch(
    status_t findOrCreatePatch(
        const std::set<int32_t>& sourcePortConfigIds,
        const std::set<int32_t>& sourcePortConfigIds,
        const std::set<int32_t>& sinkPortConfigIds,
        const std::set<int32_t>& sinkPortConfigIds,