diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2011-11-07 15:59:51 -0800 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2011-11-08 11:57:50 -0800 |
commit | 94d351603f83fdaa0c2bb5df7911c3e61fab01e2 (patch) | |
tree | 5289b63850a627d909b19db807c0af16c6aad1a8 | |
parent | 762f10659c2ac6fb66afd09be5bddd7ffebbf9df (diff) | |
download | android_system_media-94d351603f83fdaa0c2bb5df7911c3e61fab01e2.tar.gz android_system_media-94d351603f83fdaa0c2bb5df7911c3e61fab01e2.tar.bz2 android_system_media-94d351603f83fdaa0c2bb5df7911c3e61fab01e2.zip |
Bug 5585323 Authorize audio decode for system
Authorize the use of specific audio codecs for audio decoding
by the system, which guarantees audio is decoded for playback,
when the appropriate system permission is used.
Change-Id: I0633b04b4d0aebe89804ef48752bf05d72abc56d
-rw-r--r-- | wilhelm/src/android/android_AudioSfDecoder.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/wilhelm/src/android/android_AudioSfDecoder.cpp b/wilhelm/src/android/android_AudioSfDecoder.cpp index 79e01a47..de072656 100644 --- a/wilhelm/src/android/android_AudioSfDecoder.cpp +++ b/wilhelm/src/android/android_AudioSfDecoder.cpp @@ -19,6 +19,7 @@ #include "sles_allinclusive.h" #include "android/android_AudioSfDecoder.h" +#include <binder/IServiceManager.h> #include <media/stagefright/foundation/ADebug.h> @@ -776,17 +777,25 @@ void AudioSfDecoder::hasNewDecodeParams() { updateAudioSink(); } -static const char* const kUnsupportedCodecs[] = { MEDIA_MIMETYPE_AUDIO_AMR_NB, +static const char* const kPlaybackOnlyCodecs[] = { MEDIA_MIMETYPE_AUDIO_AMR_NB, MEDIA_MIMETYPE_AUDIO_AMR_WB }; -#define NB_UNSUPPORTED_CODECS (sizeof(kUnsupportedCodecs)/sizeof(kUnsupportedCodecs[0])) +#define NB_PLAYBACK_ONLY_CODECS (sizeof(kPlaybackOnlyCodecs)/sizeof(kPlaybackOnlyCodecs[0])) bool AudioSfDecoder::isSupportedCodec(const char* mime) { - for (unsigned int i = 0 ; i < NB_UNSUPPORTED_CODECS ; i++) { - if (!strcasecmp(mime, kUnsupportedCodecs[i])) { - return false; + bool codecRequiresPermission = false; + for (unsigned int i = 0 ; i < NB_PLAYBACK_ONLY_CODECS ; i++) { + if (!strcasecmp(mime, kPlaybackOnlyCodecs[i])) { + codecRequiresPermission = true; + break; } } - return true; + if (codecRequiresPermission) { + // verify only the system can decode, for playback only + return checkCallingPermission( + String16("android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK")); + } else { + return true; + } } } // namespace android |