Merge "Set DreamsActivateOnSleepSetting and handle Sandman in tests" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7bcaeee92c
@@ -2029,7 +2029,7 @@ public final class PowerManagerService extends SystemService
|
|||||||
private boolean dozePowerGroupLocked(final PowerGroup powerGroup, long eventTime,
|
private boolean dozePowerGroupLocked(final PowerGroup powerGroup, long eventTime,
|
||||||
int reason, int uid) {
|
int reason, int uid) {
|
||||||
if (DEBUG_SPEW) {
|
if (DEBUG_SPEW) {
|
||||||
Slog.d(TAG, "sleepDisplayGroupNoUpdateLocked: eventTime=" + eventTime
|
Slog.d(TAG, "dozePowerGroup: eventTime=" + eventTime
|
||||||
+ ", groupId=" + powerGroup.getGroupId() + ", reason=" + reason
|
+ ", groupId=" + powerGroup.getGroupId() + ", reason=" + reason
|
||||||
+ ", uid=" + uid);
|
+ ", uid=" + uid);
|
||||||
}
|
}
|
||||||
@@ -3158,7 +3158,7 @@ public final class PowerManagerService extends SystemService
|
|||||||
Message msg = mHandler.obtainMessage(MSG_SANDMAN);
|
Message msg = mHandler.obtainMessage(MSG_SANDMAN);
|
||||||
msg.arg1 = powerGroup.getGroupId();
|
msg.arg1 = powerGroup.getGroupId();
|
||||||
msg.setAsynchronous(true);
|
msg.setAsynchronous(true);
|
||||||
mHandler.sendMessage(msg);
|
mHandler.sendMessageAtTime(msg, mClock.uptimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ public class PowerManagerServiceTest {
|
|||||||
|
|
||||||
Settings.Global.putInt(mContextSpy.getContentResolver(),
|
Settings.Global.putInt(mContextSpy.getContentResolver(),
|
||||||
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
|
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
|
||||||
|
Settings.Secure.putInt(mContextSpy.getContentResolver(),
|
||||||
|
Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 0);
|
||||||
|
|
||||||
mClock = new OffsettableClock.Stopped();
|
mClock = new OffsettableClock.Stopped();
|
||||||
mTestLooper = new TestLooper(mClock::now);
|
mTestLooper = new TestLooper(mClock::now);
|
||||||
@@ -709,6 +711,48 @@ public class PowerManagerServiceTest {
|
|||||||
assertThat(mService.getBinderServiceInstance().forceSuspend()).isFalse();
|
assertThat(mService.getBinderServiceInstance().forceSuspend()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("GuardedBy")
|
||||||
|
@Test
|
||||||
|
public void testScreensaverActivateOnSleepDisabled_powered_afterTimeout_goesToDozing() {
|
||||||
|
when(mBatteryManagerInternalMock.isPowered(anyInt())).thenReturn(true);
|
||||||
|
|
||||||
|
doAnswer(inv -> {
|
||||||
|
when(mDreamManagerInternalMock.isDreaming()).thenReturn(true);
|
||||||
|
return null;
|
||||||
|
}).when(mDreamManagerInternalMock).startDream(anyBoolean());
|
||||||
|
|
||||||
|
setMinimumScreenOffTimeoutConfig(5);
|
||||||
|
createService();
|
||||||
|
startSystem();
|
||||||
|
|
||||||
|
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_AWAKE);
|
||||||
|
|
||||||
|
advanceTime(15000);
|
||||||
|
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_DOZING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("GuardedBy")
|
||||||
|
@Test
|
||||||
|
public void testScreensaverActivateOnSleepEnabled_powered_afterTimeout_goesToDreaming() {
|
||||||
|
when(mBatteryManagerInternalMock.isPowered(anyInt())).thenReturn(true);
|
||||||
|
Settings.Secure.putInt(mContextSpy.getContentResolver(),
|
||||||
|
Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 1);
|
||||||
|
|
||||||
|
doAnswer(inv -> {
|
||||||
|
when(mDreamManagerInternalMock.isDreaming()).thenReturn(true);
|
||||||
|
return null;
|
||||||
|
}).when(mDreamManagerInternalMock).startDream(anyBoolean());
|
||||||
|
|
||||||
|
setMinimumScreenOffTimeoutConfig(5);
|
||||||
|
createService();
|
||||||
|
startSystem();
|
||||||
|
|
||||||
|
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_AWAKE);
|
||||||
|
|
||||||
|
advanceTime(15000);
|
||||||
|
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_DREAMING);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetDozeOverrideFromDreamManager_triggersSuspendBlocker() {
|
public void testSetDozeOverrideFromDreamManager_triggersSuspendBlocker() {
|
||||||
final String suspendBlockerName = "PowerManagerService.Display";
|
final String suspendBlockerName = "PowerManagerService.Display";
|
||||||
@@ -1136,6 +1180,11 @@ public class PowerManagerServiceTest {
|
|||||||
info.displayGroupId = nonDefaultDisplayGroupId;
|
info.displayGroupId = nonDefaultDisplayGroupId;
|
||||||
when(mDisplayManagerInternalMock.getDisplayInfo(nonDefaultDisplay)).thenReturn(info);
|
when(mDisplayManagerInternalMock.getDisplayInfo(nonDefaultDisplay)).thenReturn(info);
|
||||||
|
|
||||||
|
doAnswer(inv -> {
|
||||||
|
when(mDreamManagerInternalMock.isDreaming()).thenReturn(true);
|
||||||
|
return null;
|
||||||
|
}).when(mDreamManagerInternalMock).startDream(anyBoolean());
|
||||||
|
|
||||||
final String pkg = mContextSpy.getOpPackageName();
|
final String pkg = mContextSpy.getOpPackageName();
|
||||||
final Binder token = new Binder();
|
final Binder token = new Binder();
|
||||||
final String tag = "testRemovedDisplayGroupWakeLock_affectsNoDisplayGroups";
|
final String tag = "testRemovedDisplayGroupWakeLock_affectsNoDisplayGroups";
|
||||||
|
|||||||
Reference in New Issue
Block a user