Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02e6e7e3 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB][Notif] Make sure re-tapping notif chip hides HUN immediately.

I originally implemented this behavior in ag/31139202 and it seemed like
it worked because the minimum timeout for the HUN was 1 second. But
later in ag/31744914 we updated the minimum timeout for chip HUNs to be
3 seconds, which means re-tapping the chip no longer worked if you did
it within the first 3 seconds.

This CL ensures we remove the HUN immediately if the user re-tapped the
chip since it's a clear user action.

Fixes: 399882113
Bug: 364653005
Flag: com.android.systemui.status_bar_notification_chips
Test: Tap chip then immediately re-tap chip -> verify HUN immediately
disappears (see video in bug)
Test: atest HeadsUpCoordinatorTest

Change-Id: I62e71c425df8d05cf2771ea2731d9ad1661d69f9
parent aa47a2f8
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -549,7 +549,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun onPromotedNotificationChipTapped_chipTappedTwice_hunHiddenOnSecondTap() =
    fun onPromotedNotificationChipTapped_chipTappedTwice_hunHiddenOnSecondTapImmediately() =
        testScope.runTest {
            whenever(notifCollection.getEntry(entry.key)).thenReturn(entry)

@@ -570,8 +570,9 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
            executor.runAllReady()
            beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

            // THEN HUN is hidden
            verify(headsUpManager).removeNotification(eq(entry.key), eq(false), any())
            // THEN HUN is hidden and it's hidden immediately
            verify(headsUpManager)
                .removeNotification(eq(entry.key), /* releaseImmediately= */ eq(true), any())
        }

    @Test
+7 −2
Original line number Diff line number Diff line
@@ -27,10 +27,10 @@ import com.android.systemui.statusbar.chips.notification.domain.interactor.Statu
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.notification.NotifPipelineFlags
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.NotifCollection
import com.android.systemui.statusbar.notification.collection.NotifPipeline
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter
@@ -459,7 +459,12 @@ constructor(
                } else {
                    if (posted.isHeadsUpEntry) {
                        // We don't want this to be interrupting anymore, let's remove it
                        hunMutator.removeNotification(posted.key, false /*removeImmediately*/)
                        // If the notification is pinned by the user, the only way a user can un-pin
                        // it is by tapping the status bar notification chip. Since that's a clear
                        // user action, we should remove the HUN immediately instead of waiting for
                        // any sort of minimum timeout.
                        val shouldRemoveImmediately = posted.isPinnedByUser
                        hunMutator.removeNotification(posted.key, shouldRemoveImmediately)
                    } else {
                        // Don't let the bind finish
                        cancelHeadsUpBind(posted.entry)