summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vaibhav Devmurari <vdevmurari@google.com> 2024-02-22 22:36:23 +0000
committer Vaibhav Devmurari <vdevmurari@google.com> 2024-02-26 11:29:45 +0000
commite092fefc822f4b4fb101345f74a7c951413c97b7 (patch)
tree8c34d48973e2bedee5c88f9d3831b7f7a88a6a6e
parente471edcfcf020e51512952f39d147c89c6ed38be (diff)
Don't repeat when slow keys A11y feature enabled
Currently when slow keys is enabled, user has to press and hold for the key to be registered, but since, we still haven't added settings to modify repeat thresholds, usually it ends up repeating the pressed key as well which may be annoying for the user. As a stop gap, we block repeat for now when slow keys is enabled. Future plan at V+ is to have repat threshold modification in Settings allowing user to properly configure it as per the need. Bug: 322327461 Test: Manual Change-Id: I44503746c16ed992bbfbfe852e26e22896f32595
-rw-r--r--services/inputflinger/rust/slow_keys_filter.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/services/inputflinger/rust/slow_keys_filter.rs b/services/inputflinger/rust/slow_keys_filter.rs
index 01165b57fa..09fbf40842 100644
--- a/services/inputflinger/rust/slow_keys_filter.rs
+++ b/services/inputflinger/rust/slow_keys_filter.rs
@@ -28,6 +28,9 @@ use log::debug;
use std::collections::HashSet;
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
+// Policy flags from Input.h
+const POLICY_FLAG_DISABLE_KEY_REPEAT: i32 = 0x08000000;
+
#[derive(Debug)]
struct OngoingKeyDown {
scancode: i32,
@@ -129,6 +132,12 @@ impl Filter for SlowKeysFilter {
let mut pending_event = *event;
pending_event.downTime += slow_filter.slow_key_threshold_ns;
pending_event.eventTime = pending_event.downTime;
+ // Currently a slow keys user ends up repeating the presses key quite often
+ // since default repeat thresholds are very low, so blocking repeat for events
+ // when slow keys is enabled.
+ // TODO(b/322327461): Allow key repeat with slow keys, once repeat key rate and
+ // thresholds can be modified in the settings.
+ pending_event.policyFlags |= POLICY_FLAG_DISABLE_KEY_REPEAT;
slow_filter.pending_down_events.push(pending_event);
}
KeyEventAction::UP => {
@@ -200,7 +209,7 @@ impl ThreadCallback for SlowKeysFilter {
mod tests {
use crate::input_filter::{test_callbacks::TestCallbacks, test_filter::TestFilter, Filter};
use crate::input_filter_thread::test_thread::TestThread;
- use crate::slow_keys_filter::SlowKeysFilter;
+ use crate::slow_keys_filter::{SlowKeysFilter, POLICY_FLAG_DISABLE_KEY_REPEAT};
use android_hardware_input_common::aidl::android::hardware::input::common::Source::Source;
use com_android_server_inputflinger::aidl::com::android::server::inputflinger::{
DeviceInfo::DeviceInfo, KeyEvent::KeyEvent, KeyEventAction::KeyEventAction,
@@ -285,6 +294,7 @@ mod tests {
action: KeyEventAction::DOWN,
downTime: 100,
eventTime: 100,
+ policyFlags: POLICY_FLAG_DISABLE_KEY_REPEAT,
..BASE_KEY_EVENT
}
);