summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author lyn <lynhan@google.com> 2024-08-21 21:10:23 +0000
committer Lyn Han <lynhan@google.com> 2024-08-22 17:20:52 +0000
commit445ee4d6bd1d8bb4a12c85640163b0cbd44881ec (patch)
tree3bb2b15a874e0756acf0fba9ae3d835b0f1a78d7
parent34132fcfc6886af3c9130712a41f1671ec9c823b (diff)
Log reason why HUN was allowed during avalanche
Fixes: 361385839 Bug: 356768397 Test: adb shell cmd statusbar echo -b NotifInterruptLog:verbose adb reboot adb logcat | grep VisualInterruptionDecisionProvider Flag: com.android.systemui.notification_avalanche_suppression Change-Id: Ifd7a3253d35c5dee7b41ba1561f768c013cc83ed
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt53
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt1
5 files changed, 38 insertions, 35 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
index 17f401ac0dde..0efd5f15cb09 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
@@ -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
@@ -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),
@@ -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()) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt
index c204ea9097de..b83259dce298 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt
@@ -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"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt
index 8e8d9b69ac58..2f8711a586ef 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt
@@ -194,7 +194,8 @@ constructor(
packageManager,
uiEventLogger,
context,
- notificationManager
+ notificationManager,
+ logger
)
)
avalancheProvider.register()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt
index d1b1f466ef7a..ed99705b194e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt
@@ -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) {
@@ -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) {
@@ -151,8 +152,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -171,8 +171,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldNotHeadsUp(
@@ -191,8 +190,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -209,8 +207,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -227,8 +224,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -245,8 +241,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -263,8 +258,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -281,8 +275,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -300,8 +293,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -318,8 +310,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
assertFsiNotSuppressed()
}
@@ -330,8 +321,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
avalancheProvider.startTime = whenAgo(10)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
@@ -359,8 +349,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
setAllowedEmergencyPkg(true)
withFilter(
- AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager)
+ getAvalancheSuppressor()
) {
ensurePeekState()
assertShouldHeadsUp(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt
index 9d3d9c156238..284efc71a96d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderTestBase.kt
@@ -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 {}