2424import static android .app .NotificationManager .Policy .SUPPRESSED_EFFECT_PEEK ;
2525
2626import static com .android .systemui .statusbar .NotificationEntryHelper .modifyRanking ;
27+ import static com .android .systemui .statusbar .StatusBarState .KEYGUARD ;
2728import static com .android .systemui .statusbar .StatusBarState .SHADE ;
2829
2930import static com .google .common .truth .Truth .assertThat ;
@@ -84,6 +85,8 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase {
8485 BatteryController mBatteryController ;
8586 @ Mock
8687 Handler mMockHandler ;
88+ @ Mock
89+ PendingIntent mPendingIntent ;
8790
8891 private NotificationInterruptStateProviderImpl mNotifInterruptionStateProvider ;
8992
@@ -399,6 +402,97 @@ public void testShouldNotHeadsUp_justLaunchedFullscreen() {
399402 assertThat (mNotifInterruptionStateProvider .shouldHeadsUp (entry )).isFalse ();
400403 }
401404
405+ @ Test
406+ public void testShouldNotFullScreen_notPendingIntent () throws RemoteException {
407+ NotificationEntry entry = createNotification (IMPORTANCE_HIGH );
408+ when (mPowerManager .isInteractive ()).thenReturn (true );
409+ when (mDreamManager .isDreaming ()).thenReturn (false );
410+ when (mStatusBarStateController .getState ()).thenReturn (SHADE );
411+
412+ assertThat (mNotifInterruptionStateProvider .shouldLaunchFullScreenIntentWhenAdded (entry ))
413+ .isFalse ();
414+ }
415+
416+ @ Test
417+ public void testShouldNotFullScreen_notHighImportance () throws RemoteException {
418+ NotificationEntry entry = createFsiNotification (IMPORTANCE_DEFAULT , /* silenced */ false );
419+ when (mPowerManager .isInteractive ()).thenReturn (true );
420+ when (mDreamManager .isDreaming ()).thenReturn (false );
421+ when (mStatusBarStateController .getState ()).thenReturn (SHADE );
422+
423+ assertThat (mNotifInterruptionStateProvider .shouldLaunchFullScreenIntentWhenAdded (entry ))
424+ .isFalse ();
425+ }
426+
427+ @ Test
428+ public void testShouldNotFullScreen_isGroupAlertSilenced () throws RemoteException {
429+ NotificationEntry entry = createFsiNotification (IMPORTANCE_HIGH , /* silenced */ true );
430+ when (mPowerManager .isInteractive ()).thenReturn (false );
431+ when (mDreamManager .isDreaming ()).thenReturn (true );
432+ when (mStatusBarStateController .getState ()).thenReturn (KEYGUARD );
433+
434+ assertThat (mNotifInterruptionStateProvider .shouldLaunchFullScreenIntentWhenAdded (entry ))
435+ .isFalse ();
436+ }
437+
438+ @ Test
439+ public void testShouldFullScreen_notInteractive () throws RemoteException {
440+ NotificationEntry entry = createFsiNotification (IMPORTANCE_HIGH , /* silenced */ false );
441+ when (mPowerManager .isInteractive ()).thenReturn (false );
442+ when (mDreamManager .isDreaming ()).thenReturn (false );
443+ when (mStatusBarStateController .getState ()).thenReturn (SHADE );
444+
445+ assertThat (mNotifInterruptionStateProvider .shouldLaunchFullScreenIntentWhenAdded (entry ))
446+ .isTrue ();
447+ }
448+
449+ @ Test
450+ public void testShouldFullScreen_isDreaming () throws RemoteException {
451+ NotificationEntry entry = createFsiNotification (IMPORTANCE_HIGH , /* silenced */ false );
452+ when (mPowerManager .isInteractive ()).thenReturn (true );
453+ when (mDreamManager .isDreaming ()).thenReturn (true );
454+ when (mStatusBarStateController .getState ()).thenReturn (SHADE );
455+
456+ assertThat (mNotifInterruptionStateProvider .shouldLaunchFullScreenIntentWhenAdded (entry ))
457+ .isTrue ();
458+ }
459+
460+ @ Test
461+ public void testShouldFullScreen_onKeyguard () throws RemoteException {
462+ NotificationEntry entry = createFsiNotification (IMPORTANCE_HIGH , /* silenced */ false );
463+ when (mPowerManager .isInteractive ()).thenReturn (true );
464+ when (mDreamManager .isDreaming ()).thenReturn (false );
465+ when (mStatusBarStateController .getState ()).thenReturn (KEYGUARD );
466+
467+ assertThat (mNotifInterruptionStateProvider .shouldLaunchFullScreenIntentWhenAdded (entry ))
468+ .isTrue ();
469+ }
470+
471+ @ Test
472+ public void testShouldNotFullScreen_willHun () throws RemoteException {
473+ NotificationEntry entry = createFsiNotification (IMPORTANCE_HIGH , /* silenced */ false );
474+ when (mPowerManager .isInteractive ()).thenReturn (true );
475+ when (mPowerManager .isScreenOn ()).thenReturn (true );
476+ when (mDreamManager .isDreaming ()).thenReturn (false );
477+ when (mStatusBarStateController .getState ()).thenReturn (SHADE );
478+
479+ assertThat (mNotifInterruptionStateProvider .shouldLaunchFullScreenIntentWhenAdded (entry ))
480+ .isFalse ();
481+ }
482+
483+ @ Test
484+ public void testShouldFullScreen_packageSnoozed () throws RemoteException {
485+ NotificationEntry entry = createFsiNotification (IMPORTANCE_HIGH , /* silenced */ false );
486+ when (mPowerManager .isInteractive ()).thenReturn (true );
487+ when (mPowerManager .isScreenOn ()).thenReturn (true );
488+ when (mDreamManager .isDreaming ()).thenReturn (false );
489+ when (mStatusBarStateController .getState ()).thenReturn (SHADE );
490+ when (mHeadsUpManager .isSnoozed ("a" )).thenReturn (true );
491+
492+ assertThat (mNotifInterruptionStateProvider .shouldLaunchFullScreenIntentWhenAdded (entry ))
493+ .isTrue ();
494+ }
495+
402496 /**
403497 * Bubbles can happen.
404498 */
@@ -502,6 +596,10 @@ private NotificationEntry createNotification(int importance) {
502596 .setContentText ("content text" )
503597 .build ();
504598
599+ return createNotification (importance , n );
600+ }
601+
602+ private NotificationEntry createNotification (int importance , Notification n ) {
505603 return new NotificationEntryBuilder ()
506604 .setPkg ("a" )
507605 .setOpPkg ("a" )
@@ -511,6 +609,20 @@ private NotificationEntry createNotification(int importance) {
511609 .build ();
512610 }
513611
612+ private NotificationEntry createFsiNotification (int importance , boolean silent ) {
613+ Notification n = new Notification .Builder (getContext (), "a" )
614+ .setContentTitle ("title" )
615+ .setContentText ("content text" )
616+ .setFullScreenIntent (mPendingIntent , true )
617+ .setGroup ("fsi" )
618+ .setGroupAlertBehavior (silent
619+ ? Notification .GROUP_ALERT_SUMMARY
620+ : Notification .GROUP_ALERT_ALL )
621+ .build ();
622+
623+ return createNotification (importance , n );
624+ }
625+
514626 private final NotificationInterruptSuppressor
515627 mSuppressAwakeHeadsUp =
516628 new NotificationInterruptSuppressor () {
0 commit comments