From 8ee5365f7f15f1cdf42cc3cfcd5d627ba673d580 Mon Sep 17 00:00:00 2001 From: Rohan Shah Date: Thu, 5 Apr 2018 11:13:50 -0700 Subject: [PATCH] [Notif] Disable animations as screen is powering off When showing an incog notification, it's getting added to the remove anims, but the screen is turning off and animations are never getting run (which means the transient view gets added but it doesn't get removed). The root cause is notifications clear temporary views in the power on (due to collapse animations), but don't clear them when unlocking via fingerprint. Fixed by clearing remove animation setup (where transient views are used) when disabling animations. This will stop the transient views from being held on post-screen off/when animations are disabled. Test: Visually with logging (tested before & after) Test: Dumped hierarchy and checked that transient views weren't being mismanaged Fixes: 77217401 Change-Id: I48835e45fd76c5e74810f5256c14b0c4c2ca3ec4 --- .../stack/NotificationStackScrollLayout.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) 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 da7dc07b2bfb3..d282f259df812 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -3023,6 +3023,11 @@ public class NotificationStackScrollLayout extends ViewGroup public void setAnimationsEnabled(boolean animationsEnabled) { mAnimationsEnabled = animationsEnabled; updateNotificationAnimationStates(); + if (!animationsEnabled) { + mSwipedOutViews.clear(); + mChildrenToRemoveAnimated.clear(); + clearTemporaryViewsInGroup(this); + } } private void updateNotificationAnimationStates() { @@ -3090,6 +3095,21 @@ public class NotificationStackScrollLayout extends ViewGroup @Override public void changeViewPosition(View child, int newIndex) { int currentIndex = indexOfChild(child); + + if (currentIndex == -1) { + boolean isTransient = false; + if (child instanceof ExpandableNotificationRow + && ((ExpandableNotificationRow)child).getTransientContainer() != null) { + isTransient = true; + } + Log.e(TAG, "Attempting to re-position " + + (isTransient ? "transient" : "") + + " view {" + + child + + "}"); + return; + } + if (child != null && child.getParent() == this && currentIndex != newIndex) { mChangePositionInProgress = true; ((ExpandableView)child).setChangingPosition(true); @@ -3569,17 +3589,17 @@ public class NotificationStackScrollLayout extends ViewGroup private void clearTemporaryViews() { // lets make sure nothing is in the overlay / transient anymore - clearTemporaryViews(this); + clearTemporaryViewsInGroup(this); for (int i = 0; i < getChildCount(); i++) { ExpandableView child = (ExpandableView) getChildAt(i); if (child instanceof ExpandableNotificationRow) { ExpandableNotificationRow row = (ExpandableNotificationRow) child; - clearTemporaryViews(row.getChildrenContainer()); + clearTemporaryViewsInGroup(row.getChildrenContainer()); } } } - private void clearTemporaryViews(ViewGroup viewGroup) { + private void clearTemporaryViewsInGroup(ViewGroup viewGroup) { while (viewGroup != null && viewGroup.getTransientViewCount() != 0) { viewGroup.removeTransientView(viewGroup.getTransientView(0)); }