Merge "Don't launch FSI from suspended apps" into udc-dev

This commit is contained in:
Pavel Grafov
2023-03-20 12:41:05 +00:00
committed by Android (Google) Code Review
3 changed files with 28 additions and 2 deletions

View File

@@ -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;

View File

@@ -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,

View File

@@ -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);