Allow media keys to wake device for external keyboards.
Legacy code for blocking wake on media keys can be removed,
since we block wake for internal keyboard (so that device don't
wake up in pockets), and devices like TV remove that have
doNoWakeByDefault flag set to true in their idc file.
For all other external keyboards we should wake the device even
for a media key.
Test: manual
Bug: 267526027
Change-Id: I522027c2a168996f229fd6ec11e72989b9a8f567
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
index 0361bc6..dc0454d 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
@@ -61,36 +61,6 @@
scanCode >= BTN_WHEEL;
}
-static bool isMediaKey(int32_t keyCode) {
- switch (keyCode) {
- case AKEYCODE_MEDIA_PLAY:
- case AKEYCODE_MEDIA_PAUSE:
- case AKEYCODE_MEDIA_PLAY_PAUSE:
- case AKEYCODE_MUTE:
- case AKEYCODE_HEADSETHOOK:
- case AKEYCODE_MEDIA_STOP:
- case AKEYCODE_MEDIA_NEXT:
- case AKEYCODE_MEDIA_PREVIOUS:
- case AKEYCODE_MEDIA_REWIND:
- case AKEYCODE_MEDIA_RECORD:
- case AKEYCODE_MEDIA_FAST_FORWARD:
- case AKEYCODE_MEDIA_SKIP_FORWARD:
- case AKEYCODE_MEDIA_SKIP_BACKWARD:
- case AKEYCODE_MEDIA_STEP_FORWARD:
- case AKEYCODE_MEDIA_STEP_BACKWARD:
- case AKEYCODE_MEDIA_AUDIO_TRACK:
- case AKEYCODE_VOLUME_UP:
- case AKEYCODE_VOLUME_DOWN:
- case AKEYCODE_VOLUME_MUTE:
- case AKEYCODE_TV_AUDIO_DESCRIPTION:
- case AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP:
- case AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN:
- return true;
- default:
- return false;
- }
-}
-
// --- KeyboardInputMapper ---
KeyboardInputMapper::KeyboardInputMapper(InputDeviceContext& deviceContext, uint32_t source,
@@ -295,14 +265,12 @@
keyMetaState = mMetaState;
}
- // Key down on external an keyboard should wake the device.
+ // Any key down on an external keyboard should wake the device.
// We don't do this for internal keyboards to prevent them from waking up in your pocket.
// For internal keyboards and devices for which the default wake behavior is explicitly
// prevented (e.g. TV remotes), the key layout file should specify the policy flags for each
// wake key individually.
- // TODO: Use the input device configuration to control this behavior more finely.
- if (down && getDeviceContext().isExternal() && !mParameters.doNotWakeByDefault &&
- !isMediaKey(keyCode)) {
+ if (down && getDeviceContext().isExternal() && !mParameters.doNotWakeByDefault) {
policyFlags |= POLICY_FLAG_WAKE;
}