From 77097800c47561e7de70f0143d715de78c702479 Mon Sep 17 00:00:00 2001 From: shawnlin Date: Mon, 26 Mar 2018 12:04:05 +0800 Subject: [PATCH] Fix the background of lockscreen showing the art work of removed media notification StatusBar inflates notification views by AsyncTask(AsyncInflationTask), and the notification entry will be added to mNotificationData only after the inflation is completed. It makes a timing issue for media notification if following conditions are met: 1. There already exists one none-media notification which is posted by the same app as the incoming media notification. 2. Any notification posted and its inflation is completed before the media notification and then triggers the findAndUpdateMediaNotifications(). In such case, the media notification entry hasn't been added to mNotificationData yet so we can't find any notification with media controller in this list. Then we look up MediaSessionManager and try to find any MediaController that has the same package name with any notification in mNotificationData list. It will then find a MediaController which should belong to the media notification, but then be assigned to the none-media notification since both have the same package name. We now move the if (medianotification != null) {} block outside the controller to make sure the correct media notification is set after its inflation is completed. Test: runtest systemui Test: manual - open chrome : 1)download a file 2)play any youtube video 3)screen off then on device Fixes: 75988950 Change-Id: Ic7f341cd0b0cf675807d2127e61cbb651f9dff75 --- .../statusbar/NotificationMediaManager.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java index 852239a2143b6..abc261e6bbf66 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java @@ -172,6 +172,14 @@ public class NotificationMediaManager implements Dumpable { } } + if (mediaNotification != null) { + mMediaNotificationKey = mediaNotification.notification.getKey(); + if (DEBUG_MEDIA) { + Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" + + mMediaNotificationKey + " controller=" + mMediaController); + } + } + if (controller != null && !sameSessions(mMediaController, controller)) { // We have a new media session clearCurrentMediaNotification(); @@ -183,13 +191,6 @@ public class NotificationMediaManager implements Dumpable { + mMediaMetadata); } - if (mediaNotification != null) { - mMediaNotificationKey = mediaNotification.notification.getKey(); - if (DEBUG_MEDIA) { - Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" - + mMediaNotificationKey + " controller=" + mMediaController); - } - } metaDataChanged = true; } }