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

Commit 731ce712 authored by Nathalie Le Clair's avatar Nathalie Le Clair Committed by Android (Google) Code Review
Browse files

Merge "Implement KEYCODE_TV_POWER"

parents 13658939 22d11e19
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -519,8 +519,13 @@ public class KeyEvent extends InputEvent implements Parcelable {
    /** Key code constant: Settings key.
     * Starts the system settings activity. */
    public static final int KEYCODE_SETTINGS        = 176;
    /** Key code constant: TV power key.
     * On TV remotes, toggles the power on a television screen. */
    /**
     * Key code constant: TV power key.
     * On HDMI TV panel devices and Android TV devices that don't support HDMI, toggles the power
     * state of the device.
     * On HDMI source devices, toggles the power state of the HDMI-connected TV via HDMI-CEC and
     * makes the source device follow this power state.
     */
    public static final int KEYCODE_TV_POWER        = 177;
    /** Key code constant: TV input key.
     * On TV remotes, switches the input on a television screen. */
+26 −0
Original line number Diff line number Diff line
@@ -3686,6 +3686,32 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                break;
            }

            case KeyEvent.KEYCODE_TV_POWER: {
                result &= ~ACTION_PASS_TO_USER;
                isWakeKey = false; // wake-up will be handled separately
                HdmiControlManager hdmiControlManager = getHdmiControlManager();
                if (hdmiControlManager != null && hdmiControlManager.shouldHandleTvPowerKey()) {
                    if (down) {
                        hdmiControlManager.toggleAndFollowTvPower();
                    }
                } else if (mHasFeatureLeanback) {
                    KeyEvent fallbackEvent = KeyEvent.obtain(
                            event.getDownTime(), event.getEventTime(),
                            event.getAction(), KeyEvent.KEYCODE_POWER,
                            event.getRepeatCount(), event.getMetaState(),
                            event.getDeviceId(), event.getScanCode(),
                            event.getFlags(), event.getSource(), event.getDisplayId(), null);
                    if (down) {
                        interceptPowerKeyDown(fallbackEvent, interactive);
                    } else {
                        interceptPowerKeyUp(fallbackEvent, interactive, canceled);
                    }
                }
                // Ignore this key for any device that is not connected to a TV via HDMI and
                // not an Android TV device.
                break;
            }

            case KeyEvent.KEYCODE_POWER: {
                EventLogTags.writeInterceptPower(
                        KeyEvent.actionToString(event.getAction()),