Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt +5 −2 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import android.provider.Settings.Global.HEADS_UP_OFF import android.service.notification.Flags import com.android.internal.logging.UiEvent import com.android.internal.logging.UiEventLogger import com.android.internal.logging.UiEventLogger.UiEventEnum.RESERVE_NEW_UI_EVENT_ID import com.android.internal.messages.nano.SystemMessageProto.SystemMessage import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.statusbar.StatusBarStateController Loading Loading @@ -279,7 +278,8 @@ class AvalancheSuppressor( private val packageManager: PackageManager, private val uiEventLogger: UiEventLogger, private val context: Context, private val notificationManager: NotificationManager private val notificationManager: NotificationManager, private val logger: VisualInterruptionDecisionLogger ) : VisualInterruptionFilter( types = setOf(PEEK, PULSE), Loading Loading @@ -354,15 +354,18 @@ class AvalancheSuppressor( override fun shouldSuppress(entry: NotificationEntry): Boolean { if (!isCooldownEnabled()) { logger.logAvalancheAllow("cooldown OFF") return false } val timeSinceAvalancheMs = systemClock.currentTimeMillis() - avalancheProvider.startTime val timedOut = timeSinceAvalancheMs >= avalancheProvider.timeoutMs if (timedOut) { logger.logAvalancheAllow("timedOut! timeSinceAvalancheMs=$timeSinceAvalancheMs") return false } val state = calculateState(entry) if (state != State.SUPPRESS) { logger.logAvalancheAllow("state=$state") return false } if (shouldShowEdu()) { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt +9 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,15 @@ constructor(@NotificationInterruptLog val buffer: LogBuffer) { } ) } fun logAvalancheAllow(info: String) { buffer.log( TAG, INFO, { str1 = info }, { "AvalancheSuppressor: $str1" } ) } } private const val TAG = "VisualInterruptionDecisionProvider" packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt +2 −1 Original line number Diff line number Diff line Loading @@ -194,7 +194,8 @@ constructor( packageManager, uiEventLogger, context, notificationManager notificationManager, logger ) ) avalancheProvider.register() Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt +21 −32 Original line number Diff line number Diff line Loading @@ -98,16 +98,20 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro // instead of VisualInterruptionDecisionProviderTestBase // because avalanche code is based on the suppression refactor. private fun getAvalancheSuppressor() : AvalancheSuppressor { return AvalancheSuppressor( avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager, logger ) } @Test fun testAvalancheFilter_suppress_hasNotSeenEdu_showEduHun() { setAllowedEmergencyPkg(false) whenever(avalancheProvider.timeoutMs).thenReturn(20) whenever(avalancheProvider.startTime).thenReturn(whenAgo(10)) val avalancheSuppressor = AvalancheSuppressor( avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager ) val avalancheSuppressor = getAvalancheSuppressor() avalancheSuppressor.hasSeenEdu = false withFilter(avalancheSuppressor) { Loading @@ -128,10 +132,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro whenever(avalancheProvider.timeoutMs).thenReturn(20) whenever(avalancheProvider.startTime).thenReturn(whenAgo(10)) val avalancheSuppressor = AvalancheSuppressor( avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager ) val avalancheSuppressor = getAvalancheSuppressor() avalancheSuppressor.hasSeenEdu = true withFilter(avalancheSuppressor) { Loading @@ -151,8 +152,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -171,8 +171,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldNotHeadsUp( Loading @@ -191,8 +190,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -209,8 +207,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -227,8 +224,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -245,8 +241,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -263,8 +258,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -281,8 +275,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -300,8 +293,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -318,8 +310,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { assertFsiNotSuppressed() } Loading @@ -330,8 +321,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading Loading @@ -359,8 +349,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro setAllowedEmergencyPkg(true) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt +1 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() { protected val settingsInteractor: NotificationSettingsInteractor = mock() protected val packageManager: PackageManager = mock() protected val notificationManager: NotificationManager = mock() protected val logger: VisualInterruptionDecisionLogger = mock() protected abstract val provider: VisualInterruptionDecisionProvider private val neverSuppresses = object : NotificationInterruptSuppressor {} Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt +5 −2 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import android.provider.Settings.Global.HEADS_UP_OFF import android.service.notification.Flags import com.android.internal.logging.UiEvent import com.android.internal.logging.UiEventLogger import com.android.internal.logging.UiEventLogger.UiEventEnum.RESERVE_NEW_UI_EVENT_ID import com.android.internal.messages.nano.SystemMessageProto.SystemMessage import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.statusbar.StatusBarStateController Loading Loading @@ -279,7 +278,8 @@ class AvalancheSuppressor( private val packageManager: PackageManager, private val uiEventLogger: UiEventLogger, private val context: Context, private val notificationManager: NotificationManager private val notificationManager: NotificationManager, private val logger: VisualInterruptionDecisionLogger ) : VisualInterruptionFilter( types = setOf(PEEK, PULSE), Loading Loading @@ -354,15 +354,18 @@ class AvalancheSuppressor( override fun shouldSuppress(entry: NotificationEntry): Boolean { if (!isCooldownEnabled()) { logger.logAvalancheAllow("cooldown OFF") return false } val timeSinceAvalancheMs = systemClock.currentTimeMillis() - avalancheProvider.startTime val timedOut = timeSinceAvalancheMs >= avalancheProvider.timeoutMs if (timedOut) { logger.logAvalancheAllow("timedOut! timeSinceAvalancheMs=$timeSinceAvalancheMs") return false } val state = calculateState(entry) if (state != State.SUPPRESS) { logger.logAvalancheAllow("state=$state") return false } if (shouldShowEdu()) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt +9 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,15 @@ constructor(@NotificationInterruptLog val buffer: LogBuffer) { } ) } fun logAvalancheAllow(info: String) { buffer.log( TAG, INFO, { str1 = info }, { "AvalancheSuppressor: $str1" } ) } } private const val TAG = "VisualInterruptionDecisionProvider"
packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt +2 −1 Original line number Diff line number Diff line Loading @@ -194,7 +194,8 @@ constructor( packageManager, uiEventLogger, context, notificationManager notificationManager, logger ) ) avalancheProvider.register() Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt +21 −32 Original line number Diff line number Diff line Loading @@ -98,16 +98,20 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro // instead of VisualInterruptionDecisionProviderTestBase // because avalanche code is based on the suppression refactor. private fun getAvalancheSuppressor() : AvalancheSuppressor { return AvalancheSuppressor( avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager, logger ) } @Test fun testAvalancheFilter_suppress_hasNotSeenEdu_showEduHun() { setAllowedEmergencyPkg(false) whenever(avalancheProvider.timeoutMs).thenReturn(20) whenever(avalancheProvider.startTime).thenReturn(whenAgo(10)) val avalancheSuppressor = AvalancheSuppressor( avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager ) val avalancheSuppressor = getAvalancheSuppressor() avalancheSuppressor.hasSeenEdu = false withFilter(avalancheSuppressor) { Loading @@ -128,10 +132,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro whenever(avalancheProvider.timeoutMs).thenReturn(20) whenever(avalancheProvider.startTime).thenReturn(whenAgo(10)) val avalancheSuppressor = AvalancheSuppressor( avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager ) val avalancheSuppressor = getAvalancheSuppressor() avalancheSuppressor.hasSeenEdu = true withFilter(avalancheSuppressor) { Loading @@ -151,8 +152,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -171,8 +171,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldNotHeadsUp( Loading @@ -191,8 +190,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -209,8 +207,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -227,8 +224,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -245,8 +241,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -263,8 +258,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -281,8 +275,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -300,8 +293,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading @@ -318,8 +310,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { assertFsiNotSuppressed() } Loading @@ -330,8 +321,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro avalancheProvider.startTime = whenAgo(10) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading Loading @@ -359,8 +349,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro setAllowedEmergencyPkg(true) withFilter( AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager, uiEventLogger, context, notificationManager) getAvalancheSuppressor() ) { ensurePeekState() assertShouldHeadsUp( Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt +1 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() { protected val settingsInteractor: NotificationSettingsInteractor = mock() protected val packageManager: PackageManager = mock() protected val notificationManager: NotificationManager = mock() protected val logger: VisualInterruptionDecisionLogger = mock() protected abstract val provider: VisualInterruptionDecisionProvider private val neverSuppresses = object : NotificationInterruptSuppressor {} Loading