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

Commit a74058e5 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio flinger: allow output stage effects with privileged permission

Allow apps with permission MODIFY_DEFAULT_AUDIO_EFFECTS to apply
an effect on the output stage session.

Bug: 234013785
Test: make
Change-Id: I8927073335c25d066483039a37063830421ad032
parent a2ac684a
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -3889,17 +3889,24 @@ status_t AudioFlinger::createEffect(const media::CreateEffectRequest& request,
            goto Exit;
        }
    } else if (sessionId == AUDIO_SESSION_OUTPUT_STAGE) {
        if (!isAudioServerUid(callingUid)) {
            ALOGE("%s: only APM can create using AUDIO_SESSION_OUTPUT_STAGE", __func__);
            lStatus = PERMISSION_DENIED;
            goto Exit;
        }

        if (io == AUDIO_IO_HANDLE_NONE) {
            ALOGE("%s: APM must specify output when using AUDIO_SESSION_OUTPUT_STAGE", __func__);
            lStatus = BAD_VALUE;
            goto Exit;
        }
        PlaybackThread *thread = checkPlaybackThread_l(io);
        if (thread == nullptr) {
            ALOGE("%s: invalid output %d specified for AUDIO_SESSION_OUTPUT_STAGE", __func__, io);
            lStatus = BAD_VALUE;
            goto Exit;
        }
        if (!modifyDefaultAudioEffectsAllowed(adjAttributionSource)
                && !isAudioServerUid(callingUid)) {
            ALOGE("%s: effect on AUDIO_SESSION_OUTPUT_STAGE not granted for uid %d",
                    __func__, callingUid);
            lStatus = PERMISSION_DENIED;
            goto Exit;
        }
    } else if (sessionId == AUDIO_SESSION_DEVICE) {
        if (!modifyDefaultAudioEffectsAllowed(adjAttributionSource)) {
            ALOGE("%s: device effect permission denied for uid %d", __func__, callingUid);