Skip to content

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

launcher: key_filter option keeps remote key repeat working

Singh, Shantanu1f694f1f4af8
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index 9c50fbe8d..371bf66c4 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -115,6 +115,18 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/
script now picks the known stock launcher among the candidates by itself; otherwise choose one on
the TV or pass `STOCK_LAUNCHER=<package>`.
+## Held-down remote keys do not repeat (volume steps once per long press)
+
+On some firmware — seen on a TCL Google TV 12 build — enabling any accessibility service that requests
+key filtering (the launcher's `HomeKeyService` and `InputKeyService`) breaks key auto-repeat: the held
+button produces a single press. With every such service disabled the repeat returns.
+
+There is no way to keep the remote buttons those helpers power *and* the repeat on those builds; choose
+one. To keep the helpers enabled but stop them filtering (repeat works, the buttons they handled go
+dead), push a theme with `"key_filter": false` in `config.json` — the service drops
+`FLAG_REQUEST_FILTER_KEY_EVENTS` at runtime instead of needing the whole service disabled. `config.xml`
+has the same switch as the `key_filter` bool for a rebuild.
+
## Accessibility helper enabled but the remote button does nothing
The optional `HomeKeyService` and `InputKeyService` only filter remote keys once Android has bound to
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
index 96f18aae5..cb541637a 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -76,6 +76,9 @@ final class Config {
final int[] inputKeycodes;
/** Remote buttons that open an app, "keycode:package" or "KEYCODE_NAME:package" (config.xml app_keys). */
final List<String> appKeys;
+ /** Whether the key services request key filtering (config.xml or theme key_filter); false keeps key
+ * auto-repeat working on firmware whose AccessibilityInputFilter drops repeats (TCL Android 12). */
+ final boolean keyFilter;
/** The Settings button opens the quick settings panel instead of the TV's Settings (settings_key_panel). */
final boolean settingsKeyPanel;
/** Whether themes may show a wallpaper (config.json, wallpaper). */
@@ -98,9 +101,10 @@ final class Config {
boolean showHomeSettingsShortcut, boolean showStats, boolean appLibrary, int backgroundColor, int skyIntensity,
int[] settingsKeycodes, boolean settingsKeyPanel, boolean wallpaperEnabled, File wallpaper, List<File> wallpapers,
int wallpaperRotationMinutes, int wallpaperDim, boolean overlayApplied,
- Festival festival, int[] inputKeycodes, List<String> appKeys) {
+ Festival festival, int[] inputKeycodes, List<String> appKeys, boolean keyFilter) {
this.inputKeycodes = inputKeycodes;
this.appKeys = Collections.unmodifiableList(appKeys);
+ this.keyFilter = keyFilter;
this.dockApps = Collections.unmodifiableList(dockApps);
this.fillDock = fillDock;
this.hiddenApps = Collections.unmodifiableList(hiddenApps);
@@ -173,6 +177,7 @@ final class Config {
boolean settingsKeyPanel = res.getBoolean(R.bool.settings_key_panel);
int[] inputKeycodes = res.getIntArray(R.array.input_key_keycodes);
List<String> appKeys = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.app_keys)));
+ boolean keyFilter = res.getBoolean(R.bool.key_filter);
boolean applied = false;
File dir = dir(ctx);
@@ -209,6 +214,7 @@ final class Config {
settingsKeyPanel = bool(json, "settings_key_panel", settingsKeyPanel);
inputKeycodes = intArray(json, "input_key_keycodes", inputKeycodes);
appKeys = stringList(json, "app_keys", appKeys);
+ keyFilter = bool(json, "key_filter", keyFilter);
}
// A theme push or reset invalidates choices made on the TV. On first use, remember the
// current theme without clearing choices from an older launcher version.
@@ -239,7 +245,7 @@ final class Config {
shamsi, greetingName, moduleCards, reducedMotion, dockTitle, dockRow, reorderButton, vpn, homeSettings, showStats, library, background,
Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, wallpaperEnabled, wallpaper,
wallpapers, rotationMinutes, wallpaperDim, applied,
- festival, inputKeycodes, appKeys);
+ festival, inputKeycodes, appKeys, keyFilter);
}
private static void syncThemeChoices(SharedPreferences choices, File dir, File config) {
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
index 2cc4aa27d..218eb0823 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
@@ -36,6 +36,7 @@ public class HomeKeyService extends AccessibilityService {
settingsKeycodes = config.settingsKeycodes;
settingsPanel = config.settingsKeyPanel;
appKeys = RemoteKeys.parseAppKeys(config.appKeys);
+ RemoteKeys.applyKeyFilter(this, config.keyFilter);
}
private boolean isSettingsKey(KeyEvent event) {
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/InputKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/InputKeyService.java
index 26e2d0cbc..f51579bd9 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/InputKeyService.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/InputKeyService.java
@@ -30,6 +30,7 @@ public class InputKeyService extends AccessibilityService {
Config config = Config.load(this);
inputKeycodes = config.inputKeycodes;
appKeys = RemoteKeys.parseAppKeys(config.appKeys);
+ RemoteKeys.applyKeyFilter(this, config.keyFilter);
}
private boolean isInputKey(int keyCode) {
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java b/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java
index 21e4345fa..5816f44d8 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java
@@ -1,5 +1,7 @@
package com.gathin.tvhome;
+import android.accessibilityservice.AccessibilityService;
+import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@@ -53,6 +55,21 @@ final class RemoteKeys {
return keys;
}
+ /**
+ * Applies the key_filter choice (config.xml or a theme): when false the service drops
+ * FLAG_REQUEST_FILTER_KEY_EVENTS at runtime, so it stays enabled for nothing but stops filtering.
+ * Some firmware (TCL Google TV on Android 12) drops key auto-repeat once ANY service filters keys:
+ * long-pressing volume then steps once per press. Filtering can only be skipped while the service
+ * runs, since the flag is also declared in the manifest metadata.
+ */
+ static void applyKeyFilter(AccessibilityService service, boolean keyFilter) {
+ if (keyFilter) return;
+ AccessibilityServiceInfo info = service.getServiceInfo();
+ if (info == null) return;
+ info.flags &= ~AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS;
+ service.setServiceInfo(info);
+ }
+
/** Opens an app from a remote button: its TV entry if it has one, else its phone entry. */
static void launch(Context ctx, String pkg) {
Intent open = ctx.getPackageManager().getLeanbackLaunchIntentForPackage(pkg);
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index d415e695b..468c0893c 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -44,6 +44,12 @@
(XGIMI projectors: com.xgimi.action.hdmiPlayer). Leave empty to omit. -->
<string name="input_action" translatable="false"></string>
+ <!-- Whether HomeKeyService and InputKeyService actually request key filtering (config.xml or a theme's
+ "key_filter"). Some firmware (TCL Google TV on Android 12) drops key auto-repeat once ANY service
+ filters keys, so long-pressing volume only steps once: set false and the service keeps running but
+ stops filtering, which brings repeat back at the price of the remote buttons below doing nothing. -->
+ <bool name="key_filter">true</bool>
+
<!-- Remote buttons that open Settings, by Linux scancode (HOME_KEY_SERVICE=1 build-and-install.sh). Remotes
that send KEYCODE_SETTINGS need no entry. Some send a code Android does not map: the Xiaomi/Fengmi
projector remote's gear button is scancode 384 (KEY_TAPE). Find yours with
diff --git a/themes/README.md b/themes/README.md
index f81ca920c..8402b75be 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -60,6 +60,7 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can
| `settings_key_panel` | bool | Those buttons open a small quick settings panel (TV settings, Display, Network, Apps, Launcher settings) instead of the TV's Settings |
| `input_key_keycodes` | list of keycodes | More remote buttons that open the input switcher, for `InputKeyService` (`KEYCODE_TV` and `KEYCODE_TV_INPUT` always do) |
| `app_keys` | list of strings | Remote buttons that open an app, as `"190:com.google.android.youtube.tv"` or `"KEYCODE_BUTTON_3:com.google.android.youtube.tv"`, for `InputKeyService` or `HomeKeyService` |
+| `key_filter` | bool | `false` makes the key helpers stop filtering keys while staying enabled. Use it on firmware where any key-filtering accessibility service breaks long-press repeat (TCL Google TV on Android 12): the remote buttons above stop working, and volume repeat comes back |
## Wallpapers