From 7103fd44a88989952218261b974a353342ffb3c1 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Mon, 9 May 2016 22:22:33 -0400 Subject: [PATCH] Fixed a memory leak with notification children Children where not removed from the stackscrollstate as their removal was blocked when removing a group. Change-Id: I0a3bbb91d0df2693e1ec7e89276c8714636a34ad Fixes: 28670320 --- .../android/systemui/statusbar/phone/PhoneStatusBar.java | 3 +++ .../statusbar/stack/NotificationStackScrollLayout.java | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 1ec5e7f49afc1..85857008180da 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1533,6 +1533,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } for (int i = 0; i < toRemove.size(); i++) { removeNotification(toRemove.get(i).getStatusBarNotification().getKey(), ranking); + // we need to ensure that the view is actually properly removed from the viewstate + // as this won't happen anymore when kept in the parent. + mStackScroller.removeViewStateForView(toRemove.get(i)); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 05a0ea338708e..fcd5cad7f6ec3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -3571,6 +3571,15 @@ public class NotificationStackScrollLayout extends ViewGroup setFadedOut(alpha != 1.0f); } + /** + * Remove the a given view from the viewstate. This is currently used when the children are + * kept in the parent artificially to have a nicer animation. + * @param view the view to remove + */ + public void removeViewStateForView(View view) { + mCurrentStackScrollState.removeViewStateForView(view); + } + /** * A listener that is notified when some child locations might have changed. */