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

Commit 6a051804 authored by Lyn's avatar Lyn
Browse files

Fix missing grouping after shade closes

Fixes: 356516285

Test: HeadsUpManagerPhoneTest

Test: send message HUN from two contacts from same app
      open shade, close shade
      => see that HUNs are grouped

Test: send delayed HUN, open shade, close shade before delayed HUN
      times out
      => see no disappear animation (no regression)

Flag: com.android.systemui.notification_avalanche_throttle_hun

Change-Id: Ib49522e57811b2670a60b3d05e92c3b7410cec87
parent d7d2a245
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.systemui.util.kotlin.JavaAdapter
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.settings.GlobalSettings
import com.android.systemui.util.time.SystemClock
import com.google.common.truth.Truth.assertThat
import junit.framework.Assert
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
@@ -244,35 +245,37 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager
        mSystemClock.advanceTime((TEST_AUTO_DISMISS_TIME + hmp.mExtensionTime / 2).toLong())
        Assert.assertTrue(hmp.isHeadsUpEntry(entry.key))
    }
    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testShowNotification_removeWhenReorderingAllowedTrue() {
        whenever(mVSProvider.isReorderingAllowed).thenReturn(true)
        val hmp = createHeadsUpManagerPhone()

        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        hmp.showNotification(notifEntry)
        assertThat(hmp.mEntriesToRemoveWhenReorderingAllowed.contains(notifEntry)).isTrue();
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testShowNotification_reorderNotAllowed_notPulsing_seenInShadeTrue() {
    fun testShowNotification_reorderNotAllowed_seenInShadeTrue() {
        whenever(mVSProvider.isReorderingAllowed).thenReturn(false)
        val hmp = createHeadsUpManagerPhone()

        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        val row = mock<ExpandableNotificationRow>()
        whenever(row.showingPulsing()).thenReturn(false)
        notifEntry.row = row

        hmp.showNotification(notifEntry)
        Assert.assertTrue(notifEntry.isSeenInShade)
        assertThat(notifEntry.isSeenInShade).isTrue();
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testShowNotification_reorderAllowed_notPulsing_seenInShadeFalse() {
    fun testShowNotification_reorderAllowed_seenInShadeFalse() {
        whenever(mVSProvider.isReorderingAllowed).thenReturn(true)
        val hmp = createHeadsUpManagerPhone()

        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        val row = mock<ExpandableNotificationRow>()
        whenever(row.showingPulsing()).thenReturn(false)
        notifEntry.row = row

        hmp.showNotification(notifEntry)
        Assert.assertFalse(notifEntry.isSeenInShade)
        assertThat(notifEntry.isSeenInShade).isFalse();
    }

    @Test
+4 −6
Original line number Diff line number Diff line
@@ -103,7 +103,8 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
    private boolean mTrackingHeadsUp;
    private final HashSet<String> mSwipedOutKeys = new HashSet<>();
    private final HashSet<NotificationEntry> mEntriesToRemoveAfterExpand = new HashSet<>();
    private final ArraySet<NotificationEntry> mEntriesToRemoveWhenReorderingAllowed
    @VisibleForTesting
    public final ArraySet<NotificationEntry> mEntriesToRemoveWhenReorderingAllowed
            = new ArraySet<>();
    private boolean mIsShadeOrQsExpanded;
    private boolean mIsQsExpanded;
@@ -630,11 +631,8 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
            super.setEntry(entry, removeRunnable);

            if (NotificationThrottleHun.isEnabled()) {
                if (!mVisualStabilityProvider.isReorderingAllowed()
                        // We don't want to allow reordering while pulsing, but headsup need to
                        // time out anyway
                        && !entry.showingPulsing()) {
                mEntriesToRemoveWhenReorderingAllowed.add(entry);
                if (!mVisualStabilityProvider.isReorderingAllowed()) {
                    entry.setSeenInShade(true);
                }
            }