From ce2d1afe86b6b4baf3919dc24f581e4a8630964f Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Thu, 30 May 2019 16:00:22 -0400 Subject: [PATCH] Fix always-null children on NotificationEntry Looks like _someone_ decided to make an array of children and _never_ poplate it. What used to happen was that callers into NotificationEntry would grab the row and call ExpandableNotificationRow#getNotificationChildren() on it to iterate the children and call things (notably setKeepInParent()). During the work to refactor NotficationEntry into its own class, NotificationEntry#getChildren() was created so that we could iterate the entry's children instead of the view's children. Unfortunately it was never populated. For now, just call through to ExpandableNotificationRow#getNotificationChildren() and map those to their entries. Fixes: 130018576 Test: atest SystemUITests; visual Change-Id: Ica629b96c8fa2ee2fb45fdf588ee7d1efc836883 --- .../notification/NotificationEntryManager.java | 4 ++-- .../collection/NotificationEntry.java | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index e8388ceded04f..879a8dfa2875c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -355,10 +355,10 @@ public class NotificationEntryManager implements // a child we're keeping around for reply! continue; } - entry.setKeepInParent(true); + childEntry.setKeepInParent(true); // we need to set this state earlier as otherwise we might generate some weird // animations - entry.removeRow(); + childEntry.removeRow(); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index a3e18efa19154..92c261c4cad7c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -122,7 +122,6 @@ public final class NotificationEntry { public boolean suspended; private NotificationEntry parent; // our parent (if we're in a group) - private ArrayList children = new ArrayList(); private ExpandableNotificationRow row; // the outer expanded view private int mCachedContrastColor = COLOR_INVALID; @@ -277,10 +276,20 @@ public final class NotificationEntry { @Nullable public List getChildren() { - if (children.size() <= 0) { + if (row == null) { return null; } + List rowChildren = row.getNotificationChildren(); + if (rowChildren == null) { + return null; + } + + ArrayList children = new ArrayList<>(); + for (ExpandableNotificationRow child : rowChildren) { + children.add(child.getEntry()); + } + return children; } @@ -740,7 +749,9 @@ public final class NotificationEntry { if (notification == null || !notification.isClearable()) { return false; } - if (children.size() > 0) { + + List children = getChildren(); + if (children != null && children.size() > 0) { for (int i = 0; i < children.size(); i++) { NotificationEntry child = children.get(i); if (!child.isClearable()) {