From d5ca459e979ab4df7d3036569e808665665be60b Mon Sep 17 00:00:00 2001 From: Kevin Han Date: Mon, 10 Feb 2020 15:18:46 -0800 Subject: [PATCH] Call entry clean up when removing pending entries Classes that hooked on to NotificationEntryManager to add more state would leak the entries because NotificationEntryManager wouldn't inform them to clean up their state if NEM ends up removing a notification that's pending inflation. This is because the notification isn't technically "active" yet based off NEM's pipeline. We add this hook to correct this. This is not an issue in NotifCollection as it is unrelated to the inflation pipeline and instantly considers an added notification "active" when it's posted, so the removal/clean up callbacks are actually called when it's removed shortly after posting. Bug: 149212504 Bug: 149205483 Test: add + cancel notifications in Notify.apk adb shell dumpheap com.android.systemui Observe in heap dump that NotificationEntry's match up Change-Id: I9e41399dd9ee0de853f39a47876d8c176a8d8b21 --- .../statusbar/notification/NotificationEntryManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index 916da6eca0c95..b0bf8130f3a91 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -290,6 +290,9 @@ public class NotificationEntryManager implements NotificationEntry entry = mPendingNotifications.get(key); entry.abortTask(); mPendingNotifications.remove(key); + for (NotifCollectionListener listener : mNotifCollectionListeners) { + listener.onEntryCleanUp(entry); + } mLogger.logInflationAborted(key, "pending", reason); } NotificationEntry addedEntry = getActiveNotificationUnfiltered(key);