Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
docs: the Streamer's app buttons can be taken without a key helper, and keep the repeat (#796)
xbsheng118858e1507e
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex 2474d0231..f38aeb1cf 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -597,6 +597,44 @@ Android 11 (SDK 30), build RS8185.3885N:Debloat: `tools/disable.sh examples/amazon-fire-tv-aftdec012e/debloat.txt` disables telemetry, ACR, shopping andtutorial packages. Undo with `tools/restore.sh examples/amazon-fire-tv-aftdec012e/debloat.txt com.amazon.tv.launcher`.+## Remapping the remote's app buttons without a key helper++A process of your own can take the buttons the helpers exist for without binding an accessibility service,+and the key auto-repeat a helper costs stays: a key-filtering service pushes every key through a filter+path that drops the repeats, while reading the remote's input device leaves Android's input alone.+It has to run as the `shell` user, because a normal app cannot open `/dev/input/event*`, so this is not+something the launcher can grow into — it is a script and a supervisor on the TV. On a Google TV Streamer+(`kirkwood`, Google TV 14, `UTTK.260317.003`) that was the one way to have both: `HomeKeyService` alone,+`InputKeyService` alone and both together each stopped the ramp after roughly six steps, and it came back+the moment the service was unbound ([#796](https://github.com/Gathin23/cleanyourtv/issues/796)).++The Streamer's remote appears as `Google TV Remote Keyboard`, and these are the buttons it sends:++| Button | HID usage | Android keycode |+| --- | --- | --- |+| YouTube | `0x000c0077` | `BUTTON_3` (190) |+| Star | `0x000c0186` | `MACRO_1` (313) |+| Netflix | `0x000c0078` | `BUTTON_4` |++Find the node by name, not by number: `tools/tv.py 'getevent -pl'` lists every input device with its name+and the key codes it declares, and the `/dev/input/event<N>` a remote lands on is not stable between boots,+so a watcher pinned to `event5` stops working after the next reboot and reads as a dead button again.++A reader cannot consume the press. `getevent` observes the events and Android still delivers them to+whatever answers them today, so a remapped button's stock action runs as well: map the Netflix button and+Netflix starts too, then sits in the activity back stack. A helper consumes the key it maps — which is why+the vendor receiver in the "Which keycode" bullet above never sees it — so the buttons you have to+suppress, rather than duplicate, still need a helper and its repeat trade.++What runs it again after a reboot is the part that is not free. The `shell` user reads+`/dev/input/eventX` on this unit without root and a script kept under `/data/local/tmp/` runs, but nothing+there starts itself: Android gives the `shell` user no cron and no init hook without root, so the watcher is+gone after every reboot and has to be started again from a debugging session you close afterwards. Two+things fail silently when you do: the script must be detached from the `adb shell` session or it dies with+it, and a supervisor must not start a second copy. Do not solve the reboot by leaving TCP ADB on so+something local can restart it — port 5555 reachable from the LAN is a shell on the TV for anything on the+network, which is why the closing step in [README](../README.md#questions-people-ask) turns it off.+## A key helper is bound and a held remote button stopped repeatingHold volume up or down and the volume moves one step per press instead of ramping. The remote may bediff --git a/examples/google-tv-streamer-4k-kirkwood/debloat.txt b/examples/google-tv-streamer-4k-kirkwood/debloat.txtindex 6b63130be..0e58de7bf 100644--- a/examples/google-tv-streamer-4k-kirkwood/debloat.txt+++ b/examples/google-tv-streamer-4k-kirkwood/debloat.txt@@ -81,6 +81,13 @@# `getevent -lt` prints the Star button as KEY_SPREADSHEET and the other two as KEY_UNKNOWN, which is# why the layout file is the place to read them. All three checked with the real remote on# UTTK.260317.003.+# - Both helpers cost the remote's key auto-repeat on this build: with HomeKeyService or InputKeyService+# bound, holding Volume Up/Down stops after about six steps. The YouTube button can also be taken+# without an accessibility service, which keeps the ramp: a shell-owned process watches the remote's+# input device ("Google TV Remote Keyboard", found by name with `getevent -pl`, never by a fixed+# number) and starts the app itself. It cannot consume the press, so the button's own action still runs+# as well - see docs/TROUBLESHOOTING.md, "Remapping the remote's app buttons without a key helper"+# (#796).# - com.google.android.tvrecommendations and com.google.android.apps.education.cast2class ship# disabled at the factory; `pm disable-user` on them fails with "Shell cannot change component# state". Don't add them to a restore list either.diff --git a/tests/test_streamer_watcher_note.py b/tests/test_streamer_watcher_note.pynew file mode 100644index 000000000..80aa3fc32--- /dev/null+++ b/tests/test_streamer_watcher_note.py@@ -0,0 +1,69 @@+"""Anchors for the Streamer watcher note (#796): the heading, its three buttons, and the reboot limit.++The note says a shell-owned `getevent` watcher takes the remote's app buttons without binding a+key-filtering accessibility service, so the key auto-repeat a helper costs stays. Three things in it are+worth failing a later edit over, and they are the whole test: the Streamer's reported HID usages, the+limit that a reader cannot consume the press (which is why suppressing a button still needs a helper), and+that the watcher does not survive a reboot - the version that did survive needed TCP ADB left on, which+this page no longer offers. Wording is not pinned here; the maintainer asked for anchors, not a transcript.+"""+import re+import unittest+from pathlib import Path+++ROOT = Path(__file__).resolve().parents[1]+TROUBLE = ROOT / "docs" / "TROUBLESHOOTING.md"+STREAMER = ROOT / "examples" / "google-tv-streamer-4k-kirkwood" / "debloat.txt"++HEADING = "Remapping the remote's app buttons without a key helper"++# As #796 reports them. A row that stops matching the report is a row this note invented.+REPORTED = (("YouTube", "0x000c0077"), ("Star", "0x000c0186"), ("Netflix", "0x000c0078"))+++def section(text, heading):+ """Body of the '## <heading>' section, or None. Stops at the next level-1 or 2 heading."""+ match = re.search(r"^#{1,2}\s+" + re.escape(heading) + r"\s*$(.*?)(?=^#{1,2}\s|\Z)", text, re.M | re.S)+ return match.group(1) if match else None+++class StreamerWatcherNoteTest(unittest.TestCase):+ def setUp(self):+ page = TROUBLE.read_text(encoding="utf-8")+ body = section(page, HEADING)+ self.assertIsNotNone(body, "the note's section is missing from TROUBLESHOOTING.md")+ self.raw = body or ""+ self.body = re.sub(r"\s+", " ", self.raw)++ def test_the_heading_is_unique_and_the_example_header_points_at_it(self):+ self.assertEqual(len(re.findall(r"^##\s+" + re.escape(HEADING) + r"\s*$",+ TROUBLE.read_text(encoding="utf-8"), re.M)), 1)+ header = re.sub(r"\s+", " ", STREAMER.read_text(encoding="utf-8"))+ self.assertIn('docs/TROUBLESHOOTING.md, "' + HEADING + '"', header)+ self.assertIn("#796", header)++ def test_the_three_buttons_match_the_report(self):+ rows = [line for line in self.raw.splitlines() if line.startswith("|")]+ for button, usage in REPORTED:+ row = next((r for r in rows if r.split("|")[1].strip() == button), None)+ self.assertIsNotNone(row, f"the {button} button is missing from the table")+ self.assertIn(usage, row or "")++ def test_keeps_the_limit_that_only_a_helper_can_suppress_a_button(self):+ self.assertIn("cannot consume the press", self.body)+ self.assertIn("Netflix starts too", self.body)++ def test_does_not_promise_the_watcher_survives_a_reboot(self):+ # The reboot-proof arrangement needed a TCP ADB client on the TV, i.e. port 5555 left listening;+ # the maintainer asked for that recipe to go, so the note must not quietly grow it back.+ self.assertIn("after every reboot", self.body)+ self.assertIn("detached from the `adb shell` session", self.body)+ for recipe in ("local ADB client", "authorized key", "127.0.0.1:5555"):+ self.assertNotIn(recipe, self.body)+ self.assertIn("../README.md#questions-people-ask", self.body)+ self.assertTrue((TROUBLE.parent / ".." / "README.md").resolve().exists())+++if __name__ == "__main__":+ unittest.main()