Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt +7 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,13 @@ class HeadsUpCoordinator @Inject constructor( // At this point we just need to initiate the transfer val summaryUpdate = mPostedEntries[logicalSummary.key] // Because we now know for certain that some child is going to alert for this summary // (as we have found a child to transfer the alert to), mark the group as having // interrupted. This will allow us to know in the future that the "should heads up" // state of this group has already been handled, just not via the summary entry itself. logicalSummary.setInterruption() mLogger.logSummaryMarkedInterrupted(logicalSummary.key, childToReceiveParentAlert.key) // If the summary was not attached, then remove the alert from the detached summary. // Otherwise we can simply ignore its posted update. if (!isSummaryAttached) { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinatorLogger.kt +9 −0 Original line number Diff line number Diff line Loading @@ -69,4 +69,13 @@ class HeadsUpCoordinatorLogger constructor( "updating entry via ranking applied: $str1 updated shouldHeadsUp=$bool1" }) } fun logSummaryMarkedInterrupted(summaryKey: String, childKey: String) { buffer.log(TAG, LogLevel.DEBUG, { str1 = summaryKey str2 = childKey }, { "marked group summary as interrupted: $str1 for alert transfer to child: $str2" }) } } packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinatorTest.kt +39 −0 Original line number Diff line number Diff line Loading @@ -406,6 +406,10 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupSibling1) // In addition make sure we have explicitly marked the summary as having interrupted due // to the alert being transferred assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading @@ -424,6 +428,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupChild1) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading @@ -449,6 +454,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupSibling1) verify(mHeadsUpManager, never()).showNotification(mGroupSibling2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading @@ -474,6 +480,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupChild1) verify(mHeadsUpManager, never()).showNotification(mGroupChild2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading Loading @@ -512,6 +519,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager).showNotification(mGroupPriority) verify(mHeadsUpManager, never()).showNotification(mGroupSibling1) verify(mHeadsUpManager, never()).showNotification(mGroupSibling2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading Loading @@ -548,6 +556,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager).showNotification(mGroupPriority) verify(mHeadsUpManager, never()).showNotification(mGroupSibling1) verify(mHeadsUpManager, never()).showNotification(mGroupSibling2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading Loading @@ -582,6 +591,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager).showNotification(mGroupPriority) verify(mHeadsUpManager, never()).showNotification(mGroupSibling1) verify(mHeadsUpManager, never()).showNotification(mGroupSibling2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading Loading @@ -671,6 +681,35 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupChild2) } @Test fun testNoTransfer_groupSummaryNotAlerting() { // When we have a group where the summary should not alert and exactly one child should // alert, we should never mark the group summary as interrupted (because it doesn't). setShouldHeadsUp(mGroupSummary, false) setShouldHeadsUp(mGroupChild1, true) setShouldHeadsUp(mGroupChild2, false) mCollectionListener.onEntryAdded(mGroupSummary) mCollectionListener.onEntryAdded(mGroupChild1) mCollectionListener.onEntryAdded(mGroupChild2) val groupEntry = GroupEntryBuilder() .setSummary(mGroupSummary) .setChildren(listOf(mGroupChild1, mGroupChild2)) .build() mBeforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupEntry)) verify(mHeadsUpViewBinder, never()).bindHeadsUpView(any(), any()) mBeforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupEntry)) verify(mHeadsUpViewBinder, never()).bindHeadsUpView(eq(mGroupSummary), any()) finishBind(mGroupChild1) verify(mHeadsUpViewBinder, never()).bindHeadsUpView(eq(mGroupChild2), any()) verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupChild1) verify(mHeadsUpManager, never()).showNotification(mGroupChild2) assertFalse(mGroupSummary.hasInterrupted()) } @Test fun testOnRankingApplied_newEntryShouldAlert() { // GIVEN that mEntry has never interrupted in the past, and now should Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt +7 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,13 @@ class HeadsUpCoordinator @Inject constructor( // At this point we just need to initiate the transfer val summaryUpdate = mPostedEntries[logicalSummary.key] // Because we now know for certain that some child is going to alert for this summary // (as we have found a child to transfer the alert to), mark the group as having // interrupted. This will allow us to know in the future that the "should heads up" // state of this group has already been handled, just not via the summary entry itself. logicalSummary.setInterruption() mLogger.logSummaryMarkedInterrupted(logicalSummary.key, childToReceiveParentAlert.key) // If the summary was not attached, then remove the alert from the detached summary. // Otherwise we can simply ignore its posted update. if (!isSummaryAttached) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinatorLogger.kt +9 −0 Original line number Diff line number Diff line Loading @@ -69,4 +69,13 @@ class HeadsUpCoordinatorLogger constructor( "updating entry via ranking applied: $str1 updated shouldHeadsUp=$bool1" }) } fun logSummaryMarkedInterrupted(summaryKey: String, childKey: String) { buffer.log(TAG, LogLevel.DEBUG, { str1 = summaryKey str2 = childKey }, { "marked group summary as interrupted: $str1 for alert transfer to child: $str2" }) } }
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinatorTest.kt +39 −0 Original line number Diff line number Diff line Loading @@ -406,6 +406,10 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupSibling1) // In addition make sure we have explicitly marked the summary as having interrupted due // to the alert being transferred assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading @@ -424,6 +428,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupChild1) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading @@ -449,6 +454,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupSibling1) verify(mHeadsUpManager, never()).showNotification(mGroupSibling2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading @@ -474,6 +480,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupChild1) verify(mHeadsUpManager, never()).showNotification(mGroupChild2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading Loading @@ -512,6 +519,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager).showNotification(mGroupPriority) verify(mHeadsUpManager, never()).showNotification(mGroupSibling1) verify(mHeadsUpManager, never()).showNotification(mGroupSibling2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading Loading @@ -548,6 +556,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager).showNotification(mGroupPriority) verify(mHeadsUpManager, never()).showNotification(mGroupSibling1) verify(mHeadsUpManager, never()).showNotification(mGroupSibling2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading Loading @@ -582,6 +591,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager).showNotification(mGroupPriority) verify(mHeadsUpManager, never()).showNotification(mGroupSibling1) verify(mHeadsUpManager, never()).showNotification(mGroupSibling2) assertTrue(mGroupSummary.hasInterrupted()) } @Test Loading Loading @@ -671,6 +681,35 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(mHeadsUpManager, never()).showNotification(mGroupChild2) } @Test fun testNoTransfer_groupSummaryNotAlerting() { // When we have a group where the summary should not alert and exactly one child should // alert, we should never mark the group summary as interrupted (because it doesn't). setShouldHeadsUp(mGroupSummary, false) setShouldHeadsUp(mGroupChild1, true) setShouldHeadsUp(mGroupChild2, false) mCollectionListener.onEntryAdded(mGroupSummary) mCollectionListener.onEntryAdded(mGroupChild1) mCollectionListener.onEntryAdded(mGroupChild2) val groupEntry = GroupEntryBuilder() .setSummary(mGroupSummary) .setChildren(listOf(mGroupChild1, mGroupChild2)) .build() mBeforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupEntry)) verify(mHeadsUpViewBinder, never()).bindHeadsUpView(any(), any()) mBeforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupEntry)) verify(mHeadsUpViewBinder, never()).bindHeadsUpView(eq(mGroupSummary), any()) finishBind(mGroupChild1) verify(mHeadsUpViewBinder, never()).bindHeadsUpView(eq(mGroupChild2), any()) verify(mHeadsUpManager, never()).showNotification(mGroupSummary) verify(mHeadsUpManager).showNotification(mGroupChild1) verify(mHeadsUpManager, never()).showNotification(mGroupChild2) assertFalse(mGroupSummary.hasInterrupted()) } @Test fun testOnRankingApplied_newEntryShouldAlert() { // GIVEN that mEntry has never interrupted in the past, and now should Loading