From 25f9b05b0d1601243f2981e434f062658e15d3d2 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Wed, 27 Feb 2019 15:08:54 -0800 Subject: [PATCH] AudioPolicy: allow recording on a APC dyn policy Test: atest android.media.cts.AudioPlaybackCaptureTest#testCaptureMediaUsage Bug: 111453086 Change-Id: Iee6c2f450268ab16eb299827e358468cbf1349e2 Signed-off-by: Kevin Rocard --- services/audiopolicy/AudioPolicyInterface.h | 4 +++- services/audiopolicy/managerdefault/AudioPolicyManager.cpp | 6 +++++- services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/services/audiopolicy/AudioPolicyInterface.h b/services/audiopolicy/AudioPolicyInterface.h index d61188f08c..acbfc9ee72 100644 --- a/services/audiopolicy/AudioPolicyInterface.h +++ b/services/audiopolicy/AudioPolicyInterface.h @@ -58,10 +58,12 @@ public: typedef enum { API_INPUT_INVALID = -1, API_INPUT_LEGACY = 0,// e.g. audio recording from a microphone - API_INPUT_MIX_CAPTURE,// used for "remote submix", capture of the media to play it remotely + API_INPUT_MIX_CAPTURE,// used for "remote submix" legacy mode (no DAP), + // capture of the media to play it remotely API_INPUT_MIX_EXT_POLICY_REROUTE,// used for platform audio rerouting, where mixes are // handled by external and dynamically installed // policies which reroute audio mixes + API_INPUT_MIX_PUBLIC_CAPTURE_PLAYBACK, // used for playback capture with a MediaProjection API_INPUT_TELEPHONY_RX, // used for capture from telephony RX path } input_type_t; diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp index ce305a474b..c39899c1a5 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp @@ -1986,7 +1986,11 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, if (status != NO_ERROR) { goto error; } - *inputType = API_INPUT_MIX_EXT_POLICY_REROUTE; + if (is_mix_loopback_render(policyMix->mRouteFlags)) { + *inputType = API_INPUT_MIX_PUBLIC_CAPTURE_PLAYBACK; + } else { + *inputType = API_INPUT_MIX_EXT_POLICY_REROUTE; + } device = mAvailableInputDevices.getDevice(AUDIO_DEVICE_IN_REMOTE_SUBMIX, String8(attr->tags + strlen("addr=")), AUDIO_FORMAT_DEFAULT); diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp index a1b6b0fb06..68eade152c 100644 --- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp +++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp @@ -404,6 +404,9 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, if (status == NO_ERROR) { // enforce permission (if any) required for each type of input switch (inputType) { + case AudioPolicyInterface::API_INPUT_MIX_PUBLIC_CAPTURE_PLAYBACK: + // this use case has been validated in audio service with a MediaProjection token, + // and doesn't rely on regular permissions case AudioPolicyInterface::API_INPUT_LEGACY: break; case AudioPolicyInterface::API_INPUT_TELEPHONY_RX: