Fix voice communication audio playback capture
This change fixes the CTS failure in AudioPlaybackCaptureTest caused
by ag/10111312 and ag/10111311.
It contains the following fixes/changes:
- Mix match for playback capture of USAGE_VOICE_COMMUNICATION now
also respects a new flag (AudioMix's mVoiceCommunicationCaptureAllowed)
which is set by AudioService only if the caller explicitly asked
to capture USAGE_VOICE_COMMUNICATION and have the
CAPTURE_VOICE_COMMUNICATION_OUTPUT.
- A permission check on the native side in case
mVoiceCommunicationCaptureAllowed is set.
- Code cleanup, mainly in AudioPolicy.h and AudioPolicy.cpp.
This change is accompanied by ag/10242955 on the Java side.
Bug: 148559127
Test: manual
Test: atest PlaybackCaptureTest (with the version prior to ag/10220852)
Test: atest com.google.android.gts.audio.AudioHostTest
Change-Id: I8ae6249f4da1de35e962c838d91f690eb906570e
diff --git a/media/libaudioclient/AudioPolicy.cpp b/media/libaudioclient/AudioPolicy.cpp
index d468239..0522099 100644
--- a/media/libaudioclient/AudioPolicy.cpp
+++ b/media/libaudioclient/AudioPolicy.cpp
@@ -86,6 +86,7 @@
mDeviceAddress = parcel->readString8();
mCbFlags = (uint32_t)parcel->readInt32();
mAllowPrivilegedPlaybackCapture = parcel->readBool();
+ mVoiceCommunicationCaptureAllowed = parcel->readBool();
size_t size = (size_t)parcel->readInt32();
if (size > MAX_CRITERIA_PER_MIX) {
size = MAX_CRITERIA_PER_MIX;
@@ -110,6 +111,7 @@
parcel->writeString8(mDeviceAddress);
parcel->writeInt32(mCbFlags);
parcel->writeBool(mAllowPrivilegedPlaybackCapture);
+ parcel->writeBool(mVoiceCommunicationCaptureAllowed);
size_t size = mCriteria.size();
if (size > MAX_CRITERIA_PER_MIX) {
size = MAX_CRITERIA_PER_MIX;
@@ -206,11 +208,4 @@
&& (mRouteFlags == MIX_ROUTE_FLAG_RENDER));
}
-bool AudioMix::hasMatchingRuleForUsage(std::function<bool (audio_usage_t)>const& func) const {
- return std::any_of(mCriteria.begin(), mCriteria.end(), [func](auto& criterion) {
- return criterion.mRule == RULE_MATCH_ATTRIBUTE_USAGE
- && func(criterion.mValue.mUsage);
- });
-}
-
} // namespace android