diff options
| author | 2023-03-06 10:06:32 +0000 | |
|---|---|---|
| committer | 2023-03-06 23:30:51 +0000 | |
| commit | 1625786a2cdf054aa5f65861c401c68c832695ad (patch) | |
| tree | 1300bb9b37fe9bdc1628cc79ae2fc15b80264137 | |
| parent | 3e76a50f69a2f1955ea5f412c997f80d2a0a0651 (diff) | |
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
| -rw-r--r-- | services/inputflinger/reader/mapper/KeyboardInputMapper.cpp | 36 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 6 |
2 files changed, 5 insertions, 37 deletions
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp index 0361bc670a..dc0454dc04 100644 --- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp +++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp @@ -61,36 +61,6 @@ static bool isSupportedScanCode(int32_t scanCode) { 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 @@ std::list<NotifyArgs> KeyboardInputMapper::processKey(nsecs_t when, nsecs_t read 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; } diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index 0855683ba2..9732e8d53d 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -3658,8 +3658,8 @@ protected: }; TEST_F(KeyboardInputMapperTest_ExternalDevice, WakeBehavior) { - // For external devices, non-media keys will trigger wake on key down. Media keys need to be - // marked as WAKE in the keylayout file to trigger wake. + // For external devices, keys will trigger wake on key down. Media keys should also trigger + // wake if triggered from external devices. mFakeEventHub->addKey(EVENTHUB_ID, KEY_HOME, 0, AKEYCODE_HOME, 0); mFakeEventHub->addKey(EVENTHUB_ID, KEY_PLAY, 0, AKEYCODE_MEDIA_PLAY, 0); @@ -3681,7 +3681,7 @@ TEST_F(KeyboardInputMapperTest_ExternalDevice, WakeBehavior) { process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_PLAY, 1); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args)); - ASSERT_EQ(uint32_t(0), args.policyFlags); + ASSERT_EQ(POLICY_FLAG_WAKE, args.policyFlags); process(mapper, ARBITRARY_TIME + 1, READ_TIME, EV_KEY, KEY_PLAY, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args)); |