From 40f88765156c82d6f3ceabb72f7ae72ceda0e36d Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 16 Dec 2016 16:56:41 -0800 Subject: [PATCH] Fixed a potential heads up crash If a group became suppressed with a summary that is heads-upped, while also being in the process of being removed, it could lead to a crash. Test: isolate a HUN that was being removed and is a child Change-Id: I943b63529778a3c85b03da033837f5a677b2d352 Fixes: 33645653 --- .../systemui/statusbar/phone/NotificationGroupManager.java | 4 ++++ .../android/systemui/statusbar/phone/PhoneStatusBar.java | 7 +++++++ 2 files changed, 11 insertions(+) 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);