From 391ae10c4ea0f9c770742e8b43fb3d6d7d3afc6b Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Wed, 10 Nov 2021 21:58:00 +0000 Subject: [PATCH] New Pipeline: Fix a crash when the silent header was removed then qickly re-added. This moves a check which existed in the NotificationSectionsManager into NSSL where the problem is actually being caused. Test: manual Change-Id: Ia76fdccf29176c946cb62e32d356958d61b3b789 --- .../stack/NotificationStackScrollLayout.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index bc79db36c3ea7..a97a54a50da5b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -4631,6 +4631,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable public void addContainerViewAt(View v, int index) { Assert.isMainThread(); + ensureRemovedFromTransientContainer(v); addView(v, index); if (v instanceof ExpandableNotificationRow && mController.isShowingEmptyShadeView()) { mController.updateShowEmptyShadeView(); @@ -4640,6 +4641,22 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable updateSpeedBumpIndex(); } + private void ensureRemovedFromTransientContainer(View v) { + if (v.getParent() == this && v instanceof SectionHeaderView) { + ExpandableView expandableView = (ExpandableView) v; + ViewGroup transientContainer = expandableView.getTransientContainer(); + // If the child is animating away, it will still have a parent, so + // detach it first + // TODO: We should really cancel the active animations here. This will + // happen automatically when the view's intro animation starts, but + // it's a fragile link. + if (transientContainer != null) { + transientContainer.removeTransientView(v); + expandableView.setTransientContainer(null); + } + } + } + @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void runAfterAnimationFinished(Runnable runnable) { mAnimationFinishedRunnables.add(runnable);