Introduce a system APC with its corresponding opt-out
For system application with the new permission CAPTURE_MEDIA_OUTPUT, or
CAPTURE_AUDIO_OUTPUT, allow to capture the audio of playing apps that
allow it.
Test: adb shell audiorecorder --target /data/file1.raw
Test: atest android.media.cts.AudioPlaybackCaptureTest
Bug: 111453086
Change-Id: I5bfca51e48992234508897c595a076d066db26b2
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index a672521..1ec3262 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -192,7 +192,7 @@
}
audio_attributes_t attr = *originalAttr;
if (!mPackageManager.allowPlaybackCapture(uid)) {
- attr.flags |= AUDIO_FLAG_NO_CAPTURE;
+ attr.flags |= AUDIO_FLAG_NO_MEDIA_PROJECTION;
}
audio_output_flags_t originalFlags = flags;
AutoCallerClear acc;
@@ -1080,6 +1080,14 @@
return PERMISSION_DENIED;
}
+ bool needCaptureMediaOutput = std::any_of(mixes.begin(), mixes.end(), [](auto& mix) {
+ return mix.mAllowPrivilegedPlaybackCapture; });
+ const uid_t callingUid = IPCThreadState::self()->getCallingUid();
+ const pid_t callingPid = IPCThreadState::self()->getCallingPid();
+ if (needCaptureMediaOutput && !captureMediaOutputAllowed(callingPid, callingUid)) {
+ return PERMISSION_DENIED;
+ }
+
if (mAudioPolicyManager == NULL) {
return NO_INIT;
}