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

Commit 736d5f0d authored by Nathalie Le Clair's avatar Nathalie Le Clair
Browse files

Turn on TV when pressing power or wake key during boot

Applies to HDMI-CEC playback devices only.

Boot isn't always triggered by the user and therefore shouldn't turn on an HDMI-connected TV.

However, if a power or wake key is pressed during boot, there is a clear user intention to use the Android device.
This CL makes the playback device turn on the connected TV in that
situation.

Test: atest PowerManagerServiceTest and atest com.android.server.hdmi
Bug: 183691245
Change-Id: I53e54d72a5c7fa54d27d743d80bad4644e897d2b
parent 3cb2509e
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -3479,13 +3479,23 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (!mSystemBooted) {
            // If we have not yet booted, don't let key events do anything.
            // Exception: Wake and power key events are forwarded to PowerManager to allow it to
            // wake from quiescent mode during boot.
            // wake from quiescent mode during boot. On these key events we also explicitly turn on
            // the connected TV and switch HDMI input if we're a HDMI playback device.
            boolean shouldTurnOnTv = false;
            if (down && (keyCode == KeyEvent.KEYCODE_POWER
                    || keyCode == KeyEvent.KEYCODE_TV_POWER)) {
                wakeUpFromPowerKey(event.getDownTime());
                shouldTurnOnTv = true;
            } else if (down && (isWakeKey || keyCode == KeyEvent.KEYCODE_WAKEUP)
                    && isWakeKeyWhenScreenOff(keyCode)) {
                wakeUpFromWakeKey(event);
                shouldTurnOnTv = true;
            }
            if (shouldTurnOnTv) {
                final HdmiControl hdmiControl = getHdmiControl();
                if (hdmiControl != null) {
                    hdmiControl.turnOnTv();
                }
            }
            return 0;
        }