From 2b4bdbb08151371f4fe88a2f524a988ffb2fe1b3 Mon Sep 17 00:00:00 2001 From: Kevin Han Date: Tue, 21 Apr 2020 17:26:51 -0700 Subject: [PATCH] Fix notif content when child updated to top level Since children can be updated to not be in groups and become a top level notification, we need to check and ensure that we inflate the content of any top level notifications that don't have content. Bug: 154227833 Test: repro in bug Test: atest DynamicChildBindControllerTest Change-Id: I83120691e20f63ee4f3d440d84c005cdfe84a719 --- .../NotificationViewHierarchyManager.java | 6 ++-- .../DynamicChildBindController.java | 30 ++++++++++++------- .../DynamicChildBindControllerTest.java | 4 +-- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java index afb50027f03de..c6f5f66842377 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java @@ -60,7 +60,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle private final Handler mHandler; - /** Re-usable map of notifications to their sorted children.*/ + /** Re-usable map of top-level notifications to their sorted children if any.*/ private final HashMap> mTmpChildOrderMap = new HashMap<>(); @@ -206,6 +206,8 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle } orderedChildren.add(ent); } else { + // Top-level notif + mTmpChildOrderMap.put(ent, null); toShow.add(ent.getRow()); } } @@ -283,7 +285,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle } - mDynamicChildBindController.updateChildContentViews(mTmpChildOrderMap); + mDynamicChildBindController.updateContentViews(mTmpChildOrderMap); mVisualStabilityManager.onReorderingFinished(); // clear the map again for the next usage mTmpChildOrderMap.clear(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicChildBindController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicChildBindController.java index 148cdea920520..57b41f36e51f9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicChildBindController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicChildBindController.java @@ -63,44 +63,52 @@ public class DynamicChildBindController { } /** - * Update the child content views, unbinding content views on children that won't be visible - * and binding content views on children that will be visible eventually. + * Update the content views, unbinding content views on children that won't be visible + * and binding content views on children that will be visible eventually and previously unbound + * children that are no longer children. * - * @param groupNotifs map of notification summaries to their children + * @param groupNotifs map of top-level notifs to their children, if any */ - public void updateChildContentViews( + public void updateContentViews( Map> groupNotifs) { for (NotificationEntry entry : groupNotifs.keySet()) { List children = groupNotifs.get(entry); + if (children == null) { + if (!hasContent(entry)) { + // Case where child is updated to be top level + bindContent(entry); + } + continue; + } for (int j = 0; j < children.size(); j++) { NotificationEntry childEntry = children.get(j); if (j >= mChildBindCutoff) { - if (hasChildContent(childEntry)) { - freeChildContent(childEntry); + if (hasContent(childEntry)) { + freeContent(childEntry); } } else { - if (!hasChildContent(childEntry)) { - bindChildContent(childEntry); + if (!hasContent(childEntry)) { + bindContent(childEntry); } } } } } - private boolean hasChildContent(NotificationEntry entry) { + private boolean hasContent(NotificationEntry entry) { ExpandableNotificationRow row = entry.getRow(); return row.getPrivateLayout().getContractedChild() != null || row.getPrivateLayout().getExpandedChild() != null; } - private void freeChildContent(NotificationEntry entry) { + private void freeContent(NotificationEntry entry) { RowContentBindParams params = mStage.getStageParams(entry); params.markContentViewsFreeable(FLAG_CONTENT_VIEW_CONTRACTED); params.markContentViewsFreeable(FLAG_CONTENT_VIEW_EXPANDED); mStage.requestRebind(entry, null); } - private void bindChildContent(NotificationEntry entry) { + private void bindContent(NotificationEntry entry) { RowContentBindParams params = mStage.getStageParams(entry); params.requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED); params.requireContentViews(FLAG_CONTENT_VIEW_EXPANDED); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicChildBindControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicChildBindControllerTest.java index 29040147d1ca8..d0dfb17111c66 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicChildBindControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicChildBindControllerTest.java @@ -80,7 +80,7 @@ public class DynamicChildBindControllerTest extends SysuiTestCase { when(mBindStage.getStageParams(lastChild)).thenReturn(bindParams); // WHEN the controller gets the list - mDynamicChildBindController.updateChildContentViews(mGroupNotifs); + mDynamicChildBindController.updateContentViews(mGroupNotifs); // THEN we free content views verify(bindParams).markContentViewsFreeable(FLAG_CONTENT_VIEW_CONTRACTED); @@ -101,7 +101,7 @@ public class DynamicChildBindControllerTest extends SysuiTestCase { when(mBindStage.getStageParams(lastChild)).thenReturn(bindParams); // WHEN the controller gets the list - mDynamicChildBindController.updateChildContentViews(mGroupNotifs); + mDynamicChildBindController.updateContentViews(mGroupNotifs); // THEN we bind content views verify(bindParams).requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED);