Skip to content

Commit 88089cc

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Wake on volume key when in dock. Bug: 5580373" into ics-mr1
2 parents 15843aa + 43150bf commit 88089cc

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
@@ -2486,7 +2486,7 @@ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
24862486
// keyguard, then we need to have it turn on the
24872487
// screen once it is shown.
24882488
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(
2489-
KeyEvent.KEYCODE_POWER);
2489+
KeyEvent.KEYCODE_POWER, mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED);
24902490
}
24912491
} else {
24922492
// Light up the keyboard if we are sliding up.
@@ -2706,7 +2706,8 @@ public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean i
27062706
if (down && isWakeKey) {
27072707
if (keyguardActive) {
27082708
// If the keyguard is showing, let it decide what to do with the wake key.
2709-
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode);
2709+
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode,
2710+
mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED);
27102711
} else {
27112712
// Otherwise, wake the device ourselves.
27122713
result |= ACTION_POKE_USER_ACTIVITY;

0 commit comments

Comments
 (0)