Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +8 −2 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.Vibrator; import android.provider.Settings; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import android.service.vr.IVrManager; Loading Loading @@ -562,7 +563,7 @@ public class StatusBar extends SystemUI implements DemoMode, }}; private boolean mWaitingForKeyguardExit; private boolean mDozing; protected boolean mDozing; private boolean mDozingRequested; protected boolean mScrimSrcModeEnabled; Loading Loading @@ -7233,7 +7234,12 @@ public class StatusBar extends SystemUI implements DemoMode, return false; } if (mNotificationData.shouldSuppressScreenOn(sbn.getKey())) { if (!isDozing() && mNotificationData.shouldSuppressScreenOn(sbn.getKey())) { if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey()); return false; } if (isDozing() && mNotificationData.shouldSuppressScreenOff(sbn.getKey())) { if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey()); return false; } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +77 −0 Original line number Diff line number Diff line Loading @@ -333,6 +333,83 @@ public class StatusBarTest extends SysuiTestCase { assertFalse(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testShouldPeek_suppressedScreenOn_dozing() { when(mPowerManager.isScreenOn()).thenReturn(true); when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); when(mNotificationData.shouldFilterOut(any())).thenReturn(false); when(mSystemServicesProxy.isDreaming()).thenReturn(false); when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); mStatusBar.mDozing = true; when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(true); when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(false); Notification n = new Notification.Builder(getContext(), "a").build(); StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, UserHandle.of(0), null, 0); NotificationData.Entry entry = new NotificationData.Entry(sbn); assertTrue(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testShouldPeek_suppressedScreenOn_noDoze() { when(mPowerManager.isScreenOn()).thenReturn(true); when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); when(mNotificationData.shouldFilterOut(any())).thenReturn(false); when(mSystemServicesProxy.isDreaming()).thenReturn(false); when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); mStatusBar.mDozing = false; when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(true); when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(false); Notification n = new Notification.Builder(getContext(), "a").build(); StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, UserHandle.of(0), null, 0); NotificationData.Entry entry = new NotificationData.Entry(sbn); assertFalse(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testShouldPeek_suppressedScreenOff_dozing() { when(mPowerManager.isScreenOn()).thenReturn(true); when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); when(mNotificationData.shouldFilterOut(any())).thenReturn(false); when(mSystemServicesProxy.isDreaming()).thenReturn(false); when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); mStatusBar.mDozing = true; when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(false); when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(true); Notification n = new Notification.Builder(getContext(), "a").build(); StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, UserHandle.of(0), null, 0); NotificationData.Entry entry = new NotificationData.Entry(sbn); assertFalse(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testShouldPeek_suppressedScreenOff_noDoze() { when(mPowerManager.isScreenOn()).thenReturn(true); when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); when(mNotificationData.shouldFilterOut(any())).thenReturn(false); when(mSystemServicesProxy.isDreaming()).thenReturn(false); when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); mStatusBar.mDozing = false; when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(false); when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(true); Notification n = new Notification.Builder(getContext(), "a").build(); StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, UserHandle.of(0), null, 0); NotificationData.Entry entry = new NotificationData.Entry(sbn); assertTrue(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testLogHidden() { try { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +8 −2 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.Vibrator; import android.provider.Settings; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import android.service.vr.IVrManager; Loading Loading @@ -562,7 +563,7 @@ public class StatusBar extends SystemUI implements DemoMode, }}; private boolean mWaitingForKeyguardExit; private boolean mDozing; protected boolean mDozing; private boolean mDozingRequested; protected boolean mScrimSrcModeEnabled; Loading Loading @@ -7233,7 +7234,12 @@ public class StatusBar extends SystemUI implements DemoMode, return false; } if (mNotificationData.shouldSuppressScreenOn(sbn.getKey())) { if (!isDozing() && mNotificationData.shouldSuppressScreenOn(sbn.getKey())) { if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey()); return false; } if (isDozing() && mNotificationData.shouldSuppressScreenOff(sbn.getKey())) { if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey()); return false; } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +77 −0 Original line number Diff line number Diff line Loading @@ -333,6 +333,83 @@ public class StatusBarTest extends SysuiTestCase { assertFalse(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testShouldPeek_suppressedScreenOn_dozing() { when(mPowerManager.isScreenOn()).thenReturn(true); when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); when(mNotificationData.shouldFilterOut(any())).thenReturn(false); when(mSystemServicesProxy.isDreaming()).thenReturn(false); when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); mStatusBar.mDozing = true; when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(true); when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(false); Notification n = new Notification.Builder(getContext(), "a").build(); StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, UserHandle.of(0), null, 0); NotificationData.Entry entry = new NotificationData.Entry(sbn); assertTrue(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testShouldPeek_suppressedScreenOn_noDoze() { when(mPowerManager.isScreenOn()).thenReturn(true); when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); when(mNotificationData.shouldFilterOut(any())).thenReturn(false); when(mSystemServicesProxy.isDreaming()).thenReturn(false); when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); mStatusBar.mDozing = false; when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(true); when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(false); Notification n = new Notification.Builder(getContext(), "a").build(); StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, UserHandle.of(0), null, 0); NotificationData.Entry entry = new NotificationData.Entry(sbn); assertFalse(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testShouldPeek_suppressedScreenOff_dozing() { when(mPowerManager.isScreenOn()).thenReturn(true); when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); when(mNotificationData.shouldFilterOut(any())).thenReturn(false); when(mSystemServicesProxy.isDreaming()).thenReturn(false); when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); mStatusBar.mDozing = true; when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(false); when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(true); Notification n = new Notification.Builder(getContext(), "a").build(); StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, UserHandle.of(0), null, 0); NotificationData.Entry entry = new NotificationData.Entry(sbn); assertFalse(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testShouldPeek_suppressedScreenOff_noDoze() { when(mPowerManager.isScreenOn()).thenReturn(true); when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); when(mNotificationData.shouldFilterOut(any())).thenReturn(false); when(mSystemServicesProxy.isDreaming()).thenReturn(false); when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); mStatusBar.mDozing = false; when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(false); when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(true); Notification n = new Notification.Builder(getContext(), "a").build(); StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, UserHandle.of(0), null, 0); NotificationData.Entry entry = new NotificationData.Entry(sbn); assertTrue(mStatusBar.shouldPeek(entry, sbn)); } @Test public void testLogHidden() { try { Loading