From 9bd3b87dd0a29d16779297ae61a24fb7c2f21979 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Mon, 10 Jan 2022 15:05:17 +0000 Subject: [PATCH] Crash fix: Log instead of crashing when moving child notif within group. Fixes: 213038631 Test: manual dismissing; adding to groups; getting groups to reorder Depends-On: Iedad4a54fc44e9ff900357b3486cc62516701c45 Change-Id: Ic018d949e09ff41f8d7644fda2d6d4321c64199e --- .../notification/row/ExpandableView.java | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java index 6218c77080209..624e7416d3ee7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java @@ -550,41 +550,32 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable { public void removeFromTransientContainerForAdditionTo(ViewGroup newParent) { final ViewParent parent = getParent(); final ViewGroup transientContainer = getTransientContainer(); - if (parent == null) { - // If this view has no parent, the add will succeed, so just make sure the tracked - // transient container is in sync with the lack of a parent. - if (transientContainer != null) { + if (parent == null || parent == newParent) { + // If this view's current parent is null or the same as the new parent, the add will + // succeed, so just make sure the tracked transient container is in sync with the + // current parent. + if (transientContainer != null && transientContainer != parent) { Log.w(TAG, "Expandable view " + this + " has transient container " + transientContainer - + " but no parent"); + + " but different parent" + parent); setTransientContainer(null); } return; } if (transientContainer == null) { - throw new IllegalStateException( - "Can't add view " + this + " to container " + newParent + "; current parent " - + parent + " is not a transient container"); + throw new IllegalStateException("Can't add view " + this + " to container " + newParent + + "; current parent " + parent + " is not a transient container"); } if (transientContainer != parent) { - String transientContainerOutOfSyncError = "Expandable view " + this + // Crash with details before addView() crashes without any; the view is being added + // to a different parent, and the transient container isn't the parent, so we can't + // even (safely) clean that up. + throw new IllegalStateException("Expandable view " + this + " has transient container " + transientContainer - + " but different parent " + parent; - if (parent != newParent) { - // Crash with details before addView() crashes without any; the view is being added - // to a different parent, and the transient container isn't the parent, so we can't - // even (safely) clean that up. - throw new IllegalStateException(transientContainerOutOfSyncError); - } else { - Log.w(TAG, transientContainerOutOfSyncError); - setTransientContainer(null); - return; - } - } - if (parent != newParent) { - Log.w(TAG, "Moving view " + this + " from transient container " - + transientContainer + " to parent " + newParent); + + " but different parent " + parent); } + Log.w(TAG, "Removing view " + this + " from transient container " + + transientContainer + " in preparation for moving to parent " + newParent); transientContainer.removeTransientView(this); setTransientContainer(null); }