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 CVTE boot check says which component is direct-boot aware (#1350)
xbsheng96092b255b58
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex c0454b294..b34259145 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -317,7 +317,11 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/details). With file-based encryption (`getprop ro.crypto.type` says `file`) Android starts Home beforethe first unlock, and only a direct-boot-aware activity can start then. Most firmwares have a`FallbackHome` that stands in until the unlock; some, like this CVTE board, do not, and then boot- never completes. This repo's launcher is direct-boot-aware; most other launchers are not. Check both+ never completes. This repo's launcher is only partly direct-boot-aware: `HomeKeyService` declares+ the flag, so Android binds it while the user is still locked, and `MainActivity`, the activity that+ answers HOME, does not declare it. The second command below therefore prints+ `PARTIALLY_DIRECT_BOOT_AWARE` for this launcher and cannot say whether Home exists before the+ unlock; on a set with no `FallbackHome`, the first command is the one that decides. Check bothbefore disabling the stock launcher:```shtools/tv.py 'cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.HOME'@@ -328,9 +332,11 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/whose stock launcher declares a HOME priority it can print `Success` and change nothing, with the Homerole already naming the new launcher while Home still opens the stock one, so read the resolver instead(`tools/tv.py 'cmd package resolve-activity --brief -a android.intent.action.MAIN -c android.intent.category.HOME'`).- When it keeps naming the stock launcher, the set is debloat-only until someone runs these two checks on- that exact board (Thomson 40FG2S14W, Expressluck `nagata`, Android TV 14 `UKNV.260317.001`,- [notes](devices/thomson-40fg2s14w.md)).+ When it keeps naming the stock launcher, the set is debloat-only until a boot with the stock launcher+ disabled has been tried on that exact board. The two checks have been run on the Thomson 40FG2S14W+ (Expressluck `nagata`, Android TV 14 `UKNV.260317.001`) and both fallbacks are there, but that boot has+ not been tried ([notes](devices/thomson-40fg2s14w.md),+ [#1350](https://github.com/Gathin23/cleanyourtv/issues/1350)).- **Stuck on the boot animation after the launcher change, ADB gone** (JVC LT-43N7115, CVTE`TP.SK706S.PC822`, Android 11, [#741](https://github.com/Gathin23/cleanyourtv/discussions/741)): the stocklauncher `com.cvte.tv.launcher.space` was disabled and a remote-key helper enabled before one reboot.diff --git a/docs/devices/thomson-40fg2s14w.md b/docs/devices/thomson-40fg2s14w.mdindex fd4110851..9a7b33258 100644--- a/docs/devices/thomson-40fg2s14w.md+++ b/docs/devices/thomson-40fg2s14w.md@@ -1,6 +1,8 @@# Thomson 40FG2S14W (Expressluck `nagata`, CVTE board, Android TV 14): the launcher runs, Home stays with Google TV-One owner-reported ADB session on one unit ([#1035](https://github.com/Gathin23/cleanyourtv/issues/1035)). The+Two owner-reported ADB sessions on one unit: the first ([#1035](https://github.com/Gathin23/cleanyourtv/issues/1035))+installed and ran the launcher, the second ([#1350](https://github.com/Gathin23/cleanyourtv/issues/1350)) ran the+read-only boot checks below and changed nothing. Thereplacement launcher installed and opened, and its five-app dock and D-pad navigation worked. What did not workis Home: on this board Home stays with Google TV for as long as the stock launcher is enabled, which is thestate the CVTE rule asks for. This is **not a tested debloat list** - six privacy and feedback packages were@@ -31,10 +33,41 @@ profile either.tested profile that stock launcher stays enabled ([the JVC set that hung on its boot animation with ADBgone, #741](../TROUBLESHOOTING.md)), so `setupwraith` and the stock launcher were both re-enabled and Homewent back to Google TV.-- Not tried, and what the next session on this board would need: the `FallbackHome` and direct-boot-aware checks- in [TROUBLESHOOTING.md](../TROUBLESHOOTING.md) that decide whether the stock launcher can be disabled without- a boot that never finishes, and whether Home survives a reboot afterwards. Until someone runs them on this- exact board, treat the set as debloat-only.+- The two checks in [TROUBLESHOOTING.md](../TROUBLESHOOTING.md) that decide whether the stock launcher can be+ disabled without a boot that never finishes were run afterwards ([#1350](https://github.com/Gathin23/cleanyourtv/issues/1350),+ [below](#the-two-boot-checks-run-afterwards)). They answer the fallback half - this board has two - and not+ the Home-before-unlock half, and the boot itself has still not been tried on this board. Treat the set as+ debloat-only.++## The two boot checks, run afterwards++A later session on the same set ([#1350](https://github.com/Gathin23/cleanyourtv/issues/1350)) ran the two+read-only checks the [CVTE bullet](../TROUBLESHOOTING.md) asks for, and changed nothing on the TV: no fallback+was launched, the stock launcher was not disabled, and no handover was attempted.++`cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.HOME` answered+five HOME activities on this board:++| HOME activity | Priority |+|---|---|+| `com.google.android.apps.tv.launcherx/.home.HomeActivity` | 2 |+| `com.google.android.tungsten.setupwraith/.RecoveryActivity` | 1 |+| `com.gathin.tvhome/.MainActivity` | 0 |+| `com.express.at.factory.factorymanager/.FallbackHome` | -999 |+| `com.android.tv.settings/.system.FallbackHome` | -1000 |++So this board is not one of the sets without a fallback: the ODM's factory manager and the platform's+TvSettings each declare one. The stock launcher also carries the highest HOME priority of the five, which is+what the `set-home-activity` attempts above ran into.++`dumpsys package com.gathin.tvhome | grep -o "[A-Z_]*DIRECT_BOOT_AWARE"` printed+`PARTIALLY_DIRECT_BOOT_AWARE`, twice. That is the answer for the package, not for the activity Home starts+in: in the launcher's manifest `HomeKeyService` is the one component marked+`android:directBootAware="true"`, and `com.gathin.tvhome/.MainActivity` is not marked, so the line does not+say whether Home can start before the first unlock.++What that session leaves open is the boot the CVTE rule is about: with the stock launcher disabled, does this+set finish booting, and does Home survive the next reboot. Neither was tried, so the set stays debloat-only.## Disabled, and read back after a reboot@@ -53,7 +86,7 @@ above are the whole change; this note carries no list beyond them.## What this note does not establish-- One unit, one firmware, one session: no cold boot, no second reboot after the Home attempts, no screenshot,+- One unit, one firmware, two sessions: no cold boot, no reboot after the Home attempts, no screenshot,and no HDMI, Live TV, casting, voice or physical-remote check.- The Home result belongs to `UKNV.260317.001` on `nagata`. A board whose stock launcher is`com.cvte.tv.launcher.*`, or a later build, can hand Home over differently - and an owner-report on such a setdiff --git a/examples/README.md b/examples/README.mdindex 2a00d1df7..545706d38 100644--- a/examples/README.md+++ b/examples/README.md@@ -294,7 +294,7 @@ Notes for models that have no tested list yet live in [`docs/devices/`](../docs/- [TCL `75QM751G`](../docs/devices/tcl-75qm751g-qm7.md) (QM7, 2024, `G08`, Android 14 `UTT2.250416.001 AU14`): the QM6K list applies with seven extra packages, setupwraith owns the saved Wi-Fi even on an Ethernet set, and the Cast receiver can be up while it has stopped advertising.- [TVision Hub](../docs/devices/tvision-hub.md) (SEI Robotics, Amlogic S905X2, T-Mobile's Google TV dongle): one-session report with seven disabled packages and the launcher confirmed as Home; ADB only connected after a restart; no several-day list.- [Master-G 2K Smart TV](../docs/devices/master-g-2k-smart-tv.md) (KTC `jagalchi`, Chile, Google TV 14 `UKN4.250714.046`): a same-day session, not a several-day list; `set-home-activity` prints `Success` but `launcherx` keeps Home, `setupwraith`'s RecoveryActivity takes it next and owns the saved Wi-Fi until the network is re-joined; Android 14 ad/ML services and owner-chosen apps disabled, reboot-checked.-- [Thomson 40FG2S14W](../docs/devices/thomson-40fg2s14w.md) (Expressluck `nagata`, Android TV 14 `UKNV.260317.001`): six packages, reboot-checked; `com.cvte.tv.at` makes it a CVTE board, so its stock `launcherx` stays enabled and Home never leaves Google TV there - `set-home-activity` prints `Success`, the Home role names the new launcher, and `resolve-activity` still answers `launcherx` - and the note records the check that would have to pass first; debloat only, no tested list.+- [Thomson 40FG2S14W](../docs/devices/thomson-40fg2s14w.md) (Expressluck `nagata`, Android TV 14 `UKNV.260317.001`): six packages, reboot-checked; `com.cvte.tv.at` makes it a CVTE board, so its stock `launcherx` stays enabled and Home never leaves Google TV there - `set-home-activity` prints `Success`, the Home role names the new launcher, and `resolve-activity` still answers `launcherx` - the two boot checks have since been run on that board (#1350) and both fallbacks are there, but the boot with the stock launcher disabled has not been tried; debloat only, no tested list.- [JMGO G9S](../docs/devices/jmgo-g9s.md) (China, `m7642_JmGO_H7A0`, MediaTek m7642, Android TV 9 `1.1.52`): one-session seven-package set, the stock launcher `com.jmgo.launcher` deliberately left out because `com.jmgo.tv` (the HDMI input app) also answers HOME, and the `ro.adb.secure=0` / 5555 shutdown notes; no several-day list yet.- [Toshiba 55Z500QF (China, Hisense firmware)](../docs/devices/toshiba-55z500qf-cn.md) (`T963D4`, Amlogic `t5m`, Android 11 `RD2A.211001.002`, `07.02.70`, no GMS): no Developer options entry (owner opened it from a sideloaded helper APK), stock JuUI Home at `priority=50` handed over only when disabled as a package, `com.meetingroom` came back after both recorded reboots, the boot-source setting stopped Live TV taking the front; owner-reported removal history only, no tested list.- [Wanbo T6R Max](../docs/devices/wanbo-t6r-max.md) (projector, MediaTek MT5862, Android 9 `TVOS-04.16.031.01.12`): network ADB listens on port 5877, not 5555; Zeasn Whale launcher handed over with `STOCK_LAUNCHER=none`, nine packages disabled and reboot-checked in one session; no several-day list.diff --git a/tests/test_thomson_40fg2s14w_note.py b/tests/test_thomson_40fg2s14w_note.pyindex 6539d6bf9..bc0f3b803 100644--- a/tests/test_thomson_40fg2s14w_note.py+++ b/tests/test_thomson_40fg2s14w_note.py@@ -10,14 +10,18 @@ They assert identifiers and commands, not sentences, so rewording the prose doesRun from the repository root: python3 -m unittest discover -s tests -v"""import re-from pathlib import Pathimport unittest+import xml.etree.ElementTree as ET+from pathlib import PathROOT = Path(__file__).resolve().parents[1]NOTE = ROOT / "docs" / "devices" / "thomson-40fg2s14w.md"TROUBLE = ROOT / "docs" / "TROUBLESHOOTING.md"EXAMPLES_README = ROOT / "examples" / "README.md"DISABLE_SH = ROOT / "tools" / "disable.sh"+MANIFEST = ROOT / "launcher" / "app" / "src" / "main" / "AndroidManifest.xml"+GRADLE = ROOT / "launcher" / "app" / "build.gradle"+ANDROID = "{http://schemas.android.com/apk/res/android}"LAUNCHER = "com.gathin.tvhome"STOCK = "com.google.android.apps.tv.launcherx"@@ -35,6 +39,15 @@ DISABLED = [LINK = re.compile(r"\]\(([^)\s]+)\)")+# The five HOME activities #1350's query answered on this board, highest priority first.+HOME_ACTIVITIES = [+ "com.google.android.apps.tv.launcherx/.home.HomeActivity",+ "com.google.android.tungsten.setupwraith/.RecoveryActivity",+ "com.gathin.tvhome/.MainActivity",+ "com.express.at.factory.factorymanager/.FallbackHome",+ "com.android.tv.settings/.system.FallbackHome",+]+def bullet(text, start):"""The markdown bullet that begins with `start`, up to the next top-level bullet or heading."""@@ -63,6 +76,59 @@ def note_text():return NOTE.read_text(encoding="utf-8")+def cvte_bullet():+ """The bullet of docs/TROUBLESHOOTING.md that carries the FallbackHome and direct-boot checks."""+ return bullet(TROUBLE.read_text(encoding="utf-8"),+ "- **Black screen at every boot after the launcher change")+++def application_id():+ """The launcher's package name, what the manifest's `.MainActivity` expands to."""+ gradle = GRADLE.read_text(encoding="utf-8")+ match = re.search(r"launcherApplicationId'\)\.getOrElse\('([^']+)'\)", gradle)+ if match:+ return match.group(1)+ return re.search(r"namespace '([^']+)'", gradle).group(1)+++def manifest_components(text):+ """[(name, home, direct_boot_aware)] for every component of a manifest.++ `home` marks the component that `cmd package query-activities -c android.intent.category.HOME`+ answers with; `direct_boot_aware` is the component's flag, inherited from <application> when the+ component sets none. Nothing in the manifest is expanded, so names keep their leading dot.+ """+ root = ET.fromstring(text)+ application = root.find("application")+ if application is None:+ return []+ inherited = (application.get(ANDROID + "directBootAware") or "").lower() == "true"+ out = []+ for element in application:+ if element.tag not in ("activity", "service", "receiver", "provider"):+ continue+ flag = element.get(ANDROID + "directBootAware")+ aware = inherited if flag is None else flag.lower() == "true"+ home = any(+ "android.intent.action.MAIN" in {a.get(ANDROID + "name") for a in filter_.findall("action")}+ and "android.intent.category.HOME" in {c.get(ANDROID + "name") for c in filter_.findall("category")}+ for filter_ in element.findall("intent-filter"))+ out.append((element.get(ANDROID + "name") or "", home, aware))+ return out+++def recipe_commands():+ """The two boot checks the CVTE bullet hands a reader, with the package placeholder filled in.++ Read out of the bullet rather than copied, so a command the bullet changes has to be changed in+ the note as well; the backslash before a quote (the bullet escapes it for `grep -o`) is dropped.+ The resolver command in the same bullet is left out: the note's Home section already carries it.+ """+ commands = [command.replace("<new.launcher.package>", application_id()).replace("\\", "")+ for command in re.findall(r"tools/tv\.py '([^']+)'", cvte_bullet())]+ return [c for c in commands if "query-activities" in c or "DIRECT_BOOT_AWARE" in c]++class ThomsonNoteTest(unittest.TestCase):def test_note_exists_and_names_the_board(self):self.assertTrue(NOTE.is_file(), "docs/devices note missing")@@ -103,6 +169,100 @@ class ThomsonNoteTest(unittest.TestCase):def test_note_links_resolve(self):self.assertEqual(broken_links(NOTE), [])+ def test_note_records_the_two_boot_checks_and_what_they_answered(self):+ # The note's Home section sends the next session to the checks; #1350 ran them, so the note+ # has to carry the answers: the five HOME activities, the package-level direct-boot line and+ # the commands, as the bullet gives them.+ text = note_text()+ for command in recipe_commands():+ with self.subTest(command=command):+ self.assertIn(command, text, "the note must quote the check the bullet hands a reader")+ self.assertIn("PARTIALLY_DIRECT_BOOT_AWARE", text)+ for activity in HOME_ACTIVITIES:+ with self.subTest(activity=activity):+ self.assertIn(activity, text)++ def test_note_does_not_say_the_boot_was_tried(self):+ # What #1350 did was read-only: no fallback launched, no handover attempted. A note that+ # started handing the board over would need a run on the TV behind it.+ self.assertIsNone(re.search(r"pm disable-user[^\n]*" + re.escape(STOCK), note_text()))+ self.assertIn("not been tried", note_text())+++class DirectBootClaimTest(unittest.TestCase):+ """The CVTE bullet's claim about this launcher, against the manifest that has to back it.++ The bullet used to say "This repo's launcher is direct-boot-aware", which reads as "the Home+ activity can start before the first unlock". The manifest says otherwise: one service carries+ the flag, the activity that answers HOME does not, so the package-level dump answers PARTIALLY+ and cannot settle the question on a set with no FallbackHome.+ """++ def setUp(self):+ self.components = manifest_components(MANIFEST.read_text(encoding="utf-8"))+ self.home = [name for name, home, _ in self.components if home]+ self.aware = [name for name, _, aware in self.components if aware]++ def test_the_manifest_is_one_home_activity_a_second_component_marks_aware(self):+ # Both facts the corrected bullet rests on. If either changes, the bullet and the note have+ # to be read again rather than left describing a launcher that no longer exists.+ self.assertGreaterEqual(len(self.components), 8, "the manifest read as almost nothing")+ self.assertEqual(len(self.home), 1, "the launcher declares one HOME activity")+ self.assertTrue(self.aware, "no component declares directBootAware: the answer is not PARTIALLY")+ self.assertNotIn(self.home[0], self.aware,+ "the launcher's HOME activity now declares directBootAware: the CVTE bullet and "+ "docs/devices/thomson-40fg2s14w.md have to be updated with it")++ def test_the_bullet_names_the_component_that_carries_the_flag(self):+ cvte = cvte_bullet()+ for name in self.aware:+ with self.subTest(component=name):+ self.assertIn(name.lstrip("."), cvte.replace("`", ""),+ "the bullet must say which component is direct-boot aware")++ def test_the_bullet_names_the_home_activity_that_does_not(self):+ cvte = cvte_bullet().replace("`", "")+ self.assertIn(self.home[0].lstrip("."), cvte,+ "the bullet must name the Home activity it is talking about")+ self.assertIn("PARTIALLY_DIRECT_BOOT_AWARE", cvte,+ "the package-level answer has to be in the bullet, or a reader takes it as a yes")+++class ManifestReaderTest(unittest.TestCase):+ """`manifest_components()` must report a real problem, not pass by reading nothing."""++ PAGE = ('<?xml version="1.0" encoding="utf-8"?>\n'+ '<manifest xmlns:android="http://schemas.android.com/apk/res/android">\n'+ ' <application android:label="x">\n'+ ' <activity android:name=".Home" android:directBootAware="true">\n'+ ' <intent-filter>\n'+ ' <action android:name="android.intent.action.MAIN" />\n'+ ' <category android:name="android.intent.category.HOME" />\n'+ ' </intent-filter>\n'+ ' </activity>\n'+ ' <activity android:name=".Other">\n'+ ' <intent-filter>\n'+ ' <action android:name="android.intent.action.MAIN" />\n'+ ' <category android:name="android.intent.category.LEANBACK_LAUNCHER" />\n'+ ' </intent-filter>\n'+ ' </activity>\n'+ ' <service android:name=".Plain" />\n'+ ' </application>\n'+ '</manifest>\n')++ def test_reads_the_home_filter_and_the_flag(self):+ self.assertEqual(manifest_components(self.PAGE),+ [(".Home", True, True), (".Other", False, False), (".Plain", False, False)])++ def test_the_application_flag_is_inherited(self):+ page = self.PAGE.replace('<application android:label="x">',+ '<application android:label="x" android:directBootAware="true">')+ self.assertEqual([(name, aware) for name, _, aware in manifest_components(page)],+ [(".Home", True), (".Other", True), (".Plain", True)])++ def test_a_manifest_without_an_application_reads_as_empty(self):+ self.assertEqual(manifest_components('<manifest xmlns:android="http://schemas.android.com/apk/res/android" />'), [])+class TroubleshootingCvteBulletTest(unittest.TestCase):def setUp(self):