From 75f30cd32314e920076a4a34cf1b3504833b3e49 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 4 May 2018 13:13:09 -0700 Subject: [PATCH] Fixing a memory leak with notifications Test: observe code Change-Id: I79ae5b883a743aee96f25fef2756df31cee351d8 Fixes: 79179221 --- .../notification/NotificationTemplateViewWrapper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java index c9dcc5c688ec5..2a47fe00c93bb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java @@ -227,7 +227,9 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp if (mUiOffloadThread == null) { mUiOffloadThread = Dependency.get(UiOffloadThread.class); } - mUiOffloadThread.submit(() -> pendingIntent.registerCancelListener(listener)); + if (view.isAttachedToWindow()) { + mUiOffloadThread.submit(() -> pendingIntent.registerCancelListener(listener)); + } view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) {