From 4c97b0a9920cea65e2d7d8607347946124de8c92 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 15 Feb 2017 11:16:13 -0800 Subject: [PATCH] Fix leak in NotificationStackScroller by nulling out translatingParent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Once a notification is removed we don’t need to keep reference to mTranslatingParentView. Fixes: 35323108 Test: runtest systemui Change-Id: Ibbecfde4b4f1ee56e3c4e0ec59fadf1284f6c6ce --- .../systemui/statusbar/phone/StatusBar.java | 7 +------ .../stack/NotificationStackScrollLayout.java | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index bc43663ba2613..9b7c4a158714f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1683,6 +1683,7 @@ public class StatusBar extends SystemUI implements DemoMode, if (entry != null && entry.row != null) { entry.row.setRemoved(); + mStackScroller.cleanUpViewState(entry.row); } // Let's remove the children if this was a summary handleGroupSummaryRemoved(key, ranking); @@ -1739,12 +1740,6 @@ public class StatusBar extends SystemUI implements DemoMode, // animations toRemove.get(i).setRemoved(); } - 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 dd4e876604f26..c57b95e702019 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -2455,6 +2455,17 @@ public class NotificationStackScrollLayout extends ViewGroup } } + /** + * Called when a notification is removed from the shade. This cleans up the state for a given + * view. + */ + public void cleanUpViewState(View child) { + if (child == mTranslatingParentView) { + mTranslatingParentView = null; + } + mCurrentStackScrollState.removeViewStateForView(child); + } + @Override public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { super.requestDisallowInterceptTouchEvent(disallowIntercept); @@ -4039,15 +4050,6 @@ public class NotificationStackScrollLayout extends ViewGroup setFadingOut(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); - } - public void setQsExpanded(boolean qsExpanded) { mQsExpanded = qsExpanded; updateAlgorithmLayoutMinHeight();