Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

docs: where a held volume key's repeat goes with a key helper bound, in the Android 12 source

Robert2ff1a8a29617
diff --git a/docs/devices/tcl-55p71b-g09-key-repeat.md b/docs/devices/tcl-55p71b-g09-key-repeat.md
index 184b644c0..3c94b5784 100644
--- a/docs/devices/tcl-55p71b-g09-key-repeat.md
+++ b/docs/devices/tcl-55p71b-g09-key-repeat.md
@@ -155,6 +155,40 @@ own key log (`WindowManager: interceptKeyTi keyCode=24 down=true repeatCount=0`)
it. The empty-list control was not run there either. The owner kept the helper for the YouTube, Prime
Video, Disney+, Peacock and gear buttons and lives with one step per press.
+## The path in the Android 12 source, and a Philips set measured both ways
+
+The Hisense reading above holds line by line in AOSP `android12-release`, and a fourth vendor measures the
+same way. With an input filter installed, `InputDispatcher::notifyKey` hands every key to the filter before
+anything is queued. For a key, `AccessibilityInputFilter` goes to `KeyboardInterceptor.onKeyEvent`, whose
+`getEventDelay` asks the window policy first for Volume Up and Down only
+(`mPolicy.interceptKeyBeforeDispatching(null, event, policyFlags)`), and returns without passing the event on
+when the answer is negative. On a TV (`mUseTvRouting`) `PhoneWindowManager.interceptKeyBeforeDispatching`
+answers a volume key with `dispatchDirectAudioEvent(event)` and `key_consumed`, which is `-1`. So the key
+takes its one volume step inside that check and is dropped there: no accessibility service is offered it,
+and it never reaches `InputDispatcher::dispatchKeyLocked`, the only place that records a held key
+(`mKeyRepeatState.lastKeyEntry`) and synthesizes its repeats every `getKeyRepeatDelay()`, 50 ms. That is
+why `onKeyEvent` has nothing to log, and why a helper cannot repeat the key itself either. Source:
+[KeyboardInterceptor.java](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android12-release/services/accessibility/java/com/android/server/accessibility/KeyboardInterceptor.java),
+[PhoneWindowManager.java](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android12-release/services/core/java/com/android/server/policy/PhoneWindowManager.java),
+[InputDispatcher.cpp](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android12-release/services/inputflinger/dispatcher/InputDispatcher.cpp).
+
+Measured on a Philips 65OLED804/12 (TPM191E, Android TV 12, `STT2.230526.001`, the fifth unit in
+[`examples/philips-tpm191e`](../../examples/philips-tpm191e/debloat.txt)), sound over HDMI ARC to a home
+cinema system, with `getevent -lt` on the remote and the volume event log in `dumpsys audio`. On a TV,
+`AudioService.handleVolumeKey` logs one `adjustSuggestedStreamVolume` for the down (`VOL_ADJUST_START`) and
+one for the up (`VOL_ADJUST_END`), so a pair is one press:
+
+| `enabled_accessibility_services` | Volume Down held | `dumpsys audio` |
+| --- | --- | --- |
+| `HomeKeyService` alone (`capabilities=8`) | 3.0 s | the start and the end, nothing between |
+| `null`, with `accessibility_enabled 0` | 1.07 s | the start, 14 repeats 50 ms apart from about 250 ms on, the end |
+
+The remote sent one `DOWN` and one `UP` per press in both runs, never a repeat of its own, so every step in
+the second row came from the dispatcher; 20 steps a second is also why a held key runs away on this set.
+Single presses step once either way. `settings put secure long_press_timeout` is no way to slow the ramp
+here: the dispatcher marks its first repeat `FLAG_LONG_PRESS`, which is what Home's long-press action waits
+for, and with 800 set that action still fired 400 ms after the down, before and after a reboot.
+
## Choices
- **Keep the repeat and skip the helpers.** Do not pass `INPUT_KEY_SERVICE=1` or `HOME_KEY_SERVICE=1`