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 hidden factory menu that leaves a Haier/CVTE set half-disabled
xbsheng6c9503fc1999
diff --git a/PROMPT.md b/PROMPT.mdindex f38d0836c..1a0620bdc 100644--- a/PROMPT.md+++ b/PROMPT.md@@ -56,6 +56,12 @@ Debloat- Before touching streaming apps, voice assistant, Chromecast, Miracast or the update service, ask mewhich ones I use with a checklist question and disable only what I don't tick.- Run `pm` commands one per shell call, chained commands may silently stop after the first.+- Don't launch a package whose name says factory, production, AT or fac menu (`com.cvte.tv.hkcfac`,+ `com.at.factory.*`, `mediatek.factorymenu.ui` and the like) to see what it does, even read-only:+ on Haier/CVTE boards opening one flips a factory-mode flag that kills the Input key and CEC, and+ makes the next boot disable Play services, Netflix and Chromecast - which the shell then cannot+ re-enable. `dumpsys package <name>` tells you what a package is without starting it, and+ `docs/TROUBLESHOOTING.md` has the way out if one has been opened.- Disable in small batches and screenshot between them: a batch can take something load-bearing withit and you cannot tell which.- Offer me ad-blocking DNS as an optional extra: on Android 9 and newer, Private DNS set to andiff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex aec219597..8e3b40755 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -53,6 +53,27 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/- **Chained `pm` commands** (`pm disable a; pm disable b`) may silently stop after the first. Runone per shell call; `--batch` does exactly that.- **Large pushes hang** through the Python client. Use `tools/b64push.py` for APKs.+- **The Input key and CEC die after the hidden factory menu is opened**, seen on a Haier/CVTE set+ (Durabrand `DURAT32ISDB`, `dupont`, Android TV 11 build `RTM6.230109.232`,+ [#470](https://github.com/Gathin23/cleanyourtv/issues/470)). `com.cvte.tv.hkcfac` is the+ manufacturer's production app: `dumpsys package` shows it as a factory component, and it has a+ launchable activity, so "let me see what this package does" is enough to trigger it. Opening it+ sets `customer_factory_mode=true` in `/vendor/tvcertificate/fdata.ini` and+ `vendor.mtk.factory.disable.input=1`. The Input button then does nothing and HDMI-CEC is off, and+ at the next boot `com.at.factory.factorymanager` disables Play services, Netflix,+ `com.google.android.katniss` and `com.google.android.apps.mediashell` - `pm enable` from the shell+ is refused for those, so casting and the store stay gone until the mode is cleared. Read the+ package instead of starting it. If it has already been opened, start it, send the factory-exit+ keycode twice **with it in front**, reboot, then turn CEC back on:+ ```sh+ tools/tv.py 'am start -n com.cvte.tv.hkcfac/.MainActivity'+ tools/tv.py 'input keyevent 218; input keyevent 218'+ tools/tv.py reboot+ tools/tv.py 'settings put global hdmi_control_enabled 1'+ ```+ Press the real Input button afterwards and check the packages are back:+ `tools/tv.py 'pm list packages -e | grep -E "gms|netflix|mediashell|katniss"'`. More on the unit in+ the [device notes](devices/durabrand-durat32isdb.md).- **`adb exec-out screencap -p` gives a broken PNG** on some MediaTek sets (Xiaomi, and Amazon'sown Fire TV smart TVs): the binary prints `Init wrapper sys mutex successful` on stdout first.Save on the TV and pull the file instead: `screencap -p /data/local/tmp/s.png`, or cutdiff --git a/docs/devices/durabrand-durat32isdb.md b/docs/devices/durabrand-durat32isdb.mdnew file mode 100644index 000000000..aa304fed9--- /dev/null+++ b/docs/devices/durabrand-durat32isdb.md@@ -0,0 +1,107 @@+# Durabrand DB Android TV 4K (`DURAT32ISDB`, dupont): a one-day owner report++Owner report from+[#470](https://github.com/Gathin23/cleanyourtv/issues/470): one session and one day of use, no+launcher installed. It is **not** a tested list in the `examples/` sense - CONTRIBUTING asks for+several days of living with a list before it goes there - so the packages and the two traps that+came with them are recorded here instead, and this note can graduate to `examples/` once the owner+has run it for longer.++## Identify the firmware++| Field | Reported value |+|---|---|+| Retail model | Durabrand DB Android TV 4K |+| Product | `DURAT32ISDB` |+| Device | `dupont` |+| SoC | `m7332` (Haier / CVTE board) |+| Android / SDK | Android TV 11 / 30 |+| `ro.build.display.id` | `RTM6.230109.232` |+| Security patch | 2023-08-01 |++The board is the same Haier/CVTE family as+[`examples/haier-android-tv-dvb2k/`](../../examples/haier-android-tv-dvb2k/debloat.txt) and+[`examples/haier-h32s80efx/`](../../examples/haier-h32s80efx/debloat.txt), but the package set+differs: this unit has an mstar disclaimer app, a MediaTek input panel, and a system content+launcher that the firmware restarts at every boot. Apply those lists here only after checking each+name with `dumpsys package`.++## What the owner disabled++Ten packages, `pm disable-user --user 0`, one day with no breakage reported.++| Package | What it is |+|---|---|+| `fusion.android.tv.demo` | Retail demo (`HRetailDisplay_2K`) |+| `com.haier.apps` | Store shortcuts |+| `com.haier.apps.evoSmart` | Store / partner promo |+| `com.mstar.android.tv.disclaimercustomization` | Store disclaimer screen |+| `com.google.android.feedback` | Google feedback |+| `com.google.android.videos` | Play Movies |+| `com.google.android.play.games` | Play Games |+| `com.google.android.youtube.tvmusic` | YouTube Music |+| `com.android.printspooler` | Printing (no printer on a TV) |+| `com.google.android.syncadapters.calendar` | Calendar sync for an account nobody signs in with |++The owner also set the three animation scales to `0.5` and reports free RAM going from 495 MB to+550-651 MB of 1.34 GB, plus no retail demo, store disclaimer or Haier/Okko promos at boot.+Netflix, YouTube, Disney+, Max, Prime Video, Jellyfin, HDMI, CEC and casting still worked at the+end of that session.++## Left alone, and why++- `com.google.android.tvrecommendations` and `com.haier.launcher.haiermatrix` come back on every+ boot: `com.at.factory.factorymanager` calls `enableApp` for both, and the second is a system app+ re-enabled during the boot package scan. Disabling them looks like it worked until the next+ restart. ([PR #434](https://github.com/Gathin23/cleanyourtv/pull/434) is the tool that reports+ this kind of drift; until it is merged, check by hand with+ `tools/tv.py 'pm list packages -d | grep -E "tvrecommendations|haiermatrix"'` after a reboot.)+- `com.haier.tv.hmagicboard` receives the remote's hot keys, and `com.cvte.tv.hkcfac` is the+ factory app that also receives them - see the trap below before touching either.+- `com.google.android.tungsten.setupwraith` owns a saved Wi-Fi network on this firmware. Forget and+ rejoin that network before disabling it, or the TV goes offline for good:+ see [the setupwraith Wi-Fi entry](../TROUBLESHOOTING.md).+- `*partnercustomizer` and `com.android.location.fused` were kept.++## The Input key belongs to the MediaTek TV app, not to `tvlauncher`++The panel behind the remote's Input button is provided by `com.mediatek.wwtv.tvcenter`, not by+`com.google.android.tvlauncher`. After a launcher swap the Input button therefore keeps working+even with `tvlauncher` disabled, but the panel is the TV app's own overlay: the reference launcher's+`InputKeyService` is not needed, and `INPUT_KEY_SERVICE=1` should not be set on this unit on the+strength of another Haier list.++## The hidden production menu is the expensive trap++Opening `com.cvte.tv.hkcfac` (a "production" app with a launcher icon nobody uses) sets+`customer_factory_mode=true` in `/vendor/tvcertificate/fdata.ini` and+`vendor.mtk.factory.disable.input=1`. Three things follow:++- the Input key stops working and CEC switches off;+- on the next boot `factorymanager` disables Play services, Netflix, `com.google.android.katniss`+ and `com.google.android.apps.mediashell`, and the shell cannot re-enable those packages;+- casting and the store stay dead until the factory mode is cleared.++The way out without root, as reported: start the app, send factory-exit keycode 218 twice **while it+is in front**, reboot, then turn CEC back on:++```sh+tools/tv.py 'am start -n com.cvte.tv.hkcfac/.MainActivity'+tools/tv.py 'input keyevent 218; input keyevent 218'+tools/tv.py reboot+tools/tv.py 'settings put global hdmi_control_enabled 1'+```++The exit keycode only works with the app in the foreground, so the two key events must not be sent+before it has drawn. The same trap in prose, next to the other "commands that break things" entries,+is in [TROUBLESHOOTING.md](../TROUBLESHOOTING.md).++## Validation scope++- One day of use, one owner, no multi-day soak and no reboot campaign beyond the factory-mode exit.+- No custom launcher was installed: Projectivy worked, the owner went back to the stock launcher by+ preference. Home handover, the launcher's Input/Home helpers and `restore.sh` were not exercised+ on this unit.+- The package list is the owner's, reproduced here as reported; it was not re-read from the TV by+ this note's author, and no screenshot of `dumpsys package` accompanied it.+- The RAM figures are the owner's, measured before and after in one session.diff --git a/examples/README.md b/examples/README.mdindex 701c189ac..4265ce164 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/):+- [Durabrand DB Android TV 4K `DURAT32ISDB`](../docs/devices/durabrand-durat32isdb.md) (`dupont`, m7332 Haier/CVTE board, Android TV 11 `RTM6.230109.232`): one-day owner report, ten packages, the two the firmware turns back on at every boot, the Input panel belonging to the MediaTek TV app instead of `tvlauncher`, and the hidden production menu that leaves Play services and Chromecast disabled until it is exited by hand.- [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_durabrand_factory_note.py b/tests/test_durabrand_factory_note.pynew file mode 100644index 000000000..57cde0822--- /dev/null+++ b/tests/test_durabrand_factory_note.py@@ -0,0 +1,168 @@+"""The Durabrand (#470) device note, and the factory-menu trap it reports.++The note is documentation only, so the tests pin the facts that make it useful (the packages, the+two that the firmware restores, the recovery sequence) and that its links still resolve.++Run from the repository root: python3 -m unittest discover -s tests -v+"""+import re+from pathlib import Path+import unittest++ROOT = Path(__file__).resolve().parents[1]+NOTE = ROOT / "docs" / "devices" / "durabrand-durat32isdb.md"+TROUBLE = ROOT / "docs" / "TROUBLESHOOTING.md"+EXAMPLES_README = ROOT / "examples" / "README.md"+PROMPT = ROOT / "PROMPT.md"+FACTORY = "com.cvte.tv.hkcfac"++DISABLED = [+ "fusion.android.tv.demo",+ "com.haier.apps",+ "com.haier.apps.evoSmart",+ "com.mstar.android.tv.disclaimercustomization",+ "com.google.android.feedback",+ "com.google.android.videos",+ "com.google.android.play.games",+ "com.google.android.youtube.tvmusic",+ "com.android.printspooler",+ "com.google.android.syncadapters.calendar",+]++LINK = re.compile(r"\]\(([^)\s]+)\)")+++def bullet(text, start):+ """The markdown bullet that begins with `start`, up to the next top-level bullet."""+ lines = text.split("\n")+ first = next(i for i, line in enumerate(lines) if line.startswith(start))+ out = [lines[first]]+ for line in lines[first + 1:]:+ if line.startswith("- **") or line.startswith("## "):+ break+ out.append(line)+ return "\n".join(out)+++def broken_links(path):+ broken = []+ for target in LINK.findall(path.read_text(encoding="utf-8")):+ if target.startswith(("http://", "https://", "mailto:", "#")):+ continue+ local = target.split("#", 1)[0]+ if local and not (path.parent / local).exists():+ broken.append(target)+ return broken+++class DurabrandNoteTest(unittest.TestCase):+ def test_note_exists_and_names_the_firmware(self):+ self.assertTrue(NOTE.is_file(), "docs/devices entry missing")+ text = NOTE.read_text(encoding="utf-8")+ for token in ("DURAT32ISDB", "dupont", "m7332", "RTM6.230109.232", "Android TV 11",+ "2023-08-01", "issues/470"):+ with self.subTest(token=token):+ self.assertIn(token, text)++ def test_every_disabled_package_is_recorded(self):+ text = NOTE.read_text(encoding="utf-8")+ for package in DISABLED:+ with self.subTest(package=package):+ self.assertIn(package, text)++ def test_the_two_boot_restored_packages_are_called_out(self):+ # Disabling them looks successful until the next boot, which is the whole point of the note.+ text = NOTE.read_text(encoding="utf-8")+ self.assertIn("com.google.android.tvrecommendations", text)+ self.assertIn("com.haier.launcher.haiermatrix", text)+ self.assertIn("com.at.factory.factorymanager", text)+ self.assertRegex(text, r"(?i)re-?enabled? (?:on|at) every\s+boot|come back on every\s+boot")++ def test_note_admits_it_is_not_a_tested_list(self):+ text = NOTE.read_text(encoding="utf-8")+ self.assertRegex(text, r"(?i)not\*\* a tested list|not a tested list")+ self.assertIn("several days", text)+ # A one-day report must not be indexed as an examples/ list.+ self.assertFalse(list((ROOT / "examples").glob("durabrand*")),+ "a same-day report does not belong in examples/")++ def test_note_keeps_the_input_panel_and_setupwraith_apart(self):+ text = NOTE.read_text(encoding="utf-8")+ self.assertIn("com.mediatek.wwtv.tvcenter", text)+ self.assertIn("INPUT_KEY_SERVICE", text)+ self.assertIn("com.google.android.tungsten.setupwraith", text)++ def test_recovery_sequence_is_in_order(self):+ text = NOTE.read_text(encoding="utf-8")+ block = text.split("```sh", 1)[1].split("```", 1)[0]+ steps = ["am start -n %s/.MainActivity" % FACTORY, "input keyevent 218",+ "tools/tv.py reboot", "hdmi_control_enabled 1"]+ positions = [block.find(step) for step in steps]+ self.assertNotIn(-1, positions, f"missing recovery step in {steps}")+ self.assertEqual(positions, sorted(positions), "recovery steps out of order")+ self.assertRegex(text, r"(?i)in front")++ def test_note_links_resolve(self):+ self.assertEqual(broken_links(NOTE), [])+++class TroubleshootingTrapTest(unittest.TestCase):+ def setUp(self):+ self.text = TROUBLE.read_text(encoding="utf-8")+ self.trap = bullet(self.text, "- **The Input key and CEC die")++ def test_trap_names_the_cause_and_the_damage(self):+ for token in (FACTORY, "customer_factory_mode", "vendor.mtk.factory.disable.input",+ "fdata.ini", "HDMI-CEC", "issues/470",+ "com.google.android.katniss", "com.google.android.apps.mediashell"):+ with self.subTest(token=token):+ self.assertIn(token, self.trap)++ def test_trap_explains_the_reboot_failure_and_the_shell_limit(self):+ self.assertRegex(self.trap, r"(?i)refused")+ self.assertIn("factorymanager", self.trap)++ def test_trap_has_the_way_out(self):+ for command in (f"com.cvte.tv.hkcfac/.MainActivity", "input keyevent 218",+ "tools/tv.py reboot", "hdmi_control_enabled 1"):+ with self.subTest(command=command):+ self.assertIn(command, self.trap)+ self.assertLess(self.trap.find("am start"), self.trap.find("keyevent 218"))++ def test_trap_points_at_the_device_note_and_that_link_works(self):+ self.assertIn("devices/durabrand-durat32isdb.md", self.trap)+ self.assertEqual(broken_links(TROUBLE), [])++ def test_trap_does_not_look_like_the_setupwraith_credentials_case(self):+ # The reader must not go re-enable the setup wizard for a stuck Input key.+ self.assertNotIn("CastInfoProvider", self.trap)+++class IndexAndPromptTest(unittest.TestCase):+ def test_examples_readme_lists_the_note(self):+ text = EXAMPLES_README.read_text(encoding="utf-8")+ section = text.split("Notes for models that have no tested list yet", 1)[1]+ self.assertIn("docs/devices/durabrand-durat32isdb.md", section)+ self.assertIn("DURAT32ISDB", section)+ self.assertEqual(broken_links(EXAMPLES_README), [])++ def test_prompt_tells_the_assistant_not_to_open_factory_menus(self):+ text = PROMPT.read_text(encoding="utf-8")+ lines = text.split("\n")+ starts = [i for i, line in enumerate(lines)+ if line.startswith("- ") and "factory" in line.lower()]+ self.assertTrue(starts, "PROMPT.md has no line about factory menus")+ warn = []+ for start in starts:+ for line in lines[start:]:+ if warn and (line.startswith("- ") or line.startswith("## ") or not line.strip()):+ break+ warn.append(line)+ joined = " ".join(warn)+ self.assertIn("dumpsys package", joined)+ self.assertIn("TROUBLESHOOTING", joined)+ self.assertIn(FACTORY, joined)+++if __name__ == "__main__":+ unittest.main()