Merge "Fix inattentive sleep failing to go to sleep while dreaming" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
641fbeb11b
@@ -2718,8 +2718,8 @@ public final class PowerManagerService extends SystemService
|
|||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private void updateUserActivitySummaryLocked(long now, int dirty) {
|
private void updateUserActivitySummaryLocked(long now, int dirty) {
|
||||||
// Update the status of the user activity timeout timer.
|
// Update the status of the user activity timeout timer.
|
||||||
if ((dirty & (DIRTY_DISPLAY_GROUP_WAKEFULNESS | DIRTY_WAKE_LOCKS
|
if ((dirty & (DIRTY_DISPLAY_GROUP_WAKEFULNESS | DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY
|
||||||
| DIRTY_USER_ACTIVITY | DIRTY_WAKEFULNESS | DIRTY_SETTINGS)) == 0) {
|
| DIRTY_WAKEFULNESS | DIRTY_SETTINGS | DIRTY_ATTENTIVE)) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mHandler.removeMessages(MSG_USER_ACTIVITY_TIMEOUT);
|
mHandler.removeMessages(MSG_USER_ACTIVITY_TIMEOUT);
|
||||||
@@ -2803,6 +2803,11 @@ public final class PowerManagerService extends SystemService
|
|||||||
screenDimDuration);
|
screenDimDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isAttentiveTimeoutExpired(powerGroup, now)) {
|
||||||
|
groupUserActivitySummary = 0;
|
||||||
|
groupNextTimeout = -1;
|
||||||
|
}
|
||||||
|
|
||||||
hasUserActivitySummary |= groupUserActivitySummary != 0;
|
hasUserActivitySummary |= groupUserActivitySummary != 0;
|
||||||
|
|
||||||
if (nextTimeout == -1) {
|
if (nextTimeout == -1) {
|
||||||
|
|||||||
@@ -1086,6 +1086,23 @@ public class PowerManagerServiceTest {
|
|||||||
assertThat(mService.getGlobalWakefulnessLocked()).isNotEqualTo(WAKEFULNESS_ASLEEP);
|
assertThat(mService.getGlobalWakefulnessLocked()).isNotEqualTo(WAKEFULNESS_ASLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("GuardedBy")
|
||||||
|
@Test
|
||||||
|
public void testInattentiveSleep_goesToSleepFromDream() {
|
||||||
|
setAttentiveTimeout(20000);
|
||||||
|
createService();
|
||||||
|
startSystem();
|
||||||
|
setPluggedIn(true);
|
||||||
|
forceAwake();
|
||||||
|
forceDream();
|
||||||
|
when(mDreamManagerInternalMock.isDreaming()).thenReturn(true);
|
||||||
|
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_DREAMING);
|
||||||
|
|
||||||
|
advanceTime(20500);
|
||||||
|
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_ASLEEP);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWakeLock_affectsProperDisplayGroup() {
|
public void testWakeLock_affectsProperDisplayGroup() {
|
||||||
final int nonDefaultDisplayGroupId = Display.DEFAULT_DISPLAY_GROUP + 1;
|
final int nonDefaultDisplayGroupId = Display.DEFAULT_DISPLAY_GROUP + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user