From 8439be31ae2a58a024bd52d9d58426172f7e5aa8 Mon Sep 17 00:00:00 2001 From: Pavel Grafov Date: Fri, 17 Mar 2023 16:34:59 +0000 Subject: [PATCH] Don't launch FSI from suspended apps Bug: 271821444 Test: atest NotificationInterruptStateProviderImplTest Test: manual with incoming Telegram call and Foccus mode Change-Id: Ib760510ba6a52c018af6f7c0e036d031fb1fb0cb --- .../NotificationInterruptStateProvider.java | 6 +++++- .../NotificationInterruptStateProviderImpl.java | 7 ++++++- ...ificationInterruptStateProviderImplTest.java | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProvider.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProvider.java index 5ba8801e0f638..bfb6416ac78a3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProvider.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProvider.java @@ -94,7 +94,11 @@ public interface NotificationInterruptStateProvider { /** * No conditions blocking FSI launch. */ - FSI_EXPECTED_NOT_TO_HUN(true); + FSI_EXPECTED_NOT_TO_HUN(true), + /** + * The notification is coming from a suspended packages, so FSI is suppressed. + */ + NO_FSI_SUSPENDED(false); public final boolean shouldLaunch; 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 6f4eed3c16129..4aaa7ca61d340 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 @@ -28,7 +28,6 @@ import android.database.ContentObserver; import android.hardware.display.AmbientDisplayConfiguration; import android.os.Handler; import android.os.PowerManager; -import android.os.SystemProperties; import android.provider.Settings; import android.service.notification.StatusBarNotification; @@ -274,6 +273,12 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter suppressedByDND); } + // Notification is coming from a suspended package, block FSI + if (entry.getRanking().isSuspended()) { + return getDecisionGivenSuppression(FullScreenIntentDecision.NO_FSI_SUSPENDED, + suppressedByDND); + } + // If the screen is off, then launch the FullScreenIntent if (!mPowerManager.isInteractive()) { return getDecisionGivenSuppression(FullScreenIntentDecision.FSI_DEVICE_NOT_INTERACTIVE, 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 653b0c7072407..09b00e246eec0 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 @@ -857,6 +857,23 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase { verify(mLogger, never()).logFullscreen(any(), any()); } + @Test + public void testShouldNotScreen_appSuspended() throws RemoteException { + NotificationEntry entry = createFsiNotification(IMPORTANCE_HIGH, /* silenced */ false); + when(mPowerManager.isInteractive()).thenReturn(false); + when(mStatusBarStateController.isDreaming()).thenReturn(false); + when(mStatusBarStateController.getState()).thenReturn(SHADE); + modifyRanking(entry).setSuspended(true).build(); + + assertThat(mNotifInterruptionStateProvider.getFullScreenIntentDecision(entry)) + .isEqualTo(FullScreenIntentDecision.NO_FSI_SUSPENDED); + assertThat(mNotifInterruptionStateProvider.shouldLaunchFullScreenIntentWhenAdded(entry)) + .isFalse(); + verify(mLogger).logNoFullscreen(entry, "NO_FSI_SUSPENDED"); + verify(mLogger, never()).logNoFullscreenWarning(any(), any()); + verify(mLogger, never()).logFullscreen(any(), any()); + } + @Test public void logFullScreenIntentDecision_shouldAlmostAlwaysLogOneTime() { NotificationEntry entry = createFsiNotification(IMPORTANCE_HIGH, /* silenced */ false);