diff options
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | core/java/android/view/KeyEvent.java | 14 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 2 | ||||
-rw-r--r-- | data/keyboards/Generic.kl | 4 | ||||
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 16 |
5 files changed, 33 insertions, 5 deletions
diff --git a/api/current.txt b/api/current.txt index c0f44dc..754a84f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28122,6 +28122,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 @@ -28143,6 +28144,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 diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index 7e745d8..c183f08 100644 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -628,11 +628,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() @@ -877,6 +885,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. diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index a78ce02..f85b193 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -1596,6 +1596,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> <!-- ***************************************************************** --> diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl index 2042345..0cdcb1c 100644 --- a/data/keyboards/Generic.kl +++ b/data/keyboards/Generic.kl @@ -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" diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 17a0e60..9ecb917 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -3809,7 +3809,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; } @@ -4009,6 +4011,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: |