Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b13bfab3 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Do not wake device when going from emulated -> non-emulated state" into main

parents 3f64dc81 d31d7a4e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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)
+10 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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,