Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

tests: a list folder's README names a path this tree has, and the moor0 README's .sh

xbshengc569ac4d1131
diff --git a/docs/workflows/tv-list.md b/docs/workflows/tv-list.md
index e2dbda1ee..73c9db13e 100644
--- a/docs/workflows/tv-list.md
+++ b/docs/workflows/tv-list.md
@@ -33,7 +33,7 @@
are generated from every `tv.json` by `tools/gen_tables.py`, which a maintainer runs after merging; CI compares
them only on `main`.
6. A `README.md` for TV-specific notes and a `config.json` with the dock are welcome in the folder. Notes are
- free prose; two claims in a README are read back against the list beside it.
+ free prose; three things in a README are read back, two of them against the list beside it.
A package count ("The 38 packages that were disabled", "the debloat list disables 71 packages") is
compared with what `tools/disable.sh` would send for the list, so a line added or commented out later moves
the number in the README with it: `tests/test_example_list_count.py` answers
@@ -41,7 +41,12 @@
is the other: the restore command a README shows passes the same stock launcher as the list's own Undo line,
or none where the list passes none, because those two are where an owner looks for the way back and the copy
that passes a different package leaves the stock home disabled. `tests/test_folder_undo_agrees.py` names each
- difference (the Skyworth 7S60_A5 README passed the Coocaa home while its list passed nothing). That
+ difference (the Skyworth 7S60_A5 README passed the Coocaa home while its list passed nothing). The third is
+ a path from the repository root written in backticks, which is what a reader copies into a terminal: the
+ file `launcher/build-and-install.sh` with its suffix, never the bare name, and
+ `tests/test_example_readme_paths.py` reads every folder's README and names each path this tree does not have
+ (a Windows twin written with backslashes, a placeholder such as `examples/<your tv>/debloat.txt` and the
+ folders `.gitignore` lists are not read as paths). That
`config.json` takes only the keys `themes/README.md`'s Keys table says a theme can set: the rows it marks
`config.xml` only - the vendor settings screens, the icon tiles - are never read out of a pushed file, so
`theme.sh` drops them without a word and the launcher keeps its own value. A set that needs one wants that
diff --git a/examples/xiaomi-mitv-moor0/README.md b/examples/xiaomi-mitv-moor0/README.md
index a6f9cbdb0..776c3c0cf 100644
--- a/examples/xiaomi-mitv-moor0/README.md
+++ b/examples/xiaomi-mitv-moor0/README.md
@@ -48,4 +48,4 @@ TV_HOST=<tv ip> tools/tv.py 'pm enable --user 0 <package>'
Both `com.duokan.factorytest` and `com.google.android.tungsten.setupwraith` are included in [`debloat.txt`](debloat.txt) so that `com.gathin.tvhome/.MainActivity` owns Home cleanly. On this unit all saved Wi-Fi networks belonged to `cname=android.uid.system:1000` (`dumpsys wifi | grep -o 'cname=[^ ]*'`); `tools/disable.sh` checks this automatically before disabling `setupwraith`.
- **Inputs & Live TV:** `com.mitv.livetv` owns `.input.SelectInputActivity` and `.tv.MainActivity`. [`config.json`](config.json) sets `"live_tv_package": "com.mitv.livetv"` and hides the duplicate tile from the grid (`"hidden_apps": ["com.mitv.livetv"]`). The launcher's **Inputs** pill lists HDMI 1–3 (with CEC/custom labels and connection state), AV, and Live TV via `com.mediatek.tvinput` and `com.mediatek.tv.service`.
- **Dock & wallpaper:** Edit [`config.json`](config.json) (`columns` and `dock_apps`), or place a `wallpaper.jpg` in this folder, and re-run `tools/theme.sh examples/xiaomi-mitv-moor0` (or hold OK on the Settings pill on the TV to reorder tiles or pick a wallpaper on-device).
-- **Remote buttons:** As on [`xiaomi-mitv-moor2`](../xiaomi-mitv-moor2/debloat.txt), once `launcherx` is disabled, if the physical Settings (`KEYCODE_SETTINGS`, 176), Input (`KEYCODE_TV_INPUT`, 178) or YouTube (`KEYCODE_BUTTON_3`, 190) buttons on the remote stop responding, pass `HOME_KEY_SERVICE=1 INPUT_KEY_SERVICE=1` (PowerShell: `-HomeKeyService -InputKeyService`) to `launcher/build-and-install`. Note that binding a key-filtering accessibility service on this MediaTek Google TV 11 platform makes a held Volume button step once per press instead of ramping continuously.
+- **Remote buttons:** As on [`xiaomi-mitv-moor2`](../xiaomi-mitv-moor2/debloat.txt), once `launcherx` is disabled, if the physical Settings (`KEYCODE_SETTINGS`, 176), Input (`KEYCODE_TV_INPUT`, 178) or YouTube (`KEYCODE_BUTTON_3`, 190) buttons on the remote stop responding, pass `HOME_KEY_SERVICE=1 INPUT_KEY_SERVICE=1` (PowerShell: `-HomeKeyService -InputKeyService`) to `launcher/build-and-install.sh`. Note that binding a key-filtering accessibility service on this MediaTek Google TV 11 platform makes a held Volume button step once per press instead of ramping continuously.
diff --git a/tests/test_example_readme_paths.py b/tests/test_example_readme_paths.py
new file mode 100644
index 000000000..a93b810b6
--- /dev/null
+++ b/tests/test_example_readme_paths.py
@@ -0,0 +1,150 @@
+"""A list folder's README names files this repository ships, and every one of them is there.
+
+`docs/workflows/tv-list.md` step 6 welcomes a `README.md` in a list folder and says two of its claims
+are read back against the list beside it (the package count and the undo). A path is the third, and
+nothing read it: `tests/test_markdown_links.py` walks the links in every page, and
+`tests/test_agents_md.py` walks the paths named in `AGENTS.md` and in `docs/workflows/*.md`, so a path
+written in backticks inside `examples/<folder>/README.md` - the page an owner with this exact set reads -
+was read by neither. `examples/xiaomi-mitv-moor0/README.md` passed the key helper to
+`launcher/build-and-install`, without the `.sh` the command at the top of the same page writes, and the
+file that keeps Home and the remote buttons working on that set was a name `bash` answers
+"No such file or directory" for.
+
+A path counts when it starts at the repository root, with one of the folders this repo ships: that is
+what makes it a claim about this tree rather than a file the owner has (`wallpaper.jpg` beside their
+config.json), a Windows twin written with backslashes, a placeholder (`examples/<your tv>/debloat.txt`,
+`$TV_HOST`), or an Android component (`com.gathin.tvhome/.MainActivity`). Backticks inside a fenced block
+are read too, since a path written that way is a command either way; the fence's own lines are not walked
+as commands, because one there can name a folder the reader makes (`themes/mine`), which is not a claim
+about this tree. Folders `.gitignore` names are skipped the way `tests/test_agents_md.py` skips them, so
+the venv a clone builds (`tools/venv/bin/python`) is not read as a missing file.
+
+Run from the repository root: python3 -m unittest discover -s tests -v
+"""
+import re
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+from test_agents_md import ignored_prefixes # noqa: E402 (the .gitignore folders both walks skip)
+
+ROOT = Path(__file__).resolve().parents[1]
+EXAMPLES = ROOT / "examples"
+
+# The folders a path has to start with to be about this checkout. `examples/README.md` and the docs
+# pages are read elsewhere; this is the folder README half.
+ANCHORED = ("tools/", "docs/", "examples/", "themes/", "addons/", "tests/", "launcher/", ".github/")
+CODE = re.compile(r"(`+)(.+?)\1")
+FENCE = re.compile(r"`{3,}") # the ``` that open and close a command block
+PLACEHOLDER = re.compile(r"[<>*{}$%]") # <your tv>, examples/<brand>-<model>/, $TV_HOST, a trailing %2F
+
+
+def named_paths(body):
+ """Every repository path a README writes in backticks, in page order.
+
+ Fence markers are dropped first, so a backticked path inside a command block is read like any other;
+ the fence's own lines are not walked as commands, because a command there can name a folder the reader
+ makes (`cp -r themes/aurora themes/mine`), which is not a claim about this tree.
+ """
+ found = []
+ for _, span in CODE.findall(FENCE.sub("", body)):
+ for word in span.split():
+ word = word.strip("'\"(),;:.`")
+ if not word or "\\" in word or PLACEHOLDER.search(word):
+ continue
+ if word.startswith(("~", "/", "-", "http")) or not word.startswith(ANCHORED):
+ continue
+ found.append(word)
+ return found
+
+
+def folder_readmes(root=ROOT):
+ """Every list folder README: examples/<folder>/README.md, at any depth a folder is listed at."""
+ examples = root / "examples"
+ return sorted(examples.glob("*/README.md")) + sorted(examples.glob("*/*/README.md"))
+
+
+def missing(root=ROOT):
+ """(readme, path) for each repository path a list folder's README names and this tree lacks."""
+ ignored = ignored_prefixes()
+ problems = []
+ for readme in folder_readmes(root):
+ for path in named_paths(readme.read_text(encoding="utf-8")):
+ if any(path == prefix or path.startswith(prefix + "/") for prefix in ignored):
+ continue
+ if not (root / path).exists():
+ problems.append((readme.relative_to(root).as_posix(), path))
+ return problems
+
+
+class TheFolderReadmesTest(unittest.TestCase):
+ def test_every_path_a_list_readme_names_exists(self):
+ problems = missing()
+ self.assertEqual([], problems, "a list folder's README names a path this tree does not have: "
+ + "; ".join(f"{readme} names {path}" for readme, path in problems))
+
+ def test_it_reads_the_folders(self):
+ # A walk that finds nothing would pass the test above for any tree.
+ readmes = folder_readmes()
+ self.assertGreaterEqual(len(readmes), 90, "the walk over examples/*/README.md read too few folders")
+ named = [path for readme in readmes for path in named_paths(readme.read_text(encoding="utf-8"))]
+ self.assertGreaterEqual(len(named), 250, "the walk read too few paths to be checking the folders")
+ self.assertIn("tools/disable.sh", named, "the walk no longer reads the command a list README gives")
+
+
+class TheReaderTest(unittest.TestCase):
+ def test_a_path_in_backticks_inside_a_fenced_block_is_read(self):
+ # A command block writes its paths in backticks for the reader to copy, so a fence is not a wall.
+ body = "```bash\nTV_HOST=<tv ip> `tools/disable.sh` `examples/demo-1/debloat.txt`\n```\n"
+ self.assertEqual(["tools/disable.sh", "examples/demo-1/debloat.txt"], named_paths(body))
+
+ def test_a_bare_word_in_a_fence_is_not_a_path(self):
+ # A fenced line can name a folder the reader makes, so only what the page puts in backticks is read.
+ self.assertEqual([], named_paths("```bash\ncp -r themes/aurora themes/mine\n```\n"))
+
+ def test_a_windows_twin_is_not_a_repository_path(self):
+ self.assertEqual([], named_paths("... -File `launcher\\build-and-install.ps1` -TvHost <tv ip>"))
+
+ def test_a_placeholder_is_not_a_path(self):
+ for body in ("`examples/<your tv>/debloat.txt`", "`$TV_IP`", "`examples/<brand>-<model>/`"):
+ with self.subTest(body=body):
+ self.assertEqual([], named_paths(body))
+
+ def test_an_android_component_is_not_a_path(self):
+ self.assertEqual([], named_paths("`com.gathin.tvhome/.MainActivity` and `setupwraith/.RecoveryActivity`"))
+
+ def test_a_path_this_repo_does_not_anchor_is_left_alone(self):
+ # The owner's own files, a URL and a plain word: none of them is a claim about this checkout.
+ self.assertEqual([], named_paths("`wallpaper.jpg` in this folder, `theme/config.json`, `https://x/y`"))
+
+ def test_trailing_punctuation_comes_off(self):
+ self.assertEqual(["tools/theme.sh"], named_paths("Re-run `tools/theme.sh`."))
+ self.assertEqual(["launcher/build-and-install.sh"], named_paths("(see `launcher/build-and-install.sh`),"))
+
+ def test_a_ghost_path_in_a_stand_in_tree_is_reported(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp)
+ (root / "examples" / "demo-1").mkdir(parents=True)
+ (root / "tools").mkdir()
+ (root / "tools" / "theme.sh").write_text("", encoding="utf-8")
+ (root / "examples" / "demo-1" / "README.md").write_text(
+ "Run `tools/theme.sh examples/demo-1` then `launcher/build-and-install`.\n", encoding="utf-8")
+ self.assertEqual([("examples/demo-1/README.md", "launcher/build-and-install")], missing(root))
+
+ def test_a_folder_gitignore_names_is_skipped(self):
+ # tools/venv is what a clone builds, and a list README that runs a command through it is right to:
+ # reading that path as a missing file would red the suite for every reader who has not built it yet.
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp)
+ (root / "examples" / "demo-1").mkdir(parents=True)
+ (root / "examples" / "demo-1" / "README.md").write_text(
+ "`tools/venv/bin/python -I tools/tv.py --probe`\n", encoding="utf-8")
+ self.assertEqual([("examples/demo-1/README.md", "tools/tv.py")],
+ [p for p in missing(root) if not p[1].startswith("tools/venv")])
+ self.assertIn("tools/venv", ignored_prefixes(), ".gitignore no longer names the venv this skips")
+
+
+if __name__ == "__main__":
+ unittest.main()