Loading services/core/java/com/android/server/display/LogicalDisplayMapper.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.display; import static android.hardware.devicestate.DeviceState.PROPERTY_EMULATED_ONLY; import static android.hardware.devicestate.DeviceState.PROPERTY_POWER_CONFIGURATION_TRIGGER_SLEEP; import static android.hardware.devicestate.DeviceState.PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE; import static android.hardware.devicestate.DeviceStateManager.INVALID_DEVICE_STATE; Loading Loading @@ -594,6 +595,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { boolean shouldDeviceBeWoken(DeviceState pendingState, DeviceState currentState, boolean isInteractive, boolean isBootCompleted) { if (mDeviceStateManagerFlags.deviceStatePropertyMigration()) { if (currentState.hasProperties(PROPERTY_EMULATED_ONLY) && !pendingState.hasProperties(PROPERTY_EMULATED_ONLY)) { // Do not wake the device, since this transition may occur due to the user pressing // the power button to exit an emulated state. return false; } return pendingState.hasProperty(PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE) && !currentState.equals(INVALID_DEVICE_STATE) && !currentState.hasProperty(PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE) Loading services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,8 @@ public class LogicalDisplayMapperTest { Set.of(DeviceState.PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE), Collections.emptySet()); private static final DeviceState DEVICE_STATE_OPEN = createDeviceState(2, "Two", Set.of(DeviceState.PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE), Collections.emptySet()); private static final DeviceState DEVICE_STATE_EMULATED = createDeviceState(3, "Three", Set.of(DeviceState.PROPERTY_EMULATED_ONLY), Collections.emptySet()); private static final int FLAG_GO_TO_SLEEP_ON_FOLD = 0; private static final int FLAG_GO_TO_SLEEP_FLAG_SOFT_SLEEP = 2; private static int sNextNonDefaultDisplayId = DEFAULT_DISPLAY + 1; Loading Loading @@ -685,6 +687,14 @@ public class LogicalDisplayMapperTest { /* isBootCompleted= */true)); } @Test public void testDeviceShouldNotBeWokenWhenExitingEmulatedState() { assertFalse(mLogicalDisplayMapper.shouldDeviceBeWoken(DEVICE_STATE_OPEN, DEVICE_STATE_EMULATED, /* isInteractive= */false, /* isBootCompleted= */true)); } @Test public void testDeviceShouldBePutToSleep() { assertTrue(mLogicalDisplayMapper.shouldDeviceBePutToSleep(DEVICE_STATE_CLOSED, Loading Loading
services/core/java/com/android/server/display/LogicalDisplayMapper.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.display; import static android.hardware.devicestate.DeviceState.PROPERTY_EMULATED_ONLY; import static android.hardware.devicestate.DeviceState.PROPERTY_POWER_CONFIGURATION_TRIGGER_SLEEP; import static android.hardware.devicestate.DeviceState.PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE; import static android.hardware.devicestate.DeviceStateManager.INVALID_DEVICE_STATE; Loading Loading @@ -594,6 +595,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { boolean shouldDeviceBeWoken(DeviceState pendingState, DeviceState currentState, boolean isInteractive, boolean isBootCompleted) { if (mDeviceStateManagerFlags.deviceStatePropertyMigration()) { if (currentState.hasProperties(PROPERTY_EMULATED_ONLY) && !pendingState.hasProperties(PROPERTY_EMULATED_ONLY)) { // Do not wake the device, since this transition may occur due to the user pressing // the power button to exit an emulated state. return false; } return pendingState.hasProperty(PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE) && !currentState.equals(INVALID_DEVICE_STATE) && !currentState.hasProperty(PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE) Loading
services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,8 @@ public class LogicalDisplayMapperTest { Set.of(DeviceState.PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE), Collections.emptySet()); private static final DeviceState DEVICE_STATE_OPEN = createDeviceState(2, "Two", Set.of(DeviceState.PROPERTY_POWER_CONFIGURATION_TRIGGER_WAKE), Collections.emptySet()); private static final DeviceState DEVICE_STATE_EMULATED = createDeviceState(3, "Three", Set.of(DeviceState.PROPERTY_EMULATED_ONLY), Collections.emptySet()); private static final int FLAG_GO_TO_SLEEP_ON_FOLD = 0; private static final int FLAG_GO_TO_SLEEP_FLAG_SOFT_SLEEP = 2; private static int sNextNonDefaultDisplayId = DEFAULT_DISPLAY + 1; Loading Loading @@ -685,6 +687,14 @@ public class LogicalDisplayMapperTest { /* isBootCompleted= */true)); } @Test public void testDeviceShouldNotBeWokenWhenExitingEmulatedState() { assertFalse(mLogicalDisplayMapper.shouldDeviceBeWoken(DEVICE_STATE_OPEN, DEVICE_STATE_EMULATED, /* isInteractive= */false, /* isBootCompleted= */true)); } @Test public void testDeviceShouldBePutToSleep() { assertTrue(mLogicalDisplayMapper.shouldDeviceBePutToSleep(DEVICE_STATE_CLOSED, Loading