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

Commit 60d6833f authored by Julia Tuttle's avatar Julia Tuttle Committed by Android (Google) Code Review
Browse files

Merge changes I0437f1a2,Icbe9bcbb,Ia94dbde4,I7ba38220 into main

* changes:
  VisualInterruptionDecisionProvider: suppress peek/pulse when app suspended
  NotificationInterruptStateProvider: suppress peek/pulse when app suspended
  VisualInterruptionDecisionProviderTestBase: test app suspended
  Make ktfmt happy.
parents 23758d57 5fef4180
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -207,11 +207,6 @@ class BubbleNotAllowedSuppressor() :
    override fun shouldSuppress(entry: NotificationEntry) = !entry.canBubble()
    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() :
class BubbleNoMetadataSuppressor() :
    VisualInterruptionFilter(types = setOf(BUBBLE), reason = "has no or invalid bubble metadata") {
    VisualInterruptionFilter(types = setOf(BUBBLE), reason = "has no or invalid bubble metadata") {


@@ -221,6 +216,11 @@ class BubbleNoMetadataSuppressor() :
    override fun shouldSuppress(entry: NotificationEntry) = !isValidMetadata(entry.bubbleMetadata)
    override fun shouldSuppress(entry: NotificationEntry) = !isValidMetadata(entry.bubbleMetadata)
}
}


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

class AlertKeyguardVisibilitySuppressor(
class AlertKeyguardVisibilitySuppressor(
    private val keyguardNotificationVisibilityProvider: KeyguardNotificationVisibilityProvider
    private val keyguardNotificationVisibilityProvider: KeyguardNotificationVisibilityProvider
) : VisualInterruptionFilter(types = setOf(PEEK, PULSE, BUBBLE), reason = "hidden on keyguard") {
) : VisualInterruptionFilter(types = setOf(PEEK, PULSE, BUBBLE), reason = "hidden on keyguard") {
@@ -228,11 +228,11 @@ class AlertKeyguardVisibilitySuppressor(
        keyguardNotificationVisibilityProvider.shouldHideNotification(entry)
        keyguardNotificationVisibilityProvider.shouldHideNotification(entry)
}
}



class AvalancheSuppressor(
class AvalancheSuppressor(
    private val avalancheProvider: AvalancheProvider,
    private val avalancheProvider: AvalancheProvider,
    private val systemClock: SystemClock,
    private val systemClock: SystemClock,
) : VisualInterruptionFilter(
) :
    VisualInterruptionFilter(
        types = setOf(PEEK, PULSE),
        types = setOf(PEEK, PULSE),
        reason = "avalanche",
        reason = "avalanche",
    ) {
    ) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -56,11 +56,11 @@ class NotificationInterruptLogger @Inject constructor(
        }
        }
    }
    }


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


+7 −5
Original line number Original line Diff line number Diff line
@@ -204,11 +204,6 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
            return false;
            return false;
        }
        }


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

        if (entry.getBubbleMetadata() == null
        if (entry.getBubbleMetadata() == null
                || (entry.getBubbleMetadata().getShortcutId() == null
                || (entry.getBubbleMetadata().getShortcutId() == null
                    && entry.getBubbleMetadata().getIntent() == null)) {
                    && entry.getBubbleMetadata().getIntent() == null)) {
@@ -559,6 +554,13 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
            }
            }
        }
        }


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

        if (mKeyguardNotificationVisibilityProvider.shouldHideNotification(entry)) {
        if (mKeyguardNotificationVisibilityProvider.shouldHideNotification(entry)) {
            if (log) mLogger.logNoAlertingNotificationHidden(entry);
            if (log) mLogger.logNoAlertingNotificationHidden(entry);
            return false;
            return false;
+17 −18
Original line number Original line Diff line number Diff line
@@ -62,7 +62,6 @@ constructor(
    private val uiEventLogger: UiEventLogger,
    private val uiEventLogger: UiEventLogger,
    private val userTracker: UserTracker,
    private val userTracker: UserTracker,
    private val avalancheProvider: AvalancheProvider
    private val avalancheProvider: AvalancheProvider

) : VisualInterruptionDecisionProvider {
) : VisualInterruptionDecisionProvider {


    init {
    init {
@@ -164,10 +163,10 @@ constructor(
        addFilter(PulseLockscreenVisibilityPrivateSuppressor())
        addFilter(PulseLockscreenVisibilityPrivateSuppressor())
        addFilter(PulseLowImportanceSuppressor())
        addFilter(PulseLowImportanceSuppressor())
        addFilter(BubbleNotAllowedSuppressor())
        addFilter(BubbleNotAllowedSuppressor())
        addFilter(BubbleAppSuspendedSuppressor())
        addFilter(BubbleNoMetadataSuppressor())
        addFilter(BubbleNoMetadataSuppressor())
        addFilter(HunGroupAlertBehaviorSuppressor())
        addFilter(HunGroupAlertBehaviorSuppressor())
        addFilter(HunJustLaunchedFsiSuppressor())
        addFilter(HunJustLaunchedFsiSuppressor())
        addFilter(AlertAppSuspendedSuppressor())
        addFilter(AlertKeyguardVisibilitySuppressor(keyguardNotificationVisibilityProvider))
        addFilter(AlertKeyguardVisibilitySuppressor(keyguardNotificationVisibilityProvider))


        if (NotificationAvalancheSuppression.isEnabled) {
        if (NotificationAvalancheSuppression.isEnabled) {
+20 −6
Original line number Original line Diff line number Diff line
@@ -326,6 +326,13 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {
        assertNoEventsLogged()
        assertNoEventsLogged()
    }
    }


    @Test
    fun testShouldNotPeek_appSuspended() {
        ensurePeekState()
        assertShouldNotBubble(buildPeekEntry { packageSuspended = true })
        assertNoEventsLogged()
    }

    @Test
    @Test
    fun testShouldNotPeek_hiddenOnKeyguard() {
    fun testShouldNotPeek_hiddenOnKeyguard() {
        ensurePeekState({ keyguardShouldHideNotification = true })
        ensurePeekState({ keyguardShouldHideNotification = true })
@@ -411,6 +418,13 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {
        assertNoEventsLogged()
        assertNoEventsLogged()
    }
    }


    @Test
    fun testShouldNotPulse_appSuspended() {
        ensurePulseState()
        assertShouldNotHeadsUp(buildPulseEntry { packageSuspended = true })
        assertNoEventsLogged()
    }

    @Test
    @Test
    fun testShouldNotPulse_hiddenOnKeyguard() {
    fun testShouldNotPulse_hiddenOnKeyguard() {
        ensurePulseState({ keyguardShouldHideNotification = true })
        ensurePulseState({ keyguardShouldHideNotification = true })
@@ -595,16 +609,16 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {
    }
    }


    @Test
    @Test
    fun testShouldNotBubble_hiddenOnKeyguard() {
    fun testShouldNotBubble_appSuspended() {
        ensureBubbleState({ keyguardShouldHideNotification = true })
        ensureBubbleState()
        assertShouldNotBubble(buildBubbleEntry())
        assertShouldNotBubble(buildBubbleEntry { packageSuspended = true })
        assertNoEventsLogged()
        assertNoEventsLogged()
    }
    }


    @Test
    @Test
    fun testShouldNotBubble_bubbleAppSuspended() {
    fun testShouldNotBubble_hiddenOnKeyguard() {
        ensureBubbleState()
        ensureBubbleState({ keyguardShouldHideNotification = true })
        assertShouldNotBubble(buildBubbleEntry { packageSuspended = true })
        assertShouldNotBubble(buildBubbleEntry())
        assertNoEventsLogged()
        assertNoEventsLogged()
    }
    }