Default TV remote keys to no-wake
For Android TV, we want the default behavior of keys to not wake
up the device. We want to be able to whitelist keys if wake is
desired.
This differs from the behavior on mobile where the default is
to wake the device unless its a media key.
We separate by means of the idc file. Specifying
"keyboard.doNotWakeByDefault=1" in the idc would indicate the device is
a TV remote and should go through corresponding path.
Bug: 144979700
Test: Change idc/kl files. Rebuild and examine 'dumpsys input' on key presses.
atest inputflinger_tests
Change-Id: I4168c4c21fd901ca0402e0211f636b06234b9a85
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
index f51d4a0..348a7ad 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
@@ -183,6 +183,9 @@
mParameters.handlesKeyRepeat = false;
config.tryGetProperty(String8("keyboard.handlesKeyRepeat"), mParameters.handlesKeyRepeat);
+
+ mParameters.doNotWakeByDefault = false;
+ config.tryGetProperty(String8("keyboard.doNotWakeByDefault"), mParameters.doNotWakeByDefault);
}
void KeyboardInputMapper::dumpParameters(std::string& dump) {
@@ -331,10 +334,12 @@
// Key down on external an 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, the key layout file should specify the policy flags for
- // each wake key individually.
+ // 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 && getDevice()->isExternal() && !isMediaKey(keyCode)) {
+ if (down && getDevice()->isExternal() && !mParameters.doNotWakeByDefault &&
+ !isMediaKey(keyCode)) {
policyFlags |= POLICY_FLAG_WAKE;
}