Skip to content

Commit 43150bf

Browse files
author
Jeff Brown
committed
Wake on volume key when in dock.
Bug: 5580373 Change-Id: I847fb10b48c2e5e26cabefea1d630793efc32131
1 parent 97ece7a commit 43150bf

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,12 +830,13 @@ public void onReceive(Context context, Intent intent) {
830830
* action should be posted to a handler.
831831
*
832832
* @param keyCode The keycode of the key that woke the device
833+
* @param isDocked True if the device is in the dock
833834
* @return Whether we poked the wake lock (and turned the screen on)
834835
*/
835-
public boolean onWakeKeyWhenKeyguardShowingTq(int keyCode) {
836+
public boolean onWakeKeyWhenKeyguardShowingTq(int keyCode, boolean isDocked) {
836837
if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + keyCode + ")");
837838

838-
if (isWakeKeyWhenKeyguardShowing(keyCode)) {
839+
if (isWakeKeyWhenKeyguardShowing(keyCode, isDocked)) {
839840
// give the keyguard view manager a chance to adjust the state of the
840841
// keyguard based on the key that woke the device before poking
841842
// the wake lock
@@ -846,11 +847,22 @@ public boolean onWakeKeyWhenKeyguardShowingTq(int keyCode) {
846847
}
847848
}
848849

849-
private boolean isWakeKeyWhenKeyguardShowing(int keyCode) {
850+
/**
851+
* When the keyguard is showing we ignore some keys that might otherwise typically
852+
* be considered wake keys. We filter them out here.
853+
*
854+
* {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it
855+
* is always considered a wake key.
856+
*/
857+
private boolean isWakeKeyWhenKeyguardShowing(int keyCode, boolean isDocked) {
850858
switch (keyCode) {
859+
// ignore volume keys unless docked
851860
case KeyEvent.KEYCODE_VOLUME_UP:
852861
case KeyEvent.KEYCODE_VOLUME_DOWN:
853862
case KeyEvent.KEYCODE_VOLUME_MUTE:
863+
return isDocked;
864+
865+
// ignore media and camera keys
854866
case KeyEvent.KEYCODE_MUTE:
855867
case KeyEvent.KEYCODE_HEADSETHOOK:
856868
case KeyEvent.KEYCODE_MEDIA_PLAY:

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,7 +2480,7 @@ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
24802480
// keyguard, then we need to have it turn on the
24812481
// screen once it is shown.
24822482
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(
2483-
KeyEvent.KEYCODE_POWER);
2483+
KeyEvent.KEYCODE_POWER, mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED);
24842484
}
24852485
} else {
24862486
// Light up the keyboard if we are sliding up.
@@ -2700,7 +2700,8 @@ public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean i
27002700
if (down && isWakeKey) {
27012701
if (keyguardActive) {
27022702
// If the keyguard is showing, let it decide what to do with the wake key.
2703-
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode);
2703+
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode,
2704+
mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED);
27042705
} else {
27052706
// Otherwise, wake the device ourselves.
27062707
result |= ACTION_POKE_USER_ACTIVITY;

0 commit comments

Comments
 (0)