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
This commit is contained in:
Nathalie Le Clair
2021-11-09 17:02:34 +01:00
parent 3cb2509ef7
commit 736d5f0d81

View File

@@ -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;
}