Don't launch FSI from suspended apps
Bug: 271821444 Test: atest NotificationInterruptStateProviderImplTest Test: manual with incoming Telegram call and Foccus mode Change-Id: Ib760510ba6a52c018af6f7c0e036d031fb1fb0cb
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user