Loading media/java/android/media/AudioPlaybackConfiguration.java +46 −7 Original line number Diff line number Diff line Loading @@ -218,6 +218,11 @@ public final class AudioPlaybackConfiguration implements Parcelable { public static final String EXTRA_PLAYER_EVENT_MUTE = "android.media.extra.PLAYER_EVENT_MUTE"; /** * @hide * Mute state used for anonymization. */ public static final int PLAYER_MUTE_INVALID = -1; /** * @hide * Flag used when muted by master volume. Loading Loading @@ -265,6 +270,8 @@ public final class AudioPlaybackConfiguration implements Parcelable { private int mSessionId; @PlayerMuteEvent private int mMutedState; /** * Never use without initializing parameters afterwards */ Loading @@ -285,6 +292,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { mPlayerType = pic.mPlayerType; mClientUid = uid; mClientPid = pid; mMutedState = PLAYER_MUTE_INVALID; mDeviceId = PLAYER_DEVICEID_INVALID; mPlayerState = PLAYER_STATE_IDLE; mPlayerAttr = pic.mAttributes; Loading Loading @@ -333,6 +341,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { anonymCopy.mPlayerAttr = builder.build(); anonymCopy.mDeviceId = in.mDeviceId; // anonymized data anonymCopy.mMutedState = PLAYER_MUTE_INVALID; anonymCopy.mPlayerType = PLAYER_TYPE_UNKNOWN; anonymCopy.mClientUid = PLAYER_UPID_INVALID; anonymCopy.mClientPid = PLAYER_UPID_INVALID; Loading Loading @@ -391,6 +400,14 @@ public final class AudioPlaybackConfiguration implements Parcelable { return mSessionId; } /** * @hide * @return the mute state as a combination of {@link PlayerMuteEvent} flags */ @PlayerMuteEvent public int getMutedState() { return mMutedState; } /** * @hide * Return the type of player linked to this configuration. Loading Loading @@ -471,7 +488,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { /** * @hide * Handle a change of audio session Id * Handle a change of audio session ID * @param sessionId the audio session ID */ public boolean handleSessionIdEvent(int sessionId) { Loading @@ -480,6 +497,18 @@ public final class AudioPlaybackConfiguration implements Parcelable { return changed; } /** * @hide * Handle a change of the muted state * @param mutedState the mute reason as a combination of {@link PlayerMuteEvent} flags * @return true if the state changed, false otherwise */ public boolean handleMutedEvent(@PlayerMuteEvent int mutedState) { final boolean changed = mMutedState != mutedState; mMutedState = mutedState; return changed; } /** * @hide * Handle a player state change Loading Loading @@ -531,16 +560,17 @@ public final class AudioPlaybackConfiguration implements Parcelable { /** * @hide * Returns true if the player is considered "active", i.e. actively playing, and thus * in a state that should make it considered for the list public (sanitized) active playback * configurations * Returns true if the player is considered "active", i.e. actively playing with unmuted * volume, and thus in a state that should make it considered for the list public (sanitized) * active playback configurations * @return true if active */ @SystemApi public boolean isActive() { switch (mPlayerState) { case PLAYER_STATE_STARTED: return true; return mMutedState == 0 || mMutedState == PLAYER_MUTE_INVALID; // only send true if not muted case PLAYER_STATE_UNKNOWN: case PLAYER_STATE_RELEASED: case PLAYER_STATE_IDLE: Loading Loading @@ -577,7 +607,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { @Override public int hashCode() { return Objects.hash(mPlayerIId, mDeviceId, mPlayerType, mClientUid, mClientPid, return Objects.hash(mPlayerIId, mDeviceId, mMutedState, mPlayerType, mClientUid, mClientPid, mSessionId); } Loading @@ -590,6 +620,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mPlayerIId); dest.writeInt(mDeviceId); dest.writeInt(mMutedState); dest.writeInt(mPlayerType); dest.writeInt(mClientUid); dest.writeInt(mClientPid); Loading @@ -606,6 +637,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { private AudioPlaybackConfiguration(Parcel in) { mPlayerIId = in.readInt(); mDeviceId = in.readInt(); mMutedState = in.readInt(); mPlayerType = in.readInt(); mClientUid = in.readInt(); mClientPid = in.readInt(); Loading @@ -625,6 +657,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { return ((mPlayerIId == that.mPlayerIId) && (mDeviceId == that.mDeviceId) && (mMutedState == that.mMutedState) && (mPlayerType == that.mPlayerType) && (mClientUid == that.mClientUid) && (mClientPid == that.mClientPid)) Loading @@ -639,7 +672,13 @@ public final class AudioPlaybackConfiguration implements Parcelable { + " u/pid:" + mClientUid + "/" + mClientPid + " state:" + toLogFriendlyPlayerState(mPlayerState) + " attr:" + mPlayerAttr + " sessionId:" + mSessionId; + " sessionId:" + mSessionId + " mutedState:" + " muteFromMasterMute=" + ((mMutedState & PLAYER_MUTE_MASTER) != 0) + " muteFromStreamVolume=" + ((mMutedState & PLAYER_MUTE_STREAM_VOLUME) != 0) + " muteFromStreamMuted=" + ((mMutedState & PLAYER_MUTE_STREAM_MUTED) != 0) + " muteFromPlaybackRestricted=" + ((mMutedState & PLAYER_MUTE_PLAYBACK_RESTRICTED) != 0); } //===================================================================== Loading services/core/java/com/android/server/audio/PlaybackActivityMonitor.java +12 −2 Original line number Diff line number Diff line Loading @@ -1443,8 +1443,18 @@ public final class PlaybackActivityMonitor } @PlayerMuteEvent int eventValue = extras.getInt(EXTRA_PLAYER_EVENT_MUTE); sEventLogger.log(new PlayerEvent(/*piid=*/msg.arg1, PLAYER_UPDATE_MUTED, eventValue)); synchronized (mPlayerLock) { int piid = msg.arg1; sEventLogger.log( new PlayerEvent(piid, PLAYER_UPDATE_MUTED, eventValue)); final AudioPlaybackConfiguration apc = mPlayers.get(piid); if (apc == null || !apc.handleMutedEvent(eventValue)) { break; // do not dispatch } dispatchPlaybackChange(/* iplayerReleased= */false); } break; case MSG_L_CLEAR_PORTS_FOR_PIID: int piid = msg.arg1; Loading Loading
media/java/android/media/AudioPlaybackConfiguration.java +46 −7 Original line number Diff line number Diff line Loading @@ -218,6 +218,11 @@ public final class AudioPlaybackConfiguration implements Parcelable { public static final String EXTRA_PLAYER_EVENT_MUTE = "android.media.extra.PLAYER_EVENT_MUTE"; /** * @hide * Mute state used for anonymization. */ public static final int PLAYER_MUTE_INVALID = -1; /** * @hide * Flag used when muted by master volume. Loading Loading @@ -265,6 +270,8 @@ public final class AudioPlaybackConfiguration implements Parcelable { private int mSessionId; @PlayerMuteEvent private int mMutedState; /** * Never use without initializing parameters afterwards */ Loading @@ -285,6 +292,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { mPlayerType = pic.mPlayerType; mClientUid = uid; mClientPid = pid; mMutedState = PLAYER_MUTE_INVALID; mDeviceId = PLAYER_DEVICEID_INVALID; mPlayerState = PLAYER_STATE_IDLE; mPlayerAttr = pic.mAttributes; Loading Loading @@ -333,6 +341,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { anonymCopy.mPlayerAttr = builder.build(); anonymCopy.mDeviceId = in.mDeviceId; // anonymized data anonymCopy.mMutedState = PLAYER_MUTE_INVALID; anonymCopy.mPlayerType = PLAYER_TYPE_UNKNOWN; anonymCopy.mClientUid = PLAYER_UPID_INVALID; anonymCopy.mClientPid = PLAYER_UPID_INVALID; Loading Loading @@ -391,6 +400,14 @@ public final class AudioPlaybackConfiguration implements Parcelable { return mSessionId; } /** * @hide * @return the mute state as a combination of {@link PlayerMuteEvent} flags */ @PlayerMuteEvent public int getMutedState() { return mMutedState; } /** * @hide * Return the type of player linked to this configuration. Loading Loading @@ -471,7 +488,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { /** * @hide * Handle a change of audio session Id * Handle a change of audio session ID * @param sessionId the audio session ID */ public boolean handleSessionIdEvent(int sessionId) { Loading @@ -480,6 +497,18 @@ public final class AudioPlaybackConfiguration implements Parcelable { return changed; } /** * @hide * Handle a change of the muted state * @param mutedState the mute reason as a combination of {@link PlayerMuteEvent} flags * @return true if the state changed, false otherwise */ public boolean handleMutedEvent(@PlayerMuteEvent int mutedState) { final boolean changed = mMutedState != mutedState; mMutedState = mutedState; return changed; } /** * @hide * Handle a player state change Loading Loading @@ -531,16 +560,17 @@ public final class AudioPlaybackConfiguration implements Parcelable { /** * @hide * Returns true if the player is considered "active", i.e. actively playing, and thus * in a state that should make it considered for the list public (sanitized) active playback * configurations * Returns true if the player is considered "active", i.e. actively playing with unmuted * volume, and thus in a state that should make it considered for the list public (sanitized) * active playback configurations * @return true if active */ @SystemApi public boolean isActive() { switch (mPlayerState) { case PLAYER_STATE_STARTED: return true; return mMutedState == 0 || mMutedState == PLAYER_MUTE_INVALID; // only send true if not muted case PLAYER_STATE_UNKNOWN: case PLAYER_STATE_RELEASED: case PLAYER_STATE_IDLE: Loading Loading @@ -577,7 +607,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { @Override public int hashCode() { return Objects.hash(mPlayerIId, mDeviceId, mPlayerType, mClientUid, mClientPid, return Objects.hash(mPlayerIId, mDeviceId, mMutedState, mPlayerType, mClientUid, mClientPid, mSessionId); } Loading @@ -590,6 +620,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mPlayerIId); dest.writeInt(mDeviceId); dest.writeInt(mMutedState); dest.writeInt(mPlayerType); dest.writeInt(mClientUid); dest.writeInt(mClientPid); Loading @@ -606,6 +637,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { private AudioPlaybackConfiguration(Parcel in) { mPlayerIId = in.readInt(); mDeviceId = in.readInt(); mMutedState = in.readInt(); mPlayerType = in.readInt(); mClientUid = in.readInt(); mClientPid = in.readInt(); Loading @@ -625,6 +657,7 @@ public final class AudioPlaybackConfiguration implements Parcelable { return ((mPlayerIId == that.mPlayerIId) && (mDeviceId == that.mDeviceId) && (mMutedState == that.mMutedState) && (mPlayerType == that.mPlayerType) && (mClientUid == that.mClientUid) && (mClientPid == that.mClientPid)) Loading @@ -639,7 +672,13 @@ public final class AudioPlaybackConfiguration implements Parcelable { + " u/pid:" + mClientUid + "/" + mClientPid + " state:" + toLogFriendlyPlayerState(mPlayerState) + " attr:" + mPlayerAttr + " sessionId:" + mSessionId; + " sessionId:" + mSessionId + " mutedState:" + " muteFromMasterMute=" + ((mMutedState & PLAYER_MUTE_MASTER) != 0) + " muteFromStreamVolume=" + ((mMutedState & PLAYER_MUTE_STREAM_VOLUME) != 0) + " muteFromStreamMuted=" + ((mMutedState & PLAYER_MUTE_STREAM_MUTED) != 0) + " muteFromPlaybackRestricted=" + ((mMutedState & PLAYER_MUTE_PLAYBACK_RESTRICTED) != 0); } //===================================================================== Loading
services/core/java/com/android/server/audio/PlaybackActivityMonitor.java +12 −2 Original line number Diff line number Diff line Loading @@ -1443,8 +1443,18 @@ public final class PlaybackActivityMonitor } @PlayerMuteEvent int eventValue = extras.getInt(EXTRA_PLAYER_EVENT_MUTE); sEventLogger.log(new PlayerEvent(/*piid=*/msg.arg1, PLAYER_UPDATE_MUTED, eventValue)); synchronized (mPlayerLock) { int piid = msg.arg1; sEventLogger.log( new PlayerEvent(piid, PLAYER_UPDATE_MUTED, eventValue)); final AudioPlaybackConfiguration apc = mPlayers.get(piid); if (apc == null || !apc.handleMutedEvent(eventValue)) { break; // do not dispatch } dispatchPlaybackChange(/* iplayerReleased= */false); } break; case MSG_L_CLEAR_PORTS_FOR_PIID: int piid = msg.arg1; Loading