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 FPD CG50-C3 list stays a note, and its gear key needs a scancode (#475)
xbshengd05ecc090232
diff --git a/PROMPT.md b/PROMPT.mdindex f38d0836c..fa901b2fd 100644--- a/PROMPT.md+++ b/PROMPT.md@@ -85,6 +85,9 @@ LauncherInput and Settings/dashboard buttons, so after disabling it ask me to press each one, and remap any thatdo nothing with the launcher's key services: `input_key_keycodes` and `app_keys` withINPUT_KEY_SERVICE=1, `settings_key_keycodes` with HOME_KEY_SERVICE=1 (`config.xml` or the theme).+ A button the TV logs as `KEY_UNKNOWN` or `KEY_PROGRAM` cannot be matched by keycode, since every+ unmapped button shares it: read the scancode with `getevent -lt` and use `settings_key_scancodes`,+ which only `config.xml` carries (a theme can set keycodes, not scancodes).- On Android 11 and newer the launcher must declare `<queries>` for `android.intent.category.LEANBACK_LAUNCHER`,or package visibility silently hides every app and the grid comes up empty; target a recent SDK, someGoogle TV 14 sets refuse older targets at install.diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex aec219597..a229db840 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -182,6 +182,11 @@ tools/tv.py 'dumpsys accessibility'to one app (on Google TV several go to launcherx, which is disabled), and Xiaomi firmware logs everypress as `handleAction<keycode>` in `logcat`. Put it in `input_key_keycodes` (opens Inputs) or`app_keys` (`keycode:package`), reinstall with `INPUT_KEY_SERVICE=1` and press the real button.+ A press that `logcat` reports as `KEY_UNKNOWN` or `KEY_PROGRAM` cannot be matched by keycode at all,+ because every unmapped button shares those codes: use the Linux scancode from+ `tools/tv.py 'getevent -lt'` in `settings_key_scancodes` and install with `HOME_KEY_SERVICE=1`+ (an RC-36 remote sends its gear on scancode 240 and its notifications button on 362 that way; see+ [the FPD CG50-C3 note](devices/fpd-cg50-c3.md)).Enabled but never bound points at a firmware restriction on auto-starting sideloaded services (some TCLbuilds log `OP_AUTO_START` denials). Look at `logcat` for the binding failure before changing settings,diff --git a/docs/devices/fpd-cg50-c3.md b/docs/devices/fpd-cg50-c3.mdnew file mode 100644index 000000000..7278f36ed--- /dev/null+++ b/docs/devices/fpd-cg50-c3.md@@ -0,0 +1,155 @@+# FPD CG50-C3: a one-day list, and a remote with two buttons Android never maps++The `FPD CG50-C3` is a 50-inch set sold in Canada. The brand is not the builder: `ro.product.model`+is `EcoTV Pro A`, device `hongkong`, product `FPD_4KHA0`, on a MediaTek SoC. The owner ran+[`PROMPT.md`](../../PROMPT.md) with Claude Code on Windows 11 (the PowerShell scripts and `tools/tv.py`)+and reports that the debloat, the launcher install, the HOME handover, the remote remap and AdGuard+Private DNS all worked, with ADB closed at the end.++He also says when: the list was applied the day he wrote #475. So **this is not an `examples/` list**.+[`CONTRIBUTING.md`](../../CONTRIBUTING.md) asks for a few days of living with a list before it goes there,+and nothing here was reboot-soaked or repeated on a second unit. The package block below is his, quoted+as he posted it; the sections after it are the parts that carry to another set, which is why the file+exists at all.++## Identify the firmware, not the brand++A retail name on a KTC board tells you almost nothing about the software, so record what+`getprop` answers:++| Field | Observed value |+|---|---|+| Retail model | `FPD CG50-C3`, 50 inch |+| Market | Canada |+| `ro.product.model` | `EcoTV Pro A` (KTC) |+| `ro.product.device` | `hongkong` |+| `ro.product.name` (product) | `FPD_4KHA0` |+| SoC | MediaTek |+| Android / SDK | 11 / 30, Google TV |+| `ro.build.display.id` / firmware | `RTM9.241015.016` |+| Usable RAM | 1.8 GB |+| UI | 1080p |+| `ro.adb.secure` | `1` |++## Reaching ADB++USB debugging alone opened network ADB on port 5555; `ro.adb.secure=1` means the first connection+shows the RSA prompt on the TV, which the owner accepted. At the end of the session port 5555 was+refused after a reboot, i.e. the debugging toggle did not survive it.++## The list as applied++Transcribed from #475. One day of use, one reboot, no soak - read it as a starting point and comment+out what you need.++```text+# Ads, auto-installs, telemetry+com.mediatek.android.leanbacklauncher.partnercustomizer # partner rows injected into the stock home+android.autoinstalls.config.google.gtvpai # Play auto-installs+com.google.android.feedback # feedback reports to Google+com.google.android.apps.tv.dreamx # Ambient screensaver with recommendations++# Manufacturer preloads+fusion.android.tv.demo # retail store demo loop+com.mstar.android.tv.disclaimercustomization # first-run disclaimer screen+com.electronic.manual # e-manual+com.mediatek.androidbox # Miracast / screen sharing (WFDSinkTest); keep if you mirror++# Preloaded apps, off by choice+com.google.android.videos # Google TV movies & shows store+com.google.android.play.games # Google Play Games+com.google.android.youtube.tvmusic # YouTube Music++# Home handover: re-enable setupwraith before a factory reset (restore does it)+com.google.android.tungsten.setupwraith # first-run wizard, takes Home otherwise+com.google.android.apps.tv.launcherx # stock Google TV home (sponsored rows); replaced by launcher/+```++Stock Home is `com.google.android.apps.tv.launcherx`, Live TV is `com.mediatek.wwtv.tvcenter`, and the+launcher's default `live_tv_package` already matches it. The Sources list shows HDMI 1-3, Composite and+Live TV, so the Inputs side needs no `input_action`.++## setupwraith owned a saved network, but not the one in use++`com.google.android.tungsten.setupwraith` claims HOME here through `.RecoveryActivity` at priority 1,+the usual Google TV situation, and the handover needed the usual package-level disable.++The Wi-Fi question had a different answer than on most sets. This unit has several saved networks and+setupwraith created one of them - not the network the TV was on. Disabling it therefore did not take+the TV offline, and `FORCE_SETUPWRAITH=1` was safe. The check is two commands rather than one, because+the first only names the creators:++```sh+tools/tv.py "dumpsys wifi | grep -o 'cname=[^ ]*'"+tools/tv.py "cmd wifi status"+```++If the network in `cmd wifi status` is the one whose `cname=` is setupwraith, forget and rejoin it+before the install instead of forcing. If the creators include setupwraith but the active SSID is+another one, forcing costs nothing today - and costs the unused network tomorrow, which is fine.++`logcat -b crash` stayed clean after the handover: no `FATAL EXCEPTION IN SYSTEM PROCESS` and no+`setupwraith/.RecoveryActivity` restart loop. That is worth checking rather than assuming, since the+same disable is what starts the loop on some Google TV 14 builds.++## The RC-36 remote: two buttons Android never maps++The remote is an RC-36 over Bluetooth (vendor `0x0b7a`, product `0x0001`). `dumpsys window policy`+shows the firmware routing its keys to apps that survive the debloat: `KEYCODE_SETTINGS` and the app+buttons (Netflix and friends) go to `com.mediatek.tv.service`, `KEYCODE_TV_INPUT` goes to+`com.mediatek.wwtv.tvcenter`. So Input and the app buttons keep working once launcherx is gone, which+is not true on every Google TV set.++Two buttons died with launcherx, and neither can be fixed by keycode:++| Button | Scancode | Keycode Android reports |+|---|---|---|+| gear (Settings) | 240 | `KEY_UNKNOWN` (HID usage `0x0c009f`) |+| notifications (program guide) | 362 | `KEY_PROGRAM` |++`KEY_UNKNOWN` is not a code you can list - every unmapped button shares it - so the match has to be+on the Linux scancode:++```sh+INPUT_KEY_SERVICE=1 HOME_KEY_SERVICE=1 ./launcher/build-and-install.sh+# config.xml (or the theme's config.json copy of it):+# settings_key_scancodes 240, 362+# settings_key_panel true # gear opens the small panel instead of the full Settings app+```++`settings_key_scancodes` is read by `HomeKeyService`, hence `HOME_KEY_SERVICE=1`, and only from+`config.xml`: the theme can set `settings_key_keycodes`, not scancodes. Read the scancode with+`tools/tv.py 'getevent -lt'` while pressing the real button - an injected `input keyevent` never+reaches an accessibility service, so it cannot be used to test this.++`HomeKeyService` bound on its own here, with no `OP_AUTO_START` denial in `logcat`, so the TCL-style+auto-start block does not apply to this firmware.++## What was kept, and why++- `com.ktc.tv.factory` and `ktc.factorymenu.ui`: both have `HotKeyReceiver` / `FactoryKeyReceiver`+ registered for remote global keys. They look like bloat and they are reachable, but disabling them+ takes remote buttons with them.+- `com.mediatek.autopair`: re-pairs the remote. Losing it means no way back into the TV without a+ USB keyboard.+- `com.mediatek.wwtv.*` and the TV input packages: Live TV and the input switcher.+- `com.ktc.serialport`: a factory serial console whose purpose the owner could not establish. Kept+ because nothing was known about what stops working without it.+- Assistant, Chromecast, Netflix: kept by choice.++The active screensaver was `com.google.android.apps.tv.dreamx`, so the list disables it and the launcher+supplies `com.gathin.tvhome/.ClockDream` instead. No manufacturer OTA package was found on the box,+so nothing in the list is about firmware updates.++AdGuard Private DNS was set up alongside the debloat and YouTube still loads and plays; its ads stay,+which is expected - DNS blocking does not touch same-origin ad requests.++## Limits++- One session, one set, one reboot. No multi-day test, no second unit, no screenshots.+- The list is the owner's; the package annotations are his. Only the ordering and the surrounding+ sections are this file's.+- Nothing here says the same firmware exists on other FPD sizes: check the `ro.product.device` and+ build first.+- Promote this to `examples/fpd-cg50-c3/` once someone has lived with it for a few days and can say+ what came back after the next firmware update.diff --git a/examples/README.md b/examples/README.mdindex 701c189ac..b9cea4fd4 100644--- a/examples/README.md+++ b/examples/README.md@@ -131,6 +131,7 @@ on that firmware, grouped and commented. These are starting points: comment outNotes for models that have no tested list yet live in [`docs/devices/`](../docs/devices/):+- [FPD CG50-C3](../docs/devices/fpd-cg50-c3.md), KTC-built `EcoTV Pro A` / `FPD_4KHA0`, MediaTek, Google TV 11 `RTM9.241015.016`, Canada: a one-day list, kept as a note for that reason; setupwraith owned a saved network that was not the one in use, so `FORCE_SETUPWRAITH=1` was safe; the RC-36 remote's gear and notifications buttons arrive as scancodes 240/362 with `KEY_UNKNOWN`/`KEY_PROGRAM`, so they need `settings_key_scancodes` rather than a keycode.- [TCL `75c63b`](../docs/devices/tcl-75c63b.md), owner-reported retail model, `Smart TV Pro` / `BeyondTV4`, Android 11, `V8-R51MT05-LF1V652`: launcher-only installation, HOME priorities and component restrictions, correct Live TV player package, restoration and explicit test limits.- [Xiaomi MiTV-MFTR0 "freeguy"](../docs/devices/xiaomi-mitv-mftr0-freeguy.txt), China, Android 14: inputs, Xiaomi settings intents, app discovery.diff --git a/tests/test_fpd_cg50_c3_note.py b/tests/test_fpd_cg50_c3_note.pynew file mode 100644index 000000000..be08d5d70--- /dev/null+++ b/tests/test_fpd_cg50_c3_note.py@@ -0,0 +1,269 @@+"""The FPD CG50-C3 note: a one-day list stays a note, and its remote lesson lands in the docs.++#475 supplied a working list plus two facts the repo was missing: a setupwraith check that has to be+two commands because the wizard owned a saved network that was not the one in use, and a remote whose+gear and notifications buttons arrive as scancodes 240/362 with `KEY_UNKNOWN`/`KEY_PROGRAM` - codes+that no `settings_key_keycodes` entry can ever match. The note itself is only worth having if it keeps+the list out of `examples/` while the two facts reach the docs a user actually reads, so the tests+parse sections and bullets rather than grepping the whole file: a sentence that drifts into a+neighbouring section would leave both just as useless.++Run from the repository root: python3 -m unittest discover -s tests -v+"""+from pathlib import Path+import re+import unittest+++ROOT = Path(__file__).resolve().parents[1]+++def read(relative):+ """Text of a repo file, or empty if it does not exist yet (each test then fails with its own message)."""+ path = ROOT / relative+ return path.read_text(encoding="utf-8") if path.is_file() else ""+++NOTE = read("docs/devices/fpd-cg50-c3.md")+TROUBLE = read("docs/TROUBLESHOOTING.md")+PROMPT = read("PROMPT.md")+EXAMPLES_README = read("examples/README.md")++PACKAGES = [+ "com.mediatek.android.leanbacklauncher.partnercustomizer",+ "android.autoinstalls.config.google.gtvpai",+ "com.google.android.feedback",+ "com.google.android.apps.tv.dreamx",+ "fusion.android.tv.demo",+ "com.mstar.android.tv.disclaimercustomization",+ "com.electronic.manual",+ "com.mediatek.androidbox",+ "com.google.android.videos",+ "com.google.android.play.games",+ "com.google.android.youtube.tvmusic",+ "com.google.android.tungsten.setupwraith",+ "com.google.android.apps.tv.launcherx",+]+++def section(title_needle):+ """Body of the `## ...` section whose heading contains the needle."""+ parts = re.split(r"(?m)^## ", NOTE)+ matches = [p for p in parts[1:] if title_needle.lower() in p.split("\n", 1)[0].lower()]+ assert len(matches) == 1, f"expected one section about {title_needle!r}, found {len(matches)}"+ return matches[0]+++def table_rows(block):+ """Rows of the first markdown table in a block, as cell lists."""+ lines = [l for l in block.splitlines() if l.startswith("|")]+ assert lines, "no table in this section"+ rows = []+ for line in lines[2:]:+ rows.append([c.strip() for c in line.strip("|").split("|")])+ return rows+++def fenced_text(block, info="text"):+ m = re.search(r"```" + info + r"\n(.*?)\n```", block, re.S)+ assert m, f"no ```{info} block"+ return m.group(1)+++def bullets(text):+ """`- **...` bullets with their wrapped lines, as one flattened string each."""+ found, current = [], None+ for line in text.splitlines():+ if line.startswith("- **"):+ if current is not None:+ found.append(current)+ current = line+ elif current is not None and (line.startswith(" ") or not line.strip()):+ current += "\n" + line+ else:+ if current is not None:+ found.append(current)+ current = None+ if current is not None:+ found.append(current)+ return [re.sub(r"\s+", " ", b) for b in found]+++def bullet_containing(text, needle):+ matches = [b for b in bullets(text) if needle in b]+ assert len(matches) == 1, f"expected one bullet with {needle!r}, found {len(matches)}"+ return matches[0]+++def prompt_bullet(needle):+ """PROMPT.md bullets start with a plain `- `, not `- **`, so they need their own reader."""+ found, current = [], None+ for line in PROMPT.splitlines():+ if line.startswith("- "):+ if current is not None:+ found.append(current)+ current = line+ elif current is not None and (line.startswith(" ") or not line.strip()):+ current += "\n" + line+ else:+ if current is not None:+ found.append(current)+ current = None+ if current is not None:+ found.append(current)+ matches = [b for b in found if needle in b]+ assert len(matches) == 1, f"expected one prompt bullet with {needle!r}, found {len(matches)}"+ return re.sub(r"\s+", " ", matches[0])+++class NoteKeepsTheListOutOfExamplesTest(unittest.TestCase):+ def test_no_examples_folder_for_a_one_day_list(self):+ self.assertFalse((ROOT / "examples" / "fpd-cg50-c3").exists(),+ "a list applied the same day belongs in docs/devices/, not examples/")++ def test_the_note_says_why(self):+ self.assertIn("not an `examples/` list", NOTE)+ self.assertIn("CONTRIBUTING.md", NOTE)+ self.assertIn("one day", NOTE.lower())++ def test_limits_section_is_honest(self):+ limits = section("Limits")+ for phrase in ("One session", "no second unit", "reboot"):+ self.assertIn(phrase, limits)+ self.assertIn("Promote this to `examples/fpd-cg50-c3/`", limits)+++class IdentityTest(unittest.TestCase):+ def test_firmware_fields(self):+ rows = dict((r[0], r[1]) for r in table_rows(section("Identify the firmware")))+ self.assertIn("`EcoTV Pro A`", rows["`ro.product.model`"])+ self.assertIn("`hongkong`", rows["`ro.product.device`"])+ self.assertIn("`FPD_4KHA0`", rows["`ro.product.name` (product)"])+ self.assertIn("`RTM9.241015.016`", rows["`ro.build.display.id` / firmware"])+ self.assertIn("11 / 30", rows["Android / SDK"])+ self.assertIn("`1`", rows["`ro.adb.secure`"])++ def test_adb_is_recorded_as_usb_toggle_then_closed(self):+ adb = section("Reaching ADB")+ self.assertIn("USB debugging alone", adb)+ self.assertIn("5555", adb)+ self.assertIn("refused after a reboot", adb)+++class TranscribedListTest(unittest.TestCase):+ def setUp(self):+ self.block = fenced_text(section("The list as applied"))++ def test_every_listed_package_is_a_bare_name(self):+ packages = []+ for n, line in enumerate(self.block.splitlines(), 1):+ body = line.split("#", 1)[0].strip()+ if body:+ self.assertRegex(body, r"^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z0-9_]+)+$",+ f"line {n} is not a package name: {line!r}")+ packages.append(body)++ def test_the_thirteen_packages_survived(self):+ packages = [l.split("#", 1)[0].strip() for l in self.block.splitlines()+ if l.split("#", 1)[0].strip()]+ self.assertEqual(sorted(packages), sorted(PACKAGES))+ self.assertEqual(len(packages), len(set(packages)), "a package is listed twice")++ def test_the_list_is_attributed_to_the_owner(self):+ body = section("The list as applied")+ self.assertIn("#475", body)+ self.assertIn("Transcribed", body)++ def test_live_tv_and_inputs_are_answered(self):+ body = section("The list as applied")+ self.assertIn("com.mediatek.wwtv.tvcenter", body)+ self.assertIn("live_tv_package", body)+ self.assertIn("HDMI 1-3", body)+++class SetupwraithCheckTest(unittest.TestCase):+ def setUp(self):+ self.body = section("setupwraith")++ def test_the_check_is_two_commands(self):+ # `dumpsys wifi` alone names every creator; only `cmd wifi status` names the one in use,+ # and that difference is what makes FORCE safe here.+ self.assertIn("dumpsys wifi | grep -o 'cname=[^ ]*'", self.body)+ self.assertIn("cmd wifi status", self.body)+ self.assertIn("not the one in use", self.body)++ def test_forcing_is_scoped_to_this_situation(self):+ self.assertIn("FORCE_SETUPWRAITH=1", self.body)+ self.assertIn("forget and rejoin", self.body)++ def test_crash_loop_was_checked_not_assumed(self):+ self.assertIn("logcat -b crash", self.body)+++class RemoteScancodeTest(unittest.TestCase):+ def setUp(self):+ self.body = section("remote")+ self.rows = dict((r[0], (r[1], r[2])) for r in table_rows(self.body))++ def test_the_two_dead_buttons_are_scancode_and_unmapped_keycode(self):+ gear = next(v for k, v in self.rows.items() if "gear" in k)+ notifications = next(v for k, v in self.rows.items() if "notification" in k)+ self.assertEqual(gear[0], "240")+ self.assertIn("`KEY_UNKNOWN`", gear[1])+ self.assertEqual(notifications[0], "362")+ self.assertIn("`KEY_PROGRAM`", notifications[1])++ def test_no_keycode_can_match_them(self):+ self.assertIn("not a code you can list", self.body)+ self.assertIn("scancode", self.body)++ def test_the_fix_is_scancodes_with_the_home_helper(self):+ self.assertIn("settings_key_scancodes", self.body)+ self.assertIn("240, 362", self.body)+ self.assertIn("HOME_KEY_SERVICE=1", self.body)+ self.assertIn("only from", self.body) # config.xml, not the theme++ def test_testing_needs_the_real_remote(self):+ self.assertIn("getevent -lt", self.body)+ self.assertIn("never\nreaches an accessibility service", self.body.replace(" ", " "))++ def test_working_buttons_come_from_the_firmware_routing(self):+ self.assertIn("dumpsys window policy", self.body)+ self.assertIn("com.mediatek.tv.service", self.body)+++class KeptPackagesTest(unittest.TestCase):+ def test_the_factory_and_pairing_apps_are_explained(self):+ kept = section("What was kept")+ for package in ("com.ktc.tv.factory", "ktc.factorymenu.ui",+ "com.mediatek.autopair", "com.ktc.serialport"):+ self.assertIn(package, kept)+ self.assertIn("purpose the owner could not establish", kept)+++class DocsPointersTest(unittest.TestCase):+ def test_troubleshooting_bullet_carries_the_scancode_path(self):+ bullet = bullet_containing(TROUBLE, "Which keycode")+ self.assertIn("`KEY_UNKNOWN`", bullet)+ self.assertIn("`KEY_PROGRAM`", bullet)+ self.assertIn("settings_key_scancodes", bullet)+ self.assertIn("getevent -lt", bullet)+ self.assertIn("HOME_KEY_SERVICE=1", bullet)+ self.assertIn("devices/fpd-cg50-c3.md", bullet)++ def test_prompt_tells_the_assistant_the_same(self):+ bullet = prompt_bullet("stock launcher also answers the remote's app buttons")+ self.assertIn("`KEY_UNKNOWN`", bullet)+ self.assertIn("`KEY_PROGRAM`", bullet)+ self.assertIn("settings_key_scancodes", bullet)+ self.assertIn("only `config.xml`", bullet)++ def test_examples_index_links_the_note_once(self):+ pointers = [l for l in EXAMPLES_README.splitlines() if "../docs/devices/fpd-cg50-c3.md" in l]+ self.assertEqual(len(pointers), 1, "the note should be indexed once in examples/README.md")+ self.assertIn("one-day", pointers[0])+ self.assertIn("240/362", pointers[0])+++if __name__ == "__main__":+ unittest.main()