Update when media controls get cleared
Some apps include an action to dismiss a media notification, so we
should listen for that happening and clear controls in that case.
Also, remove STATE_CONNECTING as a condition to clear controls -
This was originally added in ag/11056932 as a workaround for an issue
with YouTube cast sessions. However this caused issues with other apps
like Spotify which set STATE_CONNECTING while still active. YT was using
that as a workaround for legacy behavior and will update to use
STATE_NONE for R+ builds (b/155213698). In the meantime, listening for
when the notification is removed will also work to clear YT's controls
as expected.
Fixes: 154953276
Fixes: 155029855
Test: manual
Change-Id: Ie9320e1406c1f457a39f67705ec1ffcb3a983488
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index ddc9c9d..5ccfd8c 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -124,11 +124,7 @@
@Override
public void onPlaybackStateChanged(PlaybackState state) {
final int s = state != null ? state.getState() : PlaybackState.STATE_NONE;
- // When the playback state is NONE or CONNECTING, transition the player to the
- // resumption state. State CONNECTING needs to be considered for Cast sessions. Ending
- // a cast session in YT results in the CONNECTING state, which makes sense if you
- // thinking of the session as waiting to connect to another cast device.
- if (s == PlaybackState.STATE_NONE || s == PlaybackState.STATE_CONNECTING) {
+ if (s == PlaybackState.STATE_NONE) {
Log.d(TAG, "playback state change will trigger resumption, state=" + state);
clearControls();
makeInactive();