Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edecae25 authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge "Allow alarm, car emergency/warning HUNs during suppression" into main

parents 2e7481d1 ff7b667b
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -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
+58 −0
Original line number Diff line number Diff line
@@ -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
@@ -255,6 +258,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)