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

Commit 6212a49a authored by Jeff Brown's avatar Jeff Brown
Browse files

Declare KEYCODE_SLEEP and KEYCODE_WAKEUP.

These new keys behave in similarly to KEYCODE_POWER but do not
simply toggle between awake and asleep states.

Sleep puts the device to sleep if it is awake.
Wakeup wakes up the device if it is asleep.

Bug: 12938999
Change-Id: I260fb918cc858882fe06fa880910df5763a76c5d
parent 16ed831e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26903,6 +26903,7 @@ package android.view {
    field public static final int KEYCODE_SHIFT_LEFT = 59; // 0x3b
    field public static final int KEYCODE_SHIFT_RIGHT = 60; // 0x3c
    field public static final int KEYCODE_SLASH = 76; // 0x4c
    field public static final int KEYCODE_SLEEP = 223; // 0xdf
    field public static final int KEYCODE_SOFT_LEFT = 1; // 0x1
    field public static final int KEYCODE_SOFT_RIGHT = 2; // 0x2
    field public static final int KEYCODE_SPACE = 62; // 0x3e
@@ -26924,6 +26925,7 @@ package android.view {
    field public static final int KEYCODE_VOLUME_MUTE = 164; // 0xa4
    field public static final int KEYCODE_VOLUME_UP = 24; // 0x18
    field public static final int KEYCODE_W = 51; // 0x33
    field public static final int KEYCODE_WAKEUP = 224; // 0xe0
    field public static final int KEYCODE_WINDOW = 171; // 0xab
    field public static final int KEYCODE_X = 52; // 0x34
    field public static final int KEYCODE_Y = 53; // 0x35
+12 −2
Original line number Diff line number Diff line
@@ -629,11 +629,19 @@ public class KeyEvent extends InputEvent implements Parcelable {
    /** Key code constant: Brightness Up key.
     * Adjusts the screen brightness up. */
    public static final int KEYCODE_BRIGHTNESS_UP   = 221;
    /** Key code constant: Audio Track key
    /** Key code constant: Audio Track key.
     * Switches the audio tracks. */
    public static final int KEYCODE_MEDIA_AUDIO_TRACK = 222;
    /** Key code constant: Sleep key.
     * Puts the device to sleep.  Behaves somewhat like {@link #KEYCODE_POWER} but it
     * has no effect if the device is already asleep. */
    public static final int KEYCODE_SLEEP           = 223;
    /** Key code constant: Wakeup key.
     * Wakes up the device.  Behaves somewhat like {@link #KEYCODE_POWER} but it
     * has no effect if the device is already awake. */
    public static final int KEYCODE_WAKEUP          = 224;

    private static final int LAST_KEYCODE           = KEYCODE_MEDIA_AUDIO_TRACK;
    private static final int LAST_KEYCODE = KEYCODE_WAKEUP;

    // NOTE: If you add a new keycode here you must also add it to:
    //  isSystem()
@@ -878,6 +886,8 @@ public class KeyEvent extends InputEvent implements Parcelable {
        names.append(KEYCODE_BRIGHTNESS_DOWN, "KEYCODE_BRIGHTNESS_DOWN");
        names.append(KEYCODE_BRIGHTNESS_UP, "KEYCODE_BRIGHTNESS_UP");
        names.append(KEYCODE_MEDIA_AUDIO_TRACK, "KEYCODE_MEDIA_AUDIO_TRACK");
        names.append(KEYCODE_SLEEP, "KEYCODE_SLEEP");
        names.append(KEYCODE_WAKEUP, "KEYCODE_WAKEUP");
    };

    // Symbolic names of all metakeys in bit order from least significant to most significant.
+2 −0
Original line number Diff line number Diff line
@@ -1571,6 +1571,8 @@
        <enum name="KEYCODE_BRIGHTNESS_DOWN" value="220" />
        <enum name="KEYCODE_BRIGHTNESS_UP" value="221" />
        <enum name="KEYCODE_MEDIA_AUDIO_TRACK" value="222" />
        <enum name="KEYCODE_MEDIA_SLEEP" value="223" />
        <enum name="KEYCODE_MEDIA_WAKEUP" value="224" />
    </attr>

    <!-- ***************************************************************** -->
+2 −2
Original line number Diff line number Diff line
@@ -161,8 +161,8 @@ key 128 MEDIA_STOP
key 139   MENU              WAKE_DROPPED
key 140   CALCULATOR
# key 141 "KEY_SETUP"
key 142   POWER             WAKE
key 143   POWER             WAKE
key 142   SLEEP             WAKE
key 143   WAKEUP            WAKE
# key 144 "KEY_FILE"
# key 145 "KEY_SENDFILE"
# key 146 "KEY_DELETEFILE"
+15 −1
Original line number Diff line number Diff line
@@ -3816,7 +3816,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                                                mKeyguardDelegate.isShowingAndNotHidden() :
                                                mKeyguardDelegate.isShowing()));

        if (keyCode == KeyEvent.KEYCODE_POWER) {
        if (keyCode == KeyEvent.KEYCODE_POWER
                || keyCode == KeyEvent.KEYCODE_SLEEP
                || keyCode == KeyEvent.KEYCODE_WAKEUP) {
            policyFlags |= WindowManagerPolicy.FLAG_WAKE;
        }

@@ -4013,6 +4015,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                break;
            }

            case KeyEvent.KEYCODE_SLEEP: {
                result &= ~ACTION_PASS_TO_USER;
                mPowerManager.goToSleep(event.getEventTime());
                isWakeKey = false;
                break;
            }

            case KeyEvent.KEYCODE_WAKEUP: {
                result &= ~ACTION_PASS_TO_USER;
                break;
            }

            case KeyEvent.KEYCODE_MEDIA_PLAY:
            case KeyEvent.KEYCODE_MEDIA_PAUSE:
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: