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
examples, docs: <tv ip> instead of the contributors' own LAN addresses and a Windows user path
Mazin Kanuga139d2bf129f4
diff --git a/docs/REMOTE.md b/docs/REMOTE.mdindex bc1374151..204bbf634 100644--- a/docs/REMOTE.md+++ b/docs/REMOTE.md@@ -69,7 +69,7 @@ sudo tailscale set --advertise-routes=192.168.1.0/24```Approve the route in your admin console: Machines → the helper → Subnets → Edit. You then reach the-TV at its local address, e.g. `TV_HOST=192.168.1.40`.+TV at its local address, e.g. `TV_HOST=192.168.1.50`.**The two networks must not overlap.** If their home uses the same range as yours (both`192.168.1.x`, say), your computer can't tell their TV from a device at home. Use option A, ordiff --git a/docs/devices/coop-cotv-0001.md b/docs/devices/coop-cotv-0001.mdindex 21eebe476..dd3e32e2e 100644--- a/docs/devices/coop-cotv-0001.md+++ b/docs/devices/coop-cotv-0001.md@@ -29,8 +29,8 @@ re-applied the list in batches. That second half is why this note exists — the## How the set was reached-- Wi-Fi (192.168.18.3): port 5555 closed, `nmap -Pn -p 1-65535` found no open TCP port at all.-- Ethernet (192.168.18.32): 5555 open, and that is the only way in. `tools/tv.py` was used because no+- Wi-Fi: port 5555 closed, `nmap -Pn -p 1-65535` found no open TCP port at all.+- Ethernet: 5555 open, and that is the only way in. `tools/tv.py` was used because no`adb` binary was installed on the reporter's machine.- The first connection raised `ConnectionResetError`; a retry a few seconds later worked. The setseems to accept one ADB session at a time, so a failed connect is not the end of it.diff --git a/examples/anker-nebula-d2426/README.md b/examples/anker-nebula-d2426/README.mdindex 9a6d1b29c..73c647b9b 100644--- a/examples/anker-nebula-d2426/README.md+++ b/examples/anker-nebula-d2426/README.md@@ -8,7 +8,7 @@ All commands below run from the repository root. Replace the IP with the project(Settings > Network on the projector).```bash-export TV_HOST=192.168.68.51+export TV_HOST=192.168.1.50```## What was changed@@ -103,7 +103,7 @@ Settings > Device Preferences > Developer options > revoke USB debugging authoridebugging and USB debugging, restart, then check from the repo:```bash-tools/venv/bin/python tools/adb-closed.py 192.168.68.51+tools/venv/bin/python tools/adb-closed.py 192.168.1.50```Only "Connection refused" (exit 0) proves the port is closed; `nc` on macOS can be blocked by Local Networkdiff --git a/examples/anker-nebula-d2426/build-and-install.sh b/examples/anker-nebula-d2426/build-and-install.shindex 2642cb747..65711d978 100755--- a/examples/anker-nebula-d2426/build-and-install.sh+++ b/examples/anker-nebula-d2426/build-and-install.sh@@ -7,7 +7,7 @@# Needs: ADB on (Developer options > USB debugging, and network/Wireless debugging), JDK 17 or newer, the# Android SDK (Android Studio's default location is found), and tools/venv (see the main README).set -euo pipefail-: "${TV_HOST:?set TV_HOST to the projector IP, e.g. TV_HOST=192.168.68.51 $0}"+: "${TV_HOST:?set TV_HOST to the projector IP, e.g. TV_HOST=192.168.1.50 $0}"HERE="$(cd "$(dirname "$0")" && pwd)"ROOT="$(cd "$HERE/../.." && pwd)"export TV_HOSTdiff --git a/examples/anker-nebula-d2426/restore.sh b/examples/anker-nebula-d2426/restore.shindex 8475d8e36..4ad23017b 100755--- a/examples/anker-nebula-d2426/restore.sh+++ b/examples/anker-nebula-d2426/restore.sh@@ -8,7 +8,7 @@# disable, so anything that was already off stays off) and hands Home back to the stock launcher.# 2. Puts the Ambient screensaver back (it was com.google.android.backdrop/.Backdrop).set -euo pipefail-: "${TV_HOST:?set TV_HOST to the projector IP, e.g. TV_HOST=192.168.68.51 $0}"+: "${TV_HOST:?set TV_HOST to the projector IP, e.g. TV_HOST=192.168.1.50 $0}"HERE="$(cd "$(dirname "$0")" && pwd)"ROOT="$(cd "$HERE/../.." && pwd)"PY="$ROOT/tools/venv/bin/python"diff --git a/examples/philips-google-tv-ta7/README.md b/examples/philips-google-tv-ta7/README.mdindex e2273d716..a07c41dd2 100644--- a/examples/philips-google-tv-ta7/README.md+++ b/examples/philips-google-tv-ta7/README.md@@ -36,7 +36,7 @@ On the TV: Settings > Apps > See all apps > Show system apps (or "Disabled apps"Over ADB:```bash-TV_HOST=192.168.0.10 tools/venv/bin/python -I tools/tv.py 'pm enable --user 0 com.netflix.ninja'+TV_HOST=<tv ip> tools/venv/bin/python -I tools/tv.py 'pm enable --user 0 com.netflix.ninja'```Then delete or comment out its line in `debloat.txt`, so a later run doesn't disable it again. The@@ -55,7 +55,7 @@ Other package names: Globoplay `com.globo.globotv`, Disney+ `com.disney.disneypl`com.nousguide.android.rbtv` (all of them: `tools/tv.py 'pm list packages'`). Then push it; no rebuild:```bash-TV_HOST=192.168.0.10 tools/theme.sh examples/philips-google-tv-ta7/theme+TV_HOST=<tv ip> tools/theme.sh examples/philips-google-tv-ta7/theme```You can also reorder on the TV itself: hold OK on the Settings pill and choose the reorder option.@@ -72,7 +72,7 @@ again. All keys are in [themes/README.md](../../themes/README.md).## Undo everything```bash-TV_HOST=192.168.0.10 tools/restore.sh examples/philips-google-tv-ta7/debloat.txt com.google.android.apps.tv.launcherx+TV_HOST=<tv ip> tools/restore.sh examples/philips-google-tv-ta7/debloat.txt com.google.android.apps.tv.launcherx```This works from the state recorded before the first change (`~/.cleanyourtv/`). The apps that@@ -82,8 +82,8 @@ others listed at the top of `debloat.txt`) stay disabled. Re-enable them one by## Reinstall or update the launcher```bash-TV_HOST=192.168.0.10 STOCK_LAUNCHER=com.google.android.apps.tv.launcherx HOME_KEY_SERVICE=1 launcher/build-and-install.sh-TV_HOST=192.168.0.10 tools/theme.sh examples/philips-google-tv-ta7/theme+TV_HOST=<tv ip> STOCK_LAUNCHER=com.google.android.apps.tv.launcherx HOME_KEY_SERVICE=1 launcher/build-and-install.sh+TV_HOST=<tv ip> tools/theme.sh examples/philips-google-tv-ta7/theme```Needs JDK 17+ and the Android SDK (platform 34, build-tools 34). `HOME_KEY_SERVICE=1` keeps the@@ -94,4 +94,4 @@ gear-button fix on after a reinstall. Before the first install, check that the sPort 5555 is plaintext, so leave it off: Settings > System > Developer options > switch off USB debugging(and Wireless debugging if it is on), choose "Revoke USB debugging authorisations", then restart the TV.-From the PC, `nc -vz 192.168.0.10 5555` should then fail.+From the PC, `nc -vz <tv ip> 5555` should then fail.diff --git a/examples/skyworth-swtv-24ae-4k-nf/debloat.txt b/examples/skyworth-swtv-24ae-4k-nf/debloat.txtindex dc3d448c2..28556020e 100644--- a/examples/skyworth-swtv-24ae-4k-nf/debloat.txt+++ b/examples/skyworth-swtv-24ae-4k-nf/debloat.txt@@ -17,9 +17,9 @@## Quirks on this firmware, all verified on the TV:# - Only Wireless debugging: port 5555 stays closed. Pair once with the stock adb:-# adb pair 192.168.1.122:<pairing port> <code>-# adb connect 192.168.1.122:<connect port>-# adb -s 192.168.1.122:<connect port> tcpip 5555+# adb pair <tv ip>:<pairing port> <code>+# adb connect <tv ip>:<connect port>+# adb -s <tv ip>:<connect port> tcpip 5555# Port 5555 closes on every reboot; repeat `adb connect` + `adb tcpip 5555` each session.# - Android switches Wireless debugging off on every reboot; turn it back on in Developer options.# - All Wi-Fi networks owned by android.uid.system (not setupwraith) on this unit - safe to disable.diff --git a/examples/tcl-32l5a/README.md b/examples/tcl-32l5a/README.mdindex f99589a02..421071dc8 100644--- a/examples/tcl-32l5a/README.md+++ b/examples/tcl-32l5a/README.md@@ -50,7 +50,7 @@ python tools/tv.py "pm enable com.tcl.usercenter"### Restore All Debloated PackagesRun the restore script:```powershell-powershell -ExecutionPolicy Bypass -Command "$env:TV_HOST='192.168.1.3'; tools\restore.ps1 examples\tcl-32l5a\debloat.txt"+powershell -ExecutionPolicy Bypass -Command "$env:TV_HOST='<tv ip>'; tools\restore.ps1 examples\tcl-32l5a\debloat.txt"```---@@ -64,7 +64,7 @@ powershell -ExecutionPolicy Bypass -File launcher\build-and-install.ps1 -TvHostIf Gradle does not find a JDK 17, point `JAVA_HOME` at one first:```powershell-powershell -ExecutionPolicy Bypass -Command "$env:JAVA_HOME='C:\Users\Anas\.jdks\jbr-17.0.14'; $env:TV_HOST='192.168.1.3'; & 'launcher\build-and-install.ps1' -InputKeyService -HomeKeyService"+powershell -ExecutionPolicy Bypass -Command "$env:JAVA_HOME='<path to JDK 17>'; $env:TV_HOST='<tv ip>'; & 'launcher\build-and-install.ps1' -InputKeyService -HomeKeyService"```---diff --git a/tests/test_doc_addresses.py b/tests/test_doc_addresses.pynew file mode 100644index 000000000..b27046513--- /dev/null+++ b/tests/test_doc_addresses.py@@ -0,0 +1,116 @@+"""Pages and lists give `<tv ip>` or `192.168.1.50`, never the LAN address of the set they were written on.++AGENTS.md ("Hard rules") keeps IP addresses out of lists and docs, and CODE_OF_CONDUCT.md counts them as+private information. Five TV pages and lists, and the two scripts in one of those folders, still gave+the address of the contributor's own set, mostly in commands a reader pastes: the Philips TA7 Undo+among them, which a reader who pastes it unchanged points at another host. One page also gave a+Windows user name in a `JAVA_HOME` path, and docs/REMOTE.md an example address other than the one the+rule names. These tests keep the lists, the TV pages and the guides on the placeholders.++What is not a TV's address: a route such as `192.168.1.0/24` (the subnet a helper advertises in+docs/REMOTE.md). The add-on pages are not read: the address they show is the reader's own server+(Pi-hole, Home Assistant), given as an example.++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]+# Lists and TV pages, the guides and the themes; the top-level pages and tools/*.md are read too.+FOLDERS = ("examples", "docs", "themes")+SUFFIXES = (".md", ".txt", ".json", ".sh", ".ps1")+EXAMPLE = "192.168.1.50"++# An RFC 1918 IPv4 address, not part of a longer dotted number such as a firmware build; a full stop+# after it ends the sentence.+PRIVATE = re.compile(+ r"(?<![\w.])(?:192\.168|10\.\d{1,3}|172\.(?:1[6-9]|2\d|3[01]))\.\d{1,3}\.\d{1,3}(?!\d|\.\d)")+# A home folder with a person's name in it; `<user name>` and the shared folders are fine.+HOME_FOLDER = re.compile(+ r"(?:\b[A-Za-z]:[\\/]|(?<![\w.])/)Users[\\/](?!<|Shared\b|Public\b|Default\b)[^\\/\s'\"`]+")+++def pages(root):+ """Every page, list and script a reader copies a command from, in a stable order."""+ root = Path(root)+ found = [path for path in root.glob("*.md")]+ found += [path for path in (root / "tools").glob("*.md")]+ for folder in FOLDERS:+ found += [path for path in (root / folder).rglob("*")+ if path.is_file() and path.suffix in SUFFIXES]+ return sorted(found)+++def addresses(line):+ """The LAN addresses in one line that name a host, leaving out the example address and routes."""+ out = []+ for match in PRIVATE.finditer(line):+ if match.group(0) == EXAMPLE:+ continue+ if match.group(0).endswith(".0") and line[match.end():match.end() + 1] == "/":+ continue # a route: the network address with its prefix length+ out.append(match.group(0))+ return out+++def problems(root, find):+ """`path:line: what` for every match of `find` in the pages below root."""+ root = Path(root)+ out = []+ for path in pages(root):+ text = path.read_text(encoding="utf-8", errors="replace")+ for number, line in enumerate(text.split("\n"), 1):+ for what in find(line):+ out.append("%s:%d: %s" % (path.relative_to(root).as_posix(), number, what))+ return out+++class ReaderTest(unittest.TestCase):+ def test_a_tv_address_is_found(self):+ self.assertEqual(["192.168.7.21"], addresses("TV_HOST=192.168.7.21 tools/restore.sh x"))+ self.assertEqual(["10.0.0.37"], addresses("`adb connect 10.0.0.37:5555`"))+ self.assertEqual(["172.20.1.4"], addresses("$env:TV_HOST='172.20.1.4'"))+ self.assertEqual(["192.168.4.33"], addresses("adb pair 192.168.4.33:<pairing port> <code>"))+ self.assertEqual(["192.168.0.23"], addresses("The TV answered at 192.168.0.23."))+ self.assertEqual(["10.0.0.37"], addresses("then connect to 10.0.0.37..."))++ def test_the_example_address_routes_and_builds_are_not(self):+ self.assertEqual([], addresses("export TV_HOST=192.168.1.50"))+ self.assertEqual([], addresses("TV_HOST=192.168.1.50."))+ self.assertEqual([], addresses("tailscale set --advertise-routes=192.168.1.0/24"))+ self.assertEqual([], addresses("`--advertise-routes=10.0.0.0/8`"))+ self.assertEqual([], addresses("firmware V8-R851T02-LF1V310.10.0.1.2 build"))+ self.assertEqual([], addresses("build 10.0.0.1.5 of the firmware"))+ self.assertEqual([], addresses("Tailscale's DNS (100.100.100.100)"))+ self.assertEqual([], addresses("both `192.168.1.x`, say"))++ def test_a_home_folder_is_found_and_a_placeholder_is_not(self):+ self.assertTrue(HOME_FOLDER.search(r"$env:JAVA_HOME='C:\Users\Someone\.jdks\jbr-17'"))+ self.assertTrue(HOME_FOLDER.search("JAVA_HOME=/Users/someone/jdk17"))+ self.assertFalse(HOME_FOLDER.search("sdk.dir=C:/Users/<user name>/AppData/Local/Android/Sdk"))+ self.assertFalse(HOME_FOLDER.search(r"$env:JAVA_HOME='<path to JDK 17>'"))+ self.assertFalse(HOME_FOLDER.search("/Users/Shared/cleanyourtv"))+++class DocAddressesTest(unittest.TestCase):+ def test_pages_are_read(self):+ read = {path.relative_to(ROOT).as_posix() for path in pages(ROOT)}+ for page in ("README.md", "docs/REMOTE.md", "examples/philips-google-tv-ta7/README.md",+ "examples/skyworth-swtv-24ae-4k-nf/debloat.txt",+ "examples/anker-nebula-d2426/restore.sh"):+ self.assertIn(page, read)++ def test_no_page_gives_the_address_of_a_real_set(self):+ self.assertEqual([], problems(ROOT, addresses),+ "use <tv ip>, or %s where the page already gives an example address" % EXAMPLE)++ def test_no_page_gives_a_persons_home_folder(self):+ self.assertEqual([], problems(ROOT, lambda line: HOME_FOLDER.findall(line)),+ "use a placeholder such as <path to JDK 17> or <user name>")+++if __name__ == "__main__":+ unittest.main()