Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt +21 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.interruption import android.app.Notification.VISIBILITY_PRIVATE import android.app.NotificationManager.IMPORTANCE_DEFAULT import android.app.NotificationManager.IMPORTANCE_HIGH import android.database.ContentObserver import android.hardware.display.AmbientDisplayConfiguration Loading Loading @@ -159,3 +161,22 @@ class PeekOldWhenSuppressor(private val systemClock: SystemClock) : else -> whenAge(entry) >= MAX_HUN_WHEN_AGE_MS } } class PulseEffectSuppressor() : VisualInterruptionFilter(types = setOf(PULSE), reason = "ambient effect suppressed") { override fun shouldSuppress(entry: NotificationEntry) = entry.shouldSuppressAmbient() } class PulseLockscreenVisibilityPrivateSuppressor() : VisualInterruptionFilter( types = setOf(PULSE), reason = "notification hidden on lock screen by override" ) { override fun shouldSuppress(entry: NotificationEntry) = entry.ranking.lockscreenVisibilityOverride == VISIBILITY_PRIVATE } class PulseLowImportanceSuppressor() : VisualInterruptionFilter(types = setOf(PULSE), reason = "importance less than DEFAULT") { override fun shouldSuppress(entry: NotificationEntry) = entry.importance < IMPORTANCE_DEFAULT } packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt +3 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,9 @@ constructor( addFilter(PeekNotImportantSuppressor()) addCondition(PeekDeviceNotInUseSuppressor(powerManager, statusBarStateController)) addFilter(PeekOldWhenSuppressor(systemClock)) addFilter(PulseEffectSuppressor()) addFilter(PulseLockscreenVisibilityPrivateSuppressor()) addFilter(PulseLowImportanceSuppressor()) started = true } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt +23 −0 Original line number Diff line number Diff line Loading @@ -20,9 +20,12 @@ import android.app.ActivityManager import android.app.Notification import android.app.Notification.BubbleMetadata import android.app.Notification.FLAG_BUBBLE import android.app.Notification.VISIBILITY_PRIVATE import android.app.NotificationChannel import android.app.NotificationManager.IMPORTANCE_DEFAULT import android.app.NotificationManager.IMPORTANCE_HIGH import android.app.NotificationManager.IMPORTANCE_LOW import android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT import android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK import android.app.NotificationManager.VISIBILITY_NO_OVERRIDE import android.app.PendingIntent Loading Loading @@ -282,6 +285,26 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() { assertShouldNotHeadsUp(buildPulseEntry()) } @Test fun testShouldNotPulse_effectSuppressed() { ensurePulseState() assertShouldNotHeadsUp( buildPulseEntry { suppressedVisualEffects = SUPPRESSED_EFFECT_AMBIENT } ) } @Test fun testShouldNotPulse_visibilityOverridePrivate() { ensurePulseState() assertShouldNotHeadsUp(buildPulseEntry { visibilityOverride = VISIBILITY_PRIVATE }) } @Test fun testShouldNotPulse_importanceLow() { ensurePulseState() assertShouldNotHeadsUp(buildPulseEntry { importance = IMPORTANCE_LOW }) } @Test fun testShouldBubble() { ensureBubbleState() Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt +21 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.interruption import android.app.Notification.VISIBILITY_PRIVATE import android.app.NotificationManager.IMPORTANCE_DEFAULT import android.app.NotificationManager.IMPORTANCE_HIGH import android.database.ContentObserver import android.hardware.display.AmbientDisplayConfiguration Loading Loading @@ -159,3 +161,22 @@ class PeekOldWhenSuppressor(private val systemClock: SystemClock) : else -> whenAge(entry) >= MAX_HUN_WHEN_AGE_MS } } class PulseEffectSuppressor() : VisualInterruptionFilter(types = setOf(PULSE), reason = "ambient effect suppressed") { override fun shouldSuppress(entry: NotificationEntry) = entry.shouldSuppressAmbient() } class PulseLockscreenVisibilityPrivateSuppressor() : VisualInterruptionFilter( types = setOf(PULSE), reason = "notification hidden on lock screen by override" ) { override fun shouldSuppress(entry: NotificationEntry) = entry.ranking.lockscreenVisibilityOverride == VISIBILITY_PRIVATE } class PulseLowImportanceSuppressor() : VisualInterruptionFilter(types = setOf(PULSE), reason = "importance less than DEFAULT") { override fun shouldSuppress(entry: NotificationEntry) = entry.importance < IMPORTANCE_DEFAULT }
packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt +3 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,9 @@ constructor( addFilter(PeekNotImportantSuppressor()) addCondition(PeekDeviceNotInUseSuppressor(powerManager, statusBarStateController)) addFilter(PeekOldWhenSuppressor(systemClock)) addFilter(PulseEffectSuppressor()) addFilter(PulseLockscreenVisibilityPrivateSuppressor()) addFilter(PulseLowImportanceSuppressor()) started = true } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt +23 −0 Original line number Diff line number Diff line Loading @@ -20,9 +20,12 @@ import android.app.ActivityManager import android.app.Notification import android.app.Notification.BubbleMetadata import android.app.Notification.FLAG_BUBBLE import android.app.Notification.VISIBILITY_PRIVATE import android.app.NotificationChannel import android.app.NotificationManager.IMPORTANCE_DEFAULT import android.app.NotificationManager.IMPORTANCE_HIGH import android.app.NotificationManager.IMPORTANCE_LOW import android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT import android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK import android.app.NotificationManager.VISIBILITY_NO_OVERRIDE import android.app.PendingIntent Loading Loading @@ -282,6 +285,26 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() { assertShouldNotHeadsUp(buildPulseEntry()) } @Test fun testShouldNotPulse_effectSuppressed() { ensurePulseState() assertShouldNotHeadsUp( buildPulseEntry { suppressedVisualEffects = SUPPRESSED_EFFECT_AMBIENT } ) } @Test fun testShouldNotPulse_visibilityOverridePrivate() { ensurePulseState() assertShouldNotHeadsUp(buildPulseEntry { visibilityOverride = VISIBILITY_PRIVATE }) } @Test fun testShouldNotPulse_importanceLow() { ensurePulseState() assertShouldNotHeadsUp(buildPulseEntry { importance = IMPORTANCE_LOW }) } @Test fun testShouldBubble() { ensureBubbleState() Loading