audioflinger: Fix audio for WifiDisplay
AudioFlinger is not able to determine the correct
pid/tid for WifiDisplay and thus we do not pass checks
for CAPTURE_AUDIO_OUTPUT and RECORD_AUDIO permissions.
To fix audio for WifiDisplay, it should be safe to
always allow a trusted calling uid (AID_MEDIA which
has the same perms as AID_AUDIOSERVER).
Change-Id: Ifa46d8e77a43027645cad02a04263b58e134c3ad
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 509b673..deecab6 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -636,7 +636,8 @@
// type is API_INPUT_MIX_EXT_POLICY_REROUTE and by AudioService if a media projection
// is used and input type is API_INPUT_MIX_PUBLIC_CAPTURE_PLAYBACK
// - ECHO_REFERENCE source is controlled by captureAudioOutputAllowed()
- if (!(recordingAllowed(attributionSource, inputSource)
+ if (!isAudioServerOrMediaServerUid(attributionSource.uid)
+ && !(recordingAllowed(attributionSource, inputSource)
|| inputSource == AUDIO_SOURCE_FM_TUNER
|| inputSource == AUDIO_SOURCE_REMOTE_SUBMIX
|| inputSource == AUDIO_SOURCE_ECHO_REFERENCE)) {
@@ -719,7 +720,7 @@
// FIXME: use the same permission as for remote submix for now.
FALLTHROUGH_INTENDED;
case AudioPolicyInterface::API_INPUT_MIX_CAPTURE:
- if (!canCaptureOutput) {
+ if (!isAudioServerOrMediaServerUid(attributionSource.uid) && !canCaptureOutput) {
ALOGE("%s permission denied: capture not allowed", __func__);
status = PERMISSION_DENIED;
}
@@ -807,7 +808,8 @@
msg << "Audio recording on session " << client->session;
// check calling permissions
- if (!(startRecording(client->attributionSource, String16(msg.str().c_str()),
+ if (!isAudioServerOrMediaServerUid(client->attributionSource.uid)
+ && !(startRecording(client->attributionSource, String16(msg.str().c_str()),
client->attributes.source)
|| client->attributes.source == AUDIO_SOURCE_FM_TUNER
|| client->attributes.source == AUDIO_SOURCE_REMOTE_SUBMIX