Decouple key_repeat_timeout and long_press_timeout
The key repeat timeout was the same as the long press timeout before
Android U. However, due to a long-standing bug, the InputDispatcher
queried the key repeat timeout early in the boot phase before the
long press timeout setting was actually read, which meant that the
default fallback value was being used every time.
Although the key repeat timeout used the long press timeout under the
hood, the behavior from the user's perspective was that the key press
timeout could effectively never be changed.
Code changes in U solved the aforementioned long-standing bug, but the
now-new behavior of key repeats being affected by changes in long
press timeout is unexpected from a user perspective.
We have decided that we want to decouple to two settings altogether,
without having one fall back to the other.
Bug: 310657006
Test: manual, adb shell settings put secure key_repeat_timeout <value>
Change-Id: Ieb7167c3639bad6e7eaa24bdfc657b8ac1de0b8e
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index ec96167..fb2b8b9 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -88,6 +88,13 @@
private static final int DEFAULT_MULTI_PRESS_TIMEOUT = 300;
/**
+ * Defines the default duration in milliseconds between a key being pressed and its first key
+ * repeat event being generated. Historically, Android used the long press timeout as the
+ * key repeat timeout, so its default value is set to long press timeout's default.
+ */
+ private static final int DEFAULT_KEY_REPEAT_TIMEOUT_MS = DEFAULT_LONG_PRESS_TIMEOUT;
+
+ /**
* Defines the default duration between successive key repeats in milliseconds.
*/
private static final int DEFAULT_KEY_REPEAT_DELAY_MS = 50;
@@ -719,11 +726,8 @@
* @return the time before the first key repeat in milliseconds.
*/
public static int getKeyRepeatTimeout() {
- // Before the key repeat timeout was introduced, some users relied on changing
- // LONG_PRESS_TIMEOUT settings to also change the key repeat timeout. To support
- // this backward compatibility, we'll use the long press timeout as default value.
return AppGlobals.getIntCoreSetting(Settings.Secure.KEY_REPEAT_TIMEOUT_MS,
- getLongPressTimeout());
+ DEFAULT_KEY_REPEAT_TIMEOUT_MS);
}
/**