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
Safety: the core-package guard covers AOSP's bare android.ext.services and android.ext.shared (#1711)
Gathin233667ef6f4b82
diff --git a/AGENTS.md b/AGENTS.mdindex 0ed123511..2be713f5b 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -23,7 +23,8 @@ this file repeats their rules in the form an agent needs, and links to them forthe input/source menu, remote and Bluetooth pairing, the on-screen keyboard, Play Store and PlayServices. When a package name says nothing, read `dumpsys package <name>`, then ask.- **Never disable Android's core packages:** the permission controller, package installer, ext- services/shared and module metadata (`com.android.*` and `com.google.android.*`),+ services/shared and module metadata (`com.android.*` and `com.google.android.*`; ext services/shared+ also as the bare `android.ext.services` and `android.ext.shared`),`com.google.android.overlay.modules*`, `com.android.providers.*` (calendar, contacts, user dictionaryand blocked numbers aside), `com.android.systemui`, `com.android.shell`, `com.android.phone`,`com.android.settings`, `com.android.tv.settings`, `android`. Without them Android may not boot (#884);diff --git a/PROMPT.md b/PROMPT.mdindex ca67da75e..49d4018cf 100644--- a/PROMPT.md+++ b/PROMPT.md@@ -80,7 +80,8 @@ Debloatstill unclear.- Never disable Android's own core packages, or the TV may not boot again: the permission controller,the package installer, ext services and ext shared, module metadata (each as `com.android.*` or- `com.google.android.*`), `com.google.android.overlay.modules*`, `com.android.providers.*` (calendar,+ `com.google.android.*`, and ext services and ext shared also as the bare `android.ext.services` and+ `android.ext.shared`), `com.google.android.overlay.modules*`, `com.android.providers.*` (calendar,contacts, user dictionary and blocked numbers aside), `com.android.systemui`, `com.android.shell`,`com.android.phone`, `com.android.settings`, `com.android.tv.settings` and `android`. An original Mi TVStick never booted again after a list took the first sixdiff --git a/tests/test_core_packages.py b/tests/test_core_packages.pyindex a1c2e62cd..0833eca9e 100644--- a/tests/test_core_packages.py+++ b/tests/test_core_packages.py@@ -5,6 +5,12 @@ installer, ext services/shared, module metadata and the mainline overlays, and tagain. tools/disable.sh, tools/disable.ps1 and tools/check.py --fix refuse such a list before the TV istouched, with no switch to override it, and no list in examples/ may name one of these packages.The pattern lives in three places (bash, PowerShell, Python); this test keeps them identical.++Ext services and ext shared also ship under AOSP's bare names, android.ext.services and+android.ext.shared, with no com.android. or com.google.android. in front: the package dumps from an OBE+R3 Ultra (Android 11), a CVTE SMART_TV (Android 12) and a MIBOX4 list both, installed and enabled (#1711).++The PowerShell case needs `pwsh` on PATH and skips without it; CI's Ubuntu runner has it."""import osfrom pathlib import Path@@ -31,6 +37,8 @@ CORE = ["com.android.settings", "com.android.tv.settings","com.android.providers.settings", "com.android.providers.tv", "com.android.providers.media","com.android.providers.downloads",+ # AOSP's bare names for the same two modules (#1711).+ "android.ext.services", "android.ext.shared",]# Look alike but are fine: what tested lists disable, and names that only share a prefix.NOT_CORE = [@@ -39,6 +47,7 @@ NOT_CORE = ["com.android.settings.intelligence", "com.android.tv.settings.overlay", "com.android.phone.extra","com.google.android.tungsten.setupwraith", "com.google.android.apps.tv.launcherx","com.android.shell2", "com.example.android.ext.services",+ "android.ext.services.overlay", "android.ext.sharedlib", "android.extservices",]@@ -90,7 +99,8 @@ class CorePackagesTest(unittest.TestCase):python.chmod(0o755)listing = Path(tmp) / "debloat.txt"listing.write_text("com.example.ads\ncom.google.android.permissioncontroller # no\n"- "com.google.android.overlay.modules.ext.services\n")+ "com.google.android.overlay.modules.ext.services\n"+ "android.ext.services\nandroid.ext.shared\n")env = dict(os.environ, TV_HOST="192.168.1.50", FORCE_HOME="1", FORCE_SETUPWRAITH="1",TVINPUT_ALLOW="1")result = subprocess.run(["bash", str(tools / "disable.sh"), str(listing)], cwd=repo, env=env,@@ -99,9 +109,55 @@ class CorePackagesTest(unittest.TestCase):self.assertIn("#884", result.stderr)self.assertIn("com.google.android.permissioncontroller", result.stderr)self.assertIn("com.google.android.overlay.modules.ext.services", result.stderr)+ self.assertIn(" android.ext.services\n", result.stderr)+ self.assertIn(" android.ext.shared\n", result.stderr)self.assertNotIn("com.example.ads", result.stderr)self.assertFalse(touched.exists(), "the TV was contacted before the refusal")+ def test_disable_ps1_refuses_the_bare_names_before_touching_the_tv(self):+ # The same refusal from the PowerShell twin, for the two names #1711 added. pwsh is not on+ # every contributor's machine, so this runs where it is (CI's Ubuntu runner).+ pwsh = shutil.which("pwsh")+ if not pwsh:+ raise unittest.SkipTest("disable.ps1 needs pwsh on PATH")+ with tempfile.TemporaryDirectory() as tmp:+ repo = Path(tmp) / "repo"+ tools = repo / "tools"+ tools.mkdir(parents=True)+ shutil.copy2(ROOT / "tools" / "disable.ps1", tools / "disable.ps1")+ touched = Path(tmp) / "touched"+ (tools / "tv.py").write_text(f"open({str(touched)!r}, 'a').write('x')\n")+ python = tools / "venv" / "Scripts" / "python.exe"+ python.parent.mkdir(parents=True)+ python.write_text(f'#!/bin/sh\nexec "{sys.executable}" "$@"\n')+ python.chmod(0o755)+ listing = Path(tmp) / "debloat.txt"+ listing.write_text("com.example.ads\nandroid.ext.services # no\nandroid.ext.shared\n")+ result = subprocess.run([pwsh, "-NoProfile", "-File", str(tools / "disable.ps1"),+ "-TvHost", "192.168.1.50", str(listing)], cwd=repo,+ capture_output=True, text=True, stdin=subprocess.DEVNULL, timeout=120)+ output = result.stdout + result.stderr+ self.assertNotEqual(0, result.returncode, output)+ # PowerShell's error view can wrap a long message at the console width, so the names are+ # looked for with every whitespace taken out.+ packed = re.sub(r"\s+", "", output)+ self.assertIn("#884", packed)+ self.assertIn("android.ext.services,android.ext.shared", packed)+ self.assertFalse(touched.exists(), "the TV was contacted before the refusal")++ def test_check_py_refuses_the_bare_names_before_connecting(self):+ with tempfile.TemporaryDirectory() as tmp:+ listing = Path(tmp) / "debloat.txt"+ listing.write_text("com.example.ads\nandroid.ext.services\nandroid.ext.shared\n")+ env = dict(os.environ, TV_HOST="192.0.2.1")+ result = subprocess.run([sys.executable, "-I", str(ROOT / "tools" / "check.py"), "--fix",+ str(listing)], env=env, capture_output=True, text=True,+ stdin=subprocess.DEVNULL, timeout=60)+ self.assertEqual(2, result.returncode, result.stdout + result.stderr)+ self.assertIn("#884", result.stderr)+ self.assertIn("android.ext.services, android.ext.shared", result.stderr)+ self.assertNotIn("could not reach", result.stderr)+def test_check_py_refuses_before_connecting(self):with tempfile.TemporaryDirectory() as tmp:listing = Path(tmp) / "debloat.txt"diff --git a/tools/disable.ps1 b/tools/disable.ps1index 568379e92..1f3fa91e6 100644--- a/tools/disable.ps1+++ b/tools/disable.ps1@@ -55,9 +55,10 @@ if (-not $pkgs -or $pkgs.Count -eq 0) {throw "refusing ${List}: no package names in it (every line is a comment or blank), so nothing was sent to the TV and no recovery record was written."}# Core Android packages, the same block as disable.sh: with one of these disabled Android itself can stop-# booting (#884, an original Mi TV Stick). No switch overrides it. Keep both patterns in step with-# disable.sh and recovery.py (tests/test_core_packages.py).-$coreRe = '^(android|com\.android\.systemui|com\.android\.shell|com\.android\.phone|com\.android\.settings|com\.android\.tv\.settings|com\.(google\.)?android\.(permissioncontroller|packageinstaller|ext\.services|ext\.shared|modulemetadata)|com\.google\.android\.overlay\.modules.*|com\.android\.providers\..*)$'+# booting (#884, an original Mi TV Stick). No switch overrides it. Ext services and ext shared also+# ship under AOSP's bare names, android.ext.services and android.ext.shared (#1711). Keep both+# patterns in step with disable.sh and recovery.py (tests/test_core_packages.py).+$coreRe = '^(android|android\.ext\.(services|shared)|com\.android\.systemui|com\.android\.shell|com\.android\.phone|com\.android\.settings|com\.android\.tv\.settings|com\.(google\.)?android\.(permissioncontroller|packageinstaller|ext\.services|ext\.shared|modulemetadata)|com\.google\.android\.overlay\.modules.*|com\.android\.providers\..*)$'$coreOk = '^com\.android\.providers\.(calendar|contacts|userdictionary|blockednumber)$'$core = @($pkgs | Where-Object { $_ -cmatch $coreRe -and $_ -cnotmatch $coreOk })if ($core.Count -gt 0) {diff --git a/tools/disable.sh b/tools/disable.shindex 6ca28dcaf..8e7fb9cd2 100755--- a/tools/disable.sh+++ b/tools/disable.sh@@ -57,8 +57,10 @@ fi# Stick never came back after a list took the permission controller, package installer, ext services,# module metadata and the mainline overlays (#884). No switch overrides this. The content providers# below CORE_OK are the exception: tested lists turn them off and no TV feature uses them.+# Some TVs ship ext services and ext shared under AOSP's bare names, android.ext.services and+# android.ext.shared, with no com.android. or com.google.android. in front (#1711).# Keep CORE_RE and CORE_OK the same in disable.ps1 and recovery.py (tests/test_core_packages.py).-CORE_RE='^(android|com\.android\.systemui|com\.android\.shell|com\.android\.phone|com\.android\.settings|com\.android\.tv\.settings|com\.(google\.)?android\.(permissioncontroller|packageinstaller|ext\.services|ext\.shared|modulemetadata)|com\.google\.android\.overlay\.modules.*|com\.android\.providers\..*)$'+CORE_RE='^(android|android\.ext\.(services|shared)|com\.android\.systemui|com\.android\.shell|com\.android\.phone|com\.android\.settings|com\.android\.tv\.settings|com\.(google\.)?android\.(permissioncontroller|packageinstaller|ext\.services|ext\.shared|modulemetadata)|com\.google\.android\.overlay\.modules.*|com\.android\.providers\..*)$'CORE_OK='^com\.android\.providers\.(calendar|contacts|userdictionary|blockednumber)$'CORE=$(printf '%s\n' "$PKGS" | grep -E "$CORE_RE" | grep -vE "$CORE_OK" || true)if [ -n "$CORE" ]; thendiff --git a/tools/recovery.py b/tools/recovery.pyindex 473fd5e55..ef6bf147f 100644--- a/tools/recovery.py+++ b/tools/recovery.py@@ -48,9 +48,11 @@ VERSION = 1# Core Android packages no list may disable: with one of these off, Android itself can stop booting# (#884: an original Mi TV Stick that lost its permission controller, package installer, ext services,# module metadata and mainline overlays never came back). The content providers in CORE_OK are the-# exception, since tested lists turn them off and no TV feature uses them. disable.sh and disable.ps1+# exception, since tested lists turn them off and no TV feature uses them. Ext services and ext shared+# also ship under AOSP's bare names, android.ext.services and android.ext.shared (#1711: an OBE R3+# Ultra, a CVTE SMART_TV and a MIBOX4 list them that way). disable.sh and disable.ps1# carry the same two patterns (tests/test_core_packages.py keeps the three in step).-CORE_RE = re.compile(r"^(android|com\.android\.systemui|com\.android\.shell|com\.android\.phone|com\.android\.settings|com\.android\.tv\.settings|com\.(google\.)?android\.(permissioncontroller|packageinstaller|ext\.services|ext\.shared|modulemetadata)|com\.google\.android\.overlay\.modules.*|com\.android\.providers\..*)$")+CORE_RE = re.compile(r"^(android|android\.ext\.(services|shared)|com\.android\.systemui|com\.android\.shell|com\.android\.phone|com\.android\.settings|com\.android\.tv\.settings|com\.(google\.)?android\.(permissioncontroller|packageinstaller|ext\.services|ext\.shared|modulemetadata)|com\.google\.android\.overlay\.modules.*|com\.android\.providers\..*)$")CORE_OK = re.compile(r"^com\.android\.providers\.(calendar|contacts|userdictionary|blockednumber)$")