From 87eae9bf79a8f03ea57b79dea4d9af37ed0f7e51 Mon Sep 17 00:00:00 2001 From: shawnlin Date: Fri, 20 Apr 2018 21:42:42 +0800 Subject: [PATCH] Fix the art work of lockscreen cannot be removed The root cause is that mMediaNotificationKey is cleared right after it is set. It makes the media art work cannot be cleared since there is no notification that match the mMediaNotificationKey which is already cleared to null. Only clear media session related data inside the controller check. Test: runtest systemui Test: manual Change-Id: Iae43c502b90f73e57fae7150e15ef89eb18b096c Fixes: 78204513 --- .../statusbar/NotificationMediaManager.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java index abc261e6bbf66..f737a8cec4f09 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java @@ -172,27 +172,28 @@ 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(); + clearCurrentMediaNotificationSession(); mMediaController = controller; mMediaController.registerCallback(mMediaListener); mMediaMetadata = mMediaController.getMetadata(); if (DEBUG_MEDIA) { - Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " - + mMediaMetadata); + Log.v(TAG, "DEBUG_MEDIA: insert listener, found new controller: " + + mMediaController + ", receive metadata: " + mMediaMetadata); } metaDataChanged = true; } + + if (mediaNotification != null + && !mediaNotification.notification.getKey().equals(mMediaNotificationKey)) { + mMediaNotificationKey = mediaNotification.notification.getKey(); + if (DEBUG_MEDIA) { + Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" + + mMediaNotificationKey); + } + } } if (metaDataChanged) { @@ -203,15 +204,7 @@ public class NotificationMediaManager implements Dumpable { public void clearCurrentMediaNotification() { mMediaNotificationKey = null; - mMediaMetadata = null; - if (mMediaController != null) { - if (DEBUG_MEDIA) { - Log.v(TAG, "DEBUG_MEDIA: Disconnecting from old controller: " - + mMediaController.getPackageName()); - } - mMediaController.unregisterCallback(mMediaListener); - } - mMediaController = null; + clearCurrentMediaNotificationSession(); } @Override @@ -265,4 +258,16 @@ public class NotificationMediaManager implements Dumpable { entry.getExpandedContentView() .findViewById(com.android.internal.R.id.media_actions) != null; } + + private void clearCurrentMediaNotificationSession() { + mMediaMetadata = null; + if (mMediaController != null) { + if (DEBUG_MEDIA) { + Log.v(TAG, "DEBUG_MEDIA: Disconnecting from old controller: " + + mMediaController.getPackageName()); + } + mMediaController.unregisterCallback(mMediaListener); + } + mMediaController = null; + } }