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
tools: disable.sh matches package names by bytes under any locale (#3286)
Lokesh Navale2406368747e3
diff --git a/tests/test_disable_sh_locale.py b/tests/test_disable_sh_locale.pynew file mode 100644index 000000000..7de800185--- /dev/null+++ b/tests/test_disable_sh_locale.py@@ -0,0 +1,43 @@+"""tools/disable.sh matches package names by bytes, whatever the computer's locale (#3286).++In tr_TR.UTF-8 GNU grep 3.12 leaves i and I out of [A-Za-z], so disable.sh refused every package name+with an i in it, and its sed that reads the Live TV and Settings handlers matched nothing. The script+now sets LC_ALL=C before any of those checks.++Run from the repository root: python3 -m unittest discover -s tests -v+The behaviour case needs bash and skips on Windows and where tr_TR.UTF-8 is not generated.+"""+from pathlib import Path+import os+import subprocess+import sys+import tempfile+import unittest++ROOT = Path(__file__).resolve().parent.parent+SCRIPT = ROOT / "tools" / "disable.sh"+++class DisableShLocale(unittest.TestCase):+ def test_locale_is_pinned_before_the_first_name_check(self):+ lines = SCRIPT.read_text(encoding="utf-8").splitlines()+ pin = next(i for i, l in enumerate(lines) if l.strip() == "export LC_ALL=C")+ first = next(i for i, l in enumerate(lines) if "[A-Za-z" in l and not l.lstrip().startswith("#"))+ self.assertLess(pin, first)++ @unittest.skipIf(sys.platform == "win32", "needs bash and a POSIX locale")+ def test_turkish_locale_does_not_refuse_names_with_an_i(self):+ have = subprocess.run(["locale", "-a"], capture_output=True, text=True).stdout+ if "tr_TR.utf8" not in have.lower().replace("-", ""):+ self.skipTest("tr_TR.UTF-8 is not generated here")+ with tempfile.TemporaryDirectory() as tmp:+ lst = Path(tmp) / "debloat.txt"+ lst.write_text("com.google.android.katniss\n", encoding="utf-8")+ env = dict(os.environ, LC_ALL="tr_TR.UTF-8", LANG="tr_TR.UTF-8", TV_HOST="127.0.0.1")+ out = subprocess.run(["bash", str(SCRIPT), str(lst)], capture_output=True, text=True,+ env=env, timeout=60)+ self.assertNotIn("not a package name", out.stdout + out.stderr)+++if __name__ == "__main__":+ unittest.main()diff --git a/tools/disable.sh b/tools/disable.shindex 114e0bb5e..a6f51451c 100755--- a/tools/disable.sh+++ b/tools/disable.sh@@ -4,6 +4,10 @@## Usage: TV_HOST=192.168.1.50 tools/disable.sh examples/xiaomi-mi-tv-4a/debloat.txtset -euo pipefail+# The name checks below use ASCII ranges such as [A-Za-z]. In a Turkish locale GNU grep and sed leave+# i and I out of those ranges (dotted and dotless i), so every name with an i was refused and the+# Live TV and Settings handler lookups matched nothing (#3286). Match bytes, not the user's alphabet.+export LC_ALL=CLIST="${1:?usage: disable.sh <debloat list>}"# Resolve the list against the caller's directory before moving into the repo. Git Bash's pwd says# /c/Users/..., which the Windows Python cannot open with MSYS_NO_PATHCONV=1 set; pwd -W gives