diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java index f25e59941b11a..dd84dea9a92ff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java @@ -416,6 +416,10 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener { child = getIsolatedChild(sbn.getGroupKey()); } if (child != null) { + if (child.row.keepInParent() || child.row.isRemoved() || child.row.isDismissed()) { + // the notification is actually already removed, no need to do heads-up on it. + return; + } if (mHeadsUpManager.isHeadsUp(child.key)) { mHeadsUpManager.updateNotification(child, true); } else { 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 daac0d80db5a1..fcbc35c3ef5df 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1929,6 +1929,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, childIndex++) { ExpandableNotificationRow childView = orderedChildren.get(childIndex); if (children == null || !children.contains(childView)) { + if (childView.getParent() != null) { + Log.wtf(TAG, "trying to add a notification child that already has " + + "a parent. class:" + childView.getParent().getClass() + + "\n child: " + childView); + // This shouldn't happen. We can recover by removing it though. + ((ViewGroup) childView.getParent()).removeView(childView); + } mVisualStabilityManager.notifyViewAddition(childView); parent.addChildNotification(childView, childIndex); mStackScroller.notifyGroupChildAdded(childView);