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

Commit d7a733fd authored by Liran Binyamin's avatar Liran Binyamin Committed by Android (Google) Code Review
Browse files

Merge "Don't push bubbles from distracting apps in focus mode" into main

parents c3578967 32267575
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -204,6 +204,11 @@ class BubbleNotAllowedSuppressor() :
    override fun shouldSuppress(entry: NotificationEntry) = !entry.canBubble()
}

class BubbleAppSuspendedSuppressor :
    VisualInterruptionFilter(types = setOf(BUBBLE), reason = "app is suspended") {
    override fun shouldSuppress(entry: NotificationEntry) = entry.ranking.isSuspended
}

class BubbleNoMetadataSuppressor() :
    VisualInterruptionFilter(types = setOf(BUBBLE), reason = "has no or invalid bubble metadata") {

+8 −0
Original line number Diff line number Diff line
@@ -56,6 +56,14 @@ class NotificationInterruptLogger @Inject constructor(
        }
    }

    fun logSuspendedAppBubble(entry: NotificationEntry) {
        buffer.log(TAG, DEBUG, {
            str1 = entry.logKey
        }, {
            "No bubble up: notification: app $str1 is suspended"
        })
    }

    fun logNoBubbleNoMetadata(entry: NotificationEntry) {
        buffer.log(TAG, DEBUG, {
            str1 = entry.logKey
+5 −0
Original line number Diff line number Diff line
@@ -204,6 +204,11 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
            return false;
        }

        if (entry.getRanking().isSuspended()) {
            mLogger.logSuspendedAppBubble(entry);
            return false;
        }

        if (entry.getBubbleMetadata() == null
                || (entry.getBubbleMetadata().getShortcutId() == null
                    && entry.getBubbleMetadata().getIntent() == null)) {
+1 −0
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ constructor(
        addFilter(PulseLockscreenVisibilityPrivateSuppressor())
        addFilter(PulseLowImportanceSuppressor())
        addFilter(BubbleNotAllowedSuppressor())
        addFilter(BubbleAppSuspendedSuppressor())
        addFilter(BubbleNoMetadataSuppressor())
        addFilter(HunGroupAlertBehaviorSuppressor())
        addFilter(HunJustLaunchedFsiSuppressor())
+16 −1
Original line number Diff line number Diff line
@@ -999,11 +999,25 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase {
        assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(createBubble())).isFalse();
    }

    @Test
    public void shouldNotBubbleUp_suspended() {
        assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(createSuspendedBubble()))
                .isFalse();
    }

    private NotificationEntry createSuspendedBubble() {
        return createBubble(null, null, true);
    }

    private NotificationEntry createBubble() {
        return createBubble(null, null);
        return createBubble(null, null, false);
    }

    private NotificationEntry createBubble(String groupKey, Integer groupAlert) {
        return createBubble(groupKey, groupAlert, false);
    }

    private NotificationEntry createBubble(String groupKey, Integer groupAlert, Boolean suspended) {
        Notification.BubbleMetadata data = new Notification.BubbleMetadata.Builder(
                PendingIntent.getActivity(mContext, 0,
                        new Intent().setPackage(mContext.getPackageName()),
@@ -1031,6 +1045,7 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase {
                .setNotification(n)
                .setImportance(IMPORTANCE_HIGH)
                .setCanBubble(true)
                .setSuspended(suspended)
                .build();
    }

Loading