3636import android .media .session .MediaSessionManager ;
3737import android .media .session .PlaybackState ;
3838import android .os .AsyncTask ;
39+ import android .os .SystemProperties ;
3940import android .os .Trace ;
4041import android .os .UserHandle ;
4142import android .provider .DeviceConfig ;
9091public class NotificationMediaManager implements Dumpable {
9192 private static final String TAG = "NotificationMediaManager" ;
9293 public static final boolean DEBUG_MEDIA = false ;
93- private static final long PAUSED_MEDIA_TIMEOUT = TimeUnit .MINUTES .toMillis (10 );
94+ private static final long PAUSED_MEDIA_TIMEOUT = SystemProperties
95+ .getLong ("debug.sysui.media_timeout" , TimeUnit .MINUTES .toMillis (10 ));
9496
9597 private final StatusBarStateController mStatusBarStateController
9698 = Dependency .get (StatusBarStateController .class );
@@ -163,6 +165,9 @@ public void onPlaybackStateChanged(PlaybackState state) {
163165 Log .v (TAG , "DEBUG_MEDIA: onPlaybackStateChanged: " + state );
164166 }
165167 if (mMediaTimeoutCancellation != null ) {
168+ if (DEBUG_MEDIA ) {
169+ Log .v (TAG , "DEBUG_MEDIA: media timeout cancelled" );
170+ }
166171 mMediaTimeoutCancellation .run ();
167172 mMediaTimeoutCancellation = null ;
168173 }
@@ -182,8 +187,16 @@ private void scheduleMediaTimeout(PlaybackState state) {
182187 }
183188 if (entry != null ) {
184189 if (!isPlayingState (state .getState ())) {
190+ if (DEBUG_MEDIA ) {
191+ Log .v (TAG , "DEBUG_MEDIA: schedule timeout for "
192+ + mMediaNotificationKey );
193+ }
185194 mMediaTimeoutCancellation = mMainExecutor .executeDelayed (() -> {
186195 synchronized (mEntryManager ) {
196+ if (DEBUG_MEDIA ) {
197+ Log .v (TAG , "DEBUG_MEDIA: execute timeout for "
198+ + mMediaNotificationKey );
199+ }
187200 if (mMediaNotificationKey == null ) {
188201 return ;
189202 }
@@ -375,21 +388,18 @@ public void findAndUpdateMediaNotifications() {
375388 UserHandle .USER_ALL );
376389
377390 for (MediaController aController : sessions ) {
378- if (PlaybackState .STATE_PLAYING ==
379- getMediaControllerPlaybackState (aController )) {
380- // now to see if we have one like this
381- final String pkg = aController .getPackageName ();
382-
383- for (NotificationEntry entry : allNotifications ) {
384- if (entry .getSbn ().getPackageName ().equals (pkg )) {
385- if (DEBUG_MEDIA ) {
386- Log .v (TAG , "DEBUG_MEDIA: found controller matching "
387- + entry .getSbn ().getKey ());
388- }
389- controller = aController ;
390- mediaNotification = entry ;
391- break ;
391+ // now to see if we have one like this
392+ final String pkg = aController .getPackageName ();
393+
394+ for (NotificationEntry entry : allNotifications ) {
395+ if (entry .getSbn ().getPackageName ().equals (pkg )) {
396+ if (DEBUG_MEDIA ) {
397+ Log .v (TAG , "DEBUG_MEDIA: found controller matching "
398+ + entry .getSbn ().getKey ());
392399 }
400+ controller = aController ;
401+ mediaNotification = entry ;
402+ break ;
393403 }
394404 }
395405 }
0 commit comments