From 6591b87cce80102ba4bc77ea425c8b38ea12338e Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 24 Mar 2023 11:29:13 -0400 Subject: [PATCH] Do not wake AOD for hidden notifications Fixes: 161530512 Test: NotificationInterruptStateProviderImplTest Test: Hide notificationchannel from LS. Post notification on delay; validate AOD does not wake up/flicker Test: Unhide notificationchannel. Post HUN notification on delay; validate notificatoin HUNs on AOD Change-Id: I28fbbbff9a2540fb1e88d91555c032c7ac2aa981 --- .../NotificationInterruptLogger.kt | 8 ++++++++ ...NotificationInterruptStateProviderImpl.java | 6 ++++++ ...ficationInterruptStateProviderImplTest.java | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptLogger.kt index 27fe747e6be85..a352f23bfc1c9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptLogger.kt @@ -234,6 +234,14 @@ class NotificationInterruptLogger @Inject constructor( }) } + fun logNoPulsingNotificationHidden(entry: NotificationEntry) { + buffer.log(TAG, DEBUG, { + str1 = entry.logKey + }, { + "No pulsing: notification hidden on lock screen: $str1" + }) + } + fun logNoPulsingNotImportant(entry: NotificationEntry) { buffer.log(TAG, DEBUG, { str1 = entry.logKey diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java index 4aaa7ca61d340..7c50b48f9b4ab 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java @@ -482,6 +482,12 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter return false; } + if (entry.getRanking().getLockscreenVisibilityOverride() + == Notification.VISIBILITY_PRIVATE) { + if (log) mLogger.logNoPulsingNotificationHidden(entry); + return false; + } + if (entry.getImportance() < NotificationManager.IMPORTANCE_DEFAULT) { if (log) mLogger.logNoPulsingNotImportant(entry); return false; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImplTest.java index 09b00e246eec0..b37b9c631341d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImplTest.java @@ -19,12 +19,14 @@ package com.android.systemui.statusbar.notification.interruption; import static android.app.Notification.FLAG_BUBBLE; import static android.app.Notification.FLAG_FOREGROUND_SERVICE; import static android.app.Notification.GROUP_ALERT_SUMMARY; +import static android.app.Notification.VISIBILITY_PRIVATE; import static android.app.NotificationManager.IMPORTANCE_DEFAULT; import static android.app.NotificationManager.IMPORTANCE_HIGH; import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; +import static android.app.NotificationManager.VISIBILITY_NO_OVERRIDE; import static com.android.systemui.statusbar.NotificationEntryHelper.modifyRanking; import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; @@ -222,9 +224,25 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase { ensureStateForHeadsUpWhenDozing(); NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT); + modifyRanking(entry) + .setVisibilityOverride(VISIBILITY_NO_OVERRIDE) + .build(); + assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isTrue(); } + @Test + public void testShouldHeadsUpWhenDozing_hiddenOnLockscreen() { + ensureStateForHeadsUpWhenDozing(); + + NotificationEntry entry = createNotification(IMPORTANCE_DEFAULT); + modifyRanking(entry) + .setVisibilityOverride(VISIBILITY_PRIVATE) + .build(); + + assertThat(mNotifInterruptionStateProvider.shouldHeadsUp(entry)).isFalse(); + } + @Test public void testShouldNotHeadsUpWhenDozing_pulseDisabled() { // GIVEN state for "heads up when dozing" is true