From 14beea487c065ca902bfd7089399eb71a805e302 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 22 Sep 2010 14:17:38 -0700 Subject: [PATCH] Request permission for global audio effects. Applications creating an audio effect on the output mix must have the MODIFY_AUDIO_SETTINGS permission. Change-Id: I57d88533f91ad0d33680107d79abcec28f7263b5 --- services/audioflinger/AudioFlinger.cpp | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 886c25b7d1e24..56de765554d80 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -4656,13 +4656,25 @@ sp AudioFlinger::createEffect(pid_t pid, { Mutex::Autolock _l(mLock); + // check audio settings permission for global effects + if (sessionId == AudioSystem::SESSION_OUTPUT_MIX && !settingsAllowed()) { + lStatus = PERMISSION_DENIED; + goto Exit; + } + + // Session AudioSystem::SESSION_OUTPUT_STAGE is reserved for output stage effects + // that can only be created by audio policy manager (running in same process) + if (sessionId == AudioSystem::SESSION_OUTPUT_STAGE && getpid() != pid) { + lStatus = PERMISSION_DENIED; + goto Exit; + } + // check recording permission for visualizer - if (memcmp(&pDesc->type, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0 || - memcmp(&pDesc->uuid, &VISUALIZATION_UUID_, sizeof(effect_uuid_t)) == 0) { - if (!recordingAllowed()) { - lStatus = PERMISSION_DENIED; - goto Exit; - } + if ((memcmp(&pDesc->type, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0 || + memcmp(&pDesc->uuid, &VISUALIZATION_UUID_, sizeof(effect_uuid_t)) == 0) && + !recordingAllowed()) { + lStatus = PERMISSION_DENIED; + goto Exit; } if (!EffectIsNullUuid(&pDesc->uuid)) { @@ -4727,14 +4739,6 @@ sp AudioFlinger::createEffect(pid_t pid, goto Exit; } - // Session AudioSystem::SESSION_OUTPUT_STAGE is reserved for output stage effects - // that can only be created by audio policy manager (running in same process) - if (sessionId == AudioSystem::SESSION_OUTPUT_STAGE && - getpid() != pid) { - lStatus = INVALID_OPERATION; - goto Exit; - } - // return effect descriptor memcpy(pDesc, &desc, sizeof(effect_descriptor_t));