Fix permission check for audio recording
Define input types covering the different usecases for audio
recording, and check the corresponding permissions when
starting to record.
Move the permission check from audio flinger to audio policy,
as only the policy has the information to determine which
permission to enforce.
Fix missing permission when an application records audio
and the audio is injected by an external policy.
Bug 18736417
Change-Id: If7ec040502242c990ac8ea464db484339bdce573
diff --git a/services/audiopolicy/AudioPolicyClientImplLegacy.cpp b/services/audiopolicy/AudioPolicyClientImplLegacy.cpp
index 97719da..a79f8ae 100644
--- a/services/audiopolicy/AudioPolicyClientImplLegacy.cpp
+++ b/services/audiopolicy/AudioPolicyClientImplLegacy.cpp
@@ -188,6 +188,13 @@
if (pSamplingRate == NULL || pFormat == NULL || pChannelMask == NULL || pDevices == NULL) {
return AUDIO_IO_HANDLE_NONE;
}
+
+ if (((*pDevices & AUDIO_DEVICE_IN_REMOTE_SUBMIX) == AUDIO_DEVICE_IN_REMOTE_SUBMIX)
+ && !captureAudioOutputAllowed()) {
+ ALOGE("open_input() permission denied: capture not allowed");
+ return AUDIO_IO_HANDLE_NONE;
+ }
+
audio_config_t config = AUDIO_CONFIG_INITIALIZER;;
config.sample_rate = *pSamplingRate;
config.format = *pFormat;