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

Commit 677b95ca authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge "Require shortcut to bubble" into rvc-dev am: 1dbf98fb am: b60d52c6

Change-Id: Ic69295685644f6190cc56e6f5acb940856b8cc8e
parents d3d9bbcb b60d52c6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class BubbleExtractor implements NotificationSignalExtractor {
        boolean canPresentAsBubble = canPresentAsBubble(record)
                && !mActivityManager.isLowRamDevice()
                && record.isConversation()
                && record.getShortcutInfo() != null
                && (record.getNotification().flags & FLAG_FOREGROUND_SERVICE) == 0;

        if (!mConfig.bubblesEnabled()
+20 −2
Original line number Diff line number Diff line
@@ -431,7 +431,7 @@ public class BubbleExtractorTest extends UiServiceTestCase {
    }

    @Test
    public void testFlagBubble_false_notConversation() {
    public void testFlagBubble_false_noShortcut() {
        setUpBubblesEnabled(true /* feature */,
                BUBBLE_PREFERENCE_ALL /* app */,
                DEFAULT_ALLOW_BUBBLE /* channel */);
@@ -439,7 +439,6 @@ public class BubbleExtractorTest extends UiServiceTestCase {
        setUpIntentBubble(true /* isValid */);

        NotificationRecord r = getNotificationRecord(true /* bubble */);
        // No longer a conversation:
        r.setShortcutInfo(null);
        r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null);

@@ -450,6 +449,25 @@ public class BubbleExtractorTest extends UiServiceTestCase {
        assertFalse(r.getNotification().isBubbleNotification());
    }

    @Test
    public void testFlagBubble_false_notConversation() {
        setUpBubblesEnabled(true /* feature */,
                BUBBLE_PREFERENCE_ALL /* app */,
                DEFAULT_ALLOW_BUBBLE /* channel */);
        when(mActivityManager.isLowRamDevice()).thenReturn(false);
        setUpIntentBubble(true /* isValid */);

        NotificationRecord r = getNotificationRecord(true /* bubble */);
        r.userDemotedAppFromConvoSpace(true);
        r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null);

        mBubbleExtractor.process(r);

        assertFalse(r.canBubble());
        assertNull(r.getNotification().getBubbleMetadata());
        assertFalse(r.getNotification().isBubbleNotification());
    }

    @Test
    public void testFlagBubble_false_lowRamDevice() {
        setUpBubblesEnabled(true /* feature */,
+22 −0
Original line number Diff line number Diff line
@@ -5308,6 +5308,28 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                nr.getSbn().getKey()).getNotification().isBubbleNotification());
    }

    @Test
    public void testFlagBubbleNotifs_noFlag_noShortcut() throws RemoteException {
        setUpPrefsForBubbles(PKG, mUid,
                true /* global */,
                BUBBLE_PREFERENCE_ALL /* app */,
                true /* channel */);

        Notification.Builder nb = getMessageStyleNotifBuilder(true, null, false);
        nb.setShortcutId(null);
        StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 1,
                null, mUid, 0,
                nb.build(), new UserHandle(mUid), null, 0);

        mBinderService.enqueueNotificationWithTag(PKG, PKG, sbn.getTag(),
                sbn.getId(), sbn.getNotification(), sbn.getUserId());
        waitForIdle();

        // no shortcut no bubble
        assertFalse(mService.getNotificationRecord(
                sbn.getKey()).getNotification().isBubbleNotification());
    }

    @Test
    public void testFlagBubbleNotifs_noFlag_messaging_appNotAllowed() throws RemoteException {
        setUpPrefsForBubbles(PKG, mUid,