@@ -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 :
0 commit comments