From 6fb979f488cc33df9c7756d3b443ccadc52e0e49 Mon Sep 17 00:00:00 2001 From: Julia Tuttle Date: Tue, 18 Apr 2023 16:04:23 -0400 Subject: [PATCH] Add logReason to visual interruption decisions This will let callers (like HeadsUpCoordinator) include the reason for decisions in their logs while maintaining the simple two- or three-state decision output. Bug: 261728888 Test: builds Change-Id: Ic85985a893b9e326a6178342546077d7c0daaf71 --- .../interruption/NotificationInterruptStateProviderWrapper.kt | 3 +++ .../interruption/VisualInterruptionDecisionProvider.kt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderWrapper.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderWrapper.kt index f2216fce6fef2..ebba4b1aa2658 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderWrapper.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderWrapper.kt @@ -36,6 +36,8 @@ class NotificationInterruptStateProviderWrapper( SHOULD_INTERRUPT(shouldInterrupt = true), SHOULD_NOT_INTERRUPT(shouldInterrupt = false); + override val logReason = "unknown" + companion object { fun of(booleanDecision: Boolean) = if (booleanDecision) SHOULD_INTERRUPT else SHOULD_NOT_INTERRUPT @@ -49,6 +51,7 @@ class NotificationInterruptStateProviderWrapper( ) : FullScreenIntentDecision { override val shouldInterrupt = originalDecision.shouldLaunch override val wouldInterruptWithoutDnd = originalDecision == NO_FSI_SUPPRESSED_ONLY_BY_DND + override val logReason = originalDecision.name } override fun addSuppressor(suppressor: NotificationInterruptSuppressor) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProvider.kt index c0f4fcda56bb4..8024016fd3fc8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProvider.kt @@ -32,9 +32,12 @@ interface VisualInterruptionDecisionProvider { * full-screen intent decisions. * * @property[shouldInterrupt] whether a visual interruption should be triggered + * @property[logReason] a log-friendly string explaining the reason for the decision; should be + * used *only* for logging, not decision-making */ interface Decision { val shouldInterrupt: Boolean + val logReason: String } /**