summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lucas Dupin <dupin@google.com> 2020-05-21 16:19:59 -0700
committer Lucas Dupin <dupin@google.com> 2020-05-21 16:31:48 -0700
commit41c3f9c078e1d662cfb0eae6a61a33560e26e8eb (patch)
tree5fb81302c005e7794df46e6235173e3553ee243b
parentec95b137caaf3fe8381ed0ce5a733a6238c071f9 (diff)
Fix issue where media would not expire
We only register media listerners for active streams, and this can be a problem. A stream might arrive not playing yet because it's buffering, and we won't receive any other state notifications about it. Let's register listeners for all media streams that have notifications, regardless of them being already active or not. Test: play/pause song without pulling down the shade, wait for media timeout Test: play/pause song with shade down, wait for timeout Bug: 153897770 Change-Id: I1809f2380bbe2840640baa732360a230904b0c57
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java40
1 files changed, 25 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java
index 8ed69d8fb982..db5329a8f952 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java
@@ -36,6 +36,7 @@ import android.media.session.MediaSession;
import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.os.AsyncTask;
+import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.provider.DeviceConfig;
@@ -90,7 +91,8 @@ import dagger.Lazy;
public class NotificationMediaManager implements Dumpable {
private static final String TAG = "NotificationMediaManager";
public static final boolean DEBUG_MEDIA = false;
- private static final long PAUSED_MEDIA_TIMEOUT = TimeUnit.MINUTES.toMillis(10);
+ private static final long PAUSED_MEDIA_TIMEOUT = SystemProperties
+ .getLong("debug.sysui.media_timeout", TimeUnit.MINUTES.toMillis(10));
private final StatusBarStateController mStatusBarStateController
= Dependency.get(StatusBarStateController.class);
@@ -163,6 +165,9 @@ public class NotificationMediaManager implements Dumpable {
Log.v(TAG, "DEBUG_MEDIA: onPlaybackStateChanged: " + state);
}
if (mMediaTimeoutCancellation != null) {
+ if (DEBUG_MEDIA) {
+ Log.v(TAG, "DEBUG_MEDIA: media timeout cancelled");
+ }
mMediaTimeoutCancellation.run();
mMediaTimeoutCancellation = null;
}
@@ -182,8 +187,16 @@ public class NotificationMediaManager implements Dumpable {
}
if (entry != null) {
if (!isPlayingState(state.getState())) {
+ if (DEBUG_MEDIA) {
+ Log.v(TAG, "DEBUG_MEDIA: schedule timeout for "
+ + mMediaNotificationKey);
+ }
mMediaTimeoutCancellation = mMainExecutor.executeDelayed(() -> {
synchronized (mEntryManager) {
+ if (DEBUG_MEDIA) {
+ Log.v(TAG, "DEBUG_MEDIA: execute timeout for "
+ + mMediaNotificationKey);
+ }
if (mMediaNotificationKey == null) {
return;
}
@@ -375,21 +388,18 @@ public class NotificationMediaManager implements Dumpable {
UserHandle.USER_ALL);
for (MediaController aController : sessions) {
- if (PlaybackState.STATE_PLAYING ==
- getMediaControllerPlaybackState(aController)) {
- // now to see if we have one like this
- final String pkg = aController.getPackageName();
-
- for (NotificationEntry entry : allNotifications) {
- if (entry.getSbn().getPackageName().equals(pkg)) {
- if (DEBUG_MEDIA) {
- Log.v(TAG, "DEBUG_MEDIA: found controller matching "
- + entry.getSbn().getKey());
- }
- controller = aController;
- mediaNotification = entry;
- break;
+ // now to see if we have one like this
+ final String pkg = aController.getPackageName();
+
+ for (NotificationEntry entry : allNotifications) {
+ if (entry.getSbn().getPackageName().equals(pkg)) {
+ if (DEBUG_MEDIA) {
+ Log.v(TAG, "DEBUG_MEDIA: found controller matching "
+ + entry.getSbn().getKey());
}
+ controller = aController;
+ mediaNotification = entry;
+ break;
}
}
}