From 3ddad6750e53d00f416a67733b391f29c8d382ca Mon Sep 17 00:00:00 2001 From: Vlad Popa Date: Wed, 21 Sep 2022 03:32:45 +0200 Subject: [PATCH] Adjust the APC active state Some mute events like master mute and stream mute should not affect the active state of the AudioPlaybackConfiguration. Test: atest android.media.audio.cts.AudioPlaybackConfigurationTest Bug: 246846130 Change-Id: Id7c94fd44cf714d65ef8ae21734af4c2c02ff873 --- .../android/media/AudioPlaybackConfiguration.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/media/java/android/media/AudioPlaybackConfiguration.java b/media/java/android/media/AudioPlaybackConfiguration.java index 819358b497549..60e3a3068e9d6 100644 --- a/media/java/android/media/AudioPlaybackConfiguration.java +++ b/media/java/android/media/AudioPlaybackConfiguration.java @@ -569,6 +569,17 @@ public final class AudioPlaybackConfiguration implements Parcelable { } } + private boolean isMuteAffectingActiveState() { + if (mMutedState == PLAYER_MUTE_INVALID) { + // mute state is not set, therefore it will not affect the active state + return false; + } + + return (mMutedState & PLAYER_MUTE_CLIENT_VOLUME) != 0 + || (mMutedState & PLAYER_MUTE_VOLUME_SHAPER) != 0 + || (mMutedState & PLAYER_MUTE_PLAYBACK_RESTRICTED) != 0; + } + /** * @hide * Returns true if the player is considered "active", i.e. actively playing with unmuted @@ -580,8 +591,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { public boolean isActive() { switch (mPlayerState) { case PLAYER_STATE_STARTED: - return mMutedState == 0 - || mMutedState == PLAYER_MUTE_INVALID; // only send true if not muted + return !isMuteAffectingActiveState(); case PLAYER_STATE_UNKNOWN: case PLAYER_STATE_RELEASED: case PLAYER_STATE_IDLE: