summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt32
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt58
2 files changed, 88 insertions, 2 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 a6ca3ab8bce3..17f401ac0dde 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
@@ -19,6 +19,9 @@ package com.android.systemui.statusbar.notification.interruption
import android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST
import android.app.Notification
import android.app.Notification.BubbleMetadata
+import android.app.Notification.CATEGORY_ALARM
+import android.app.Notification.CATEGORY_CAR_EMERGENCY
+import android.app.Notification.CATEGORY_CAR_WARNING
import android.app.Notification.CATEGORY_EVENT
import android.app.Notification.CATEGORY_REMINDER
import android.app.Notification.VISIBILITY_PRIVATE
@@ -42,6 +45,7 @@ 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
@@ -307,6 +311,9 @@ class AvalancheSuppressor(
ALLOW_CALLSTYLE,
ALLOW_CATEGORY_REMINDER,
ALLOW_CATEGORY_EVENT,
+ ALLOW_CATEGORY_ALARM,
+ ALLOW_CATEGORY_CAR_EMERGENCY,
+ ALLOW_CATEGORY_CAR_WARNING,
ALLOW_FSI_WITH_PERMISSION_ON,
ALLOW_COLORIZED,
ALLOW_EMERGENCY,
@@ -333,8 +340,13 @@ class AvalancheSuppressor(
@UiEvent(doc = "HUN allowed during avalanche because it is colorized.")
AVALANCHE_SUPPRESSOR_HUN_ALLOWED_COLORIZED(1832),
@UiEvent(doc = "HUN allowed during avalanche because it is an emergency notification.")
- AVALANCHE_SUPPRESSOR_HUN_ALLOWED_EMERGENCY(1833);
-
+ AVALANCHE_SUPPRESSOR_HUN_ALLOWED_EMERGENCY(1833),
+ @UiEvent(doc = "HUN allowed during avalanche because it is an alarm.")
+ AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_ALARM(1867),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a car emergency.")
+ AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_CAR_EMERGENCY(1868),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a car warning")
+ AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_CAR_WARNING(1869);
override fun getId(): Int {
return id
}
@@ -423,6 +435,22 @@ class AvalancheSuppressor(
return State.ALLOW_CATEGORY_REMINDER
}
+ if (entry.sbn.notification.category == CATEGORY_ALARM) {
+ uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_ALARM)
+ return State.ALLOW_CATEGORY_ALARM
+ }
+
+ if (entry.sbn.notification.category == CATEGORY_CAR_EMERGENCY) {
+ uiEventLogger.log(
+ AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_CAR_EMERGENCY)
+ return State.ALLOW_CATEGORY_CAR_EMERGENCY
+ }
+
+ if (entry.sbn.notification.category == CATEGORY_CAR_WARNING) {
+ uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_CAR_WARNING)
+ return State.ALLOW_CATEGORY_CAR_WARNING
+ }
+
if (entry.sbn.notification.category == CATEGORY_EVENT) {
uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_EVENT)
return State.ALLOW_CATEGORY_EVENT
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 f9509d2d394d..d1b1f466ef7a 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
@@ -17,6 +17,9 @@
package com.android.systemui.statusbar.notification.interruption
import android.Manifest.permission
+import android.app.Notification.CATEGORY_ALARM
+import android.app.Notification.CATEGORY_CAR_EMERGENCY
+import android.app.Notification.CATEGORY_CAR_WARNING
import android.app.Notification.CATEGORY_EVENT
import android.app.Notification.CATEGORY_REMINDER
import android.app.NotificationManager
@@ -256,6 +259,61 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
}
@Test
+ fun testAvalancheFilter_duringAvalanche_allowCategoryAlarm() {
+ avalancheProvider.startTime = whenAgo(10)
+
+ withFilter(
+ AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
+ uiEventLogger, context, notificationManager)
+ ) {
+ ensurePeekState()
+ assertShouldHeadsUp(
+ buildEntry {
+ importance = NotificationManager.IMPORTANCE_HIGH
+ category = CATEGORY_ALARM
+ }
+ )
+ }
+ }
+
+ @Test
+ fun testAvalancheFilter_duringAvalanche_allowCategoryCarEmergency() {
+ avalancheProvider.startTime = whenAgo(10)
+
+ withFilter(
+ AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
+ uiEventLogger, context, notificationManager)
+ ) {
+ ensurePeekState()
+ assertShouldHeadsUp(
+ buildEntry {
+ importance = NotificationManager.IMPORTANCE_HIGH
+ category = CATEGORY_CAR_EMERGENCY
+
+ }
+ )
+ }
+ }
+
+ @Test
+ fun testAvalancheFilter_duringAvalanche_allowCategoryCarWarning() {
+ avalancheProvider.startTime = whenAgo(10)
+
+ withFilter(
+ AvalancheSuppressor(avalancheProvider, systemClock, settingsInteractor, packageManager,
+ uiEventLogger, context, notificationManager)
+ ) {
+ ensurePeekState()
+ assertShouldHeadsUp(
+ buildEntry {
+ importance = NotificationManager.IMPORTANCE_HIGH
+ category = CATEGORY_CAR_WARNING
+ }
+ )
+ }
+ }
+
+ @Test
fun testAvalancheFilter_duringAvalanche_allowFsi() {
avalancheProvider.startTime = whenAgo(10)