Loading services/core/java/com/android/server/power/PowerManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -2953,7 +2953,8 @@ public final class PowerManagerService extends SystemService mHandler.removeMessages(MSG_ATTENTIVE_TIMEOUT); if (isBeingKeptFromInattentiveSleepLocked()) { if (getGlobalWakefulnessLocked() == WAKEFULNESS_ASLEEP || isBeingKeptFromInattentiveSleepLocked()) { return; } Loading Loading @@ -2985,7 +2986,7 @@ public final class PowerManagerService extends SystemService return false; } if (getGlobalWakefulnessLocked() != WAKEFULNESS_AWAKE) { if (getGlobalWakefulnessLocked() == WAKEFULNESS_ASLEEP) { mInattentiveSleepWarningOverlayController.dismiss(false); return true; } else if (attentiveTimeout < 0 || isBeingKeptFromInattentiveSleepLocked() Loading services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -991,6 +991,40 @@ public class PowerManagerServiceTest { verify(mInattentiveSleepWarningControllerMock, atLeastOnce()).dismiss(false); } @Test public void testInattentiveSleep_warningStaysWhenDreaming() { setMinimumScreenOffTimeoutConfig(5); setAttentiveWarningDuration(70); setAttentiveTimeout(100); createService(); startSystem(); advanceTime(50); verify(mInattentiveSleepWarningControllerMock, atLeastOnce()).show(); when(mInattentiveSleepWarningControllerMock.isShown()).thenReturn(true); forceDream(); when(mDreamManagerInternalMock.isDreaming()).thenReturn(true); advanceTime(10); assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_DREAMING); verify(mInattentiveSleepWarningControllerMock, never()).dismiss(anyBoolean()); } @Test public void testInattentiveSleep_warningNotShownWhenSleeping() { setMinimumScreenOffTimeoutConfig(5); setAttentiveWarningDuration(70); setAttentiveTimeout(100); createService(); startSystem(); advanceTime(10); forceSleep(); advanceTime(50); verify(mInattentiveSleepWarningControllerMock, never()).show(); } @Test public void testInattentiveSleep_noWarningShownIfInattentiveSleepDisabled() { setAttentiveTimeout(-1); Loading Loading
services/core/java/com/android/server/power/PowerManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -2953,7 +2953,8 @@ public final class PowerManagerService extends SystemService mHandler.removeMessages(MSG_ATTENTIVE_TIMEOUT); if (isBeingKeptFromInattentiveSleepLocked()) { if (getGlobalWakefulnessLocked() == WAKEFULNESS_ASLEEP || isBeingKeptFromInattentiveSleepLocked()) { return; } Loading Loading @@ -2985,7 +2986,7 @@ public final class PowerManagerService extends SystemService return false; } if (getGlobalWakefulnessLocked() != WAKEFULNESS_AWAKE) { if (getGlobalWakefulnessLocked() == WAKEFULNESS_ASLEEP) { mInattentiveSleepWarningOverlayController.dismiss(false); return true; } else if (attentiveTimeout < 0 || isBeingKeptFromInattentiveSleepLocked() Loading
services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -991,6 +991,40 @@ public class PowerManagerServiceTest { verify(mInattentiveSleepWarningControllerMock, atLeastOnce()).dismiss(false); } @Test public void testInattentiveSleep_warningStaysWhenDreaming() { setMinimumScreenOffTimeoutConfig(5); setAttentiveWarningDuration(70); setAttentiveTimeout(100); createService(); startSystem(); advanceTime(50); verify(mInattentiveSleepWarningControllerMock, atLeastOnce()).show(); when(mInattentiveSleepWarningControllerMock.isShown()).thenReturn(true); forceDream(); when(mDreamManagerInternalMock.isDreaming()).thenReturn(true); advanceTime(10); assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_DREAMING); verify(mInattentiveSleepWarningControllerMock, never()).dismiss(anyBoolean()); } @Test public void testInattentiveSleep_warningNotShownWhenSleeping() { setMinimumScreenOffTimeoutConfig(5); setAttentiveWarningDuration(70); setAttentiveTimeout(100); createService(); startSystem(); advanceTime(10); forceSleep(); advanceTime(50); verify(mInattentiveSleepWarningControllerMock, never()).show(); } @Test public void testInattentiveSleep_noWarningShownIfInattentiveSleepDisabled() { setAttentiveTimeout(-1); Loading