From 6ea2787920ee132c3b88fc86f13b43742d5f69b4 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Tue, 30 May 2017 12:00:04 -0700 Subject: [PATCH] Fix header not set on initialization Header not being set was causing min priority groups to skip expansion animation. Bug: 38436027 Test: runtest -x frameworks/base/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java Change-Id: I34307a7e5ecfe7e30d5bf97880b17fedb0d84378 --- .../stack/NotificationChildrenContainer.java | 16 +++++++++++++--- .../stack/NotificationChildrenContainerTest.java | 8 ++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java index 0dbd1d6cc74af..ff06b5b33a05c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java @@ -300,7 +300,7 @@ public class NotificationChildrenContainer extends ViewGroup { mNotificationHeaderWrapper.notifyContentUpdated(mContainingNotification); recreateLowPriorityHeader(builder); recreateAmbientHeader(builder); - resetHeaderVisibilityIfNeeded(mNotificationHeader, calculateDesiredHeader()); + updateHeaderVisibility(false /* animate */); updateChildrenHeaderAppearance(); } @@ -833,6 +833,11 @@ public class NotificationChildrenContainer extends ViewGroup { return mNotificationHeaderLowPriority; } + @VisibleForTesting + public ViewGroup getCurrentHeaderView() { + return mCurrentHeader; + } + public void notifyShowAmbientChanged() { updateHeaderVisibility(false); } @@ -869,7 +874,12 @@ public class NotificationChildrenContainer extends ViewGroup { desiredHeader.setVisibility(VISIBLE); } if (currentHeader != null) { - getWrapperForView(currentHeader).setVisible(false); + // Wrapper can be null if we were a low priority notification + // and just destroyed it by calling setIsLowPriority(false) + NotificationViewWrapper wrapper = getWrapperForView(currentHeader); + if (wrapper != null) { + wrapper.setVisible(false); + } currentHeader.setVisibility(INVISIBLE); } } @@ -878,7 +888,7 @@ public class NotificationChildrenContainer extends ViewGroup { resetHeaderVisibilityIfNeeded(mNotificationHeaderAmbient, desiredHeader); resetHeaderVisibilityIfNeeded(mNotificationHeaderLowPriority, desiredHeader); - mCurrentHeader = currentHeader; + mCurrentHeader = desiredHeader; } private void resetHeaderVisibilityIfNeeded(View header, View desiredHeader) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java index e6c8815b9e212..2dd96b6869962 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java @@ -60,4 +60,12 @@ public class NotificationChildrenContainerTest extends SysuiTestCase { Assert.assertTrue(lowPriorityHeaderView.getParent() == null); Assert.assertTrue(childrenContainer.getLowPriorityHeaderView() == null); } + + @Test + public void testRecreateNotificationHeader_hasHeader() { + NotificationChildrenContainer childrenContainer = mGroup.getChildrenContainer(); + childrenContainer.recreateNotificationHeader(null); + Assert.assertNotNull("Children container must have a header after recreation", + childrenContainer.getCurrentHeaderView()); + } }