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

Commit 3f40ec34 authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge "Mark bubbles as updated when they're added to the stack" into sc-v2-dev...

Merge "Mark bubbles as updated when they're added to the stack" into sc-v2-dev am: 6b1abd9b am: 8834b96d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16374106

Change-Id: I217f3b55666f3b1f21ad12fa5081d44bea60162b
parents 238f9d57 8834b96d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -328,6 +328,7 @@ public class BubbleData {
        if (prevBubble == null) {
            // Create a new bubble
            bubble.setSuppressFlyout(suppressFlyout);
            bubble.markUpdatedAt(mTimeSource.currentTimeMillis());
            doAdd(bubble);
            trim();
        } else {
+32 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.util.Log;
import android.util.Pair;
import android.view.WindowManager;

@@ -913,6 +914,31 @@ public class BubbleDataTest extends ShellTestCase {
        assertSelectionChangedTo(mBubbleA2);
    }

    /**
      * - have a maxed out bubble stack & all of the bubbles have been recently accessed
      * - bubble a notification that was posted before any of those bubbles were accessed
      * => that bubble should be added
     *
      */
    @Test
    public void test_addOldNotifWithNewerBubbles() {
        sendUpdatedEntryAtTime(mEntryA1, 2000);
        sendUpdatedEntryAtTime(mEntryA2, 3000);
        sendUpdatedEntryAtTime(mEntryA3, 4000);
        sendUpdatedEntryAtTime(mEntryB1, 5000);
        sendUpdatedEntryAtTime(mEntryB2, 6000);

        mBubbleData.setListener(mListener);
        sendUpdatedEntryAtTime(mEntryB3, 1000 /* postTime */, 7000 /* currentTime */);
        verifyUpdateReceived();

        // B3 is in the stack
        assertThat(mBubbleData.getBubbleInStackWithKey(mBubbleB3.getKey())).isNotNull();
        // A1 is the oldest so it's in the overflow
        assertThat(mBubbleData.getOverflowBubbleWithKey(mEntryA1.getKey())).isNotNull();
        assertOrderChangedTo(mBubbleB3, mBubbleB2, mBubbleB1, mBubbleA3, mBubbleA2);
    }

    private void verifyUpdateReceived() {
        verify(mListener).applyUpdate(mUpdateCaptor.capture());
        reset(mListener);
@@ -1014,6 +1040,12 @@ public class BubbleDataTest extends ShellTestCase {
    }

    private void sendUpdatedEntryAtTime(BubbleEntry entry, long postTime) {
        setCurrentTime(postTime);
        sendUpdatedEntryAtTime(entry, postTime, true /* isTextChanged */);
    }

    private void sendUpdatedEntryAtTime(BubbleEntry entry, long postTime, long currentTime) {
        setCurrentTime(currentTime);
        sendUpdatedEntryAtTime(entry, postTime, true /* isTextChanged */);
    }