Skip to content

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

examples: the hy320 folder describes the launcher and the undo this repo has

xbsheng359cbcfab97f
diff --git a/examples/hy320/README.md b/examples/hy320/README.md
index 109882f77..162552d19 100644
--- a/examples/hy320/README.md
+++ b/examples/hy320/README.md
@@ -19,14 +19,24 @@ TV_HOST=<tv ip> tools/venv/bin/python tools/tv.py 'pm enable --user 0 <package>'
## Restore everything (undo the debloat)
```sh
-TV_HOST=<tv ip> tools/restore.sh examples/hy320/debloat.txt
+TV_HOST=<tv ip> tools/restore.sh examples/hy320/debloat.txt com.htc.htclauncherhighenglishd08
```
+The stock launcher is passed because `tools/restore.sh` otherwise gives Home back to
+`com.google.android.tvlauncher`, the Android TV default, which this projector does not ship - so
+the set would come back from an undo with no Home at all.
## Rebuild and reinstall the launcher
```sh
cd launcher
JAVA_HOME=/opt/homebrew/opt/openjdk@17 ANDROID_HOME=/opt/homebrew/share/android-commandlinetools \
- TV_HOST=<tv ip> bash build-and-install.sh
+ TV_HOST=<tv ip> STOCK_LAUNCHER=none bash build-and-install.sh
+```
+`STOCK_LAUNCHER=none` because this set's stock launcher, `com.htc.htclauncherhighenglishd08`, is not
+one of the launchers `build-and-install.sh` recognises: without it the script stops at "not a stock
+launcher this script knows". Home is then set by hand, and the stock launcher stays as a fallback:
+
+```sh
+TV_HOST=<tv ip> tools/venv/bin/python tools/tv.py 'cmd package set-home-activity com.gathin.tvhome/.MainActivity'
```
## Change dock apps or order
@@ -43,9 +53,12 @@ AdGuard Private DNS works on this TV.
## Firmware note: HOME.JM
This projector's firmware routes the Home key through a custom `android.intent.category.HOME.JM`
-category (from the JM launcher that was preloaded). The launcher's AndroidManifest.xml was updated
-to include this category in its HOME intent filter. If you rebuild from a clean checkout, that
-change must be re-applied or the Home key will go to FallbackHome instead of the launcher.
+category, from the JM launcher that was preloaded. The launcher in this repository does not declare it:
+`MainActivity` answers `android.intent.category.HOME`, `DEFAULT` and `LEANBACK_LAUNCHER`, and
+`grep -rn HOME.JM launcher/` finds nothing - so from a clean checkout the Home key does not reach the
+launcher and lands on FallbackHome. The unit in this folder ran with a filter of its own added to the
+manifest, which is not in this repository; making such a filter part of the launcher is a change to the
+Home path and is open as #1799, and when it lands this note goes away.
## Security
This TV has `ro.adb.secure` unset, meaning port 5555 accepts any device on the network without
diff --git a/examples/hy320/debloat.txt b/examples/hy320/debloat.txt
index a4010bda3..cb97c2bb4 100644
--- a/examples/hy320/debloat.txt
+++ b/examples/hy320/debloat.txt
@@ -2,14 +2,16 @@
# Firmware be311-13 TQ2A.20250729 06:21:20.E1, 1280x720 panel, 213dpi.
#
# Apply: TV_HOST=<tv ip> tools/disable.sh examples/hy320/debloat.txt
-# Undo: TV_HOST=<tv ip> tools/restore.sh examples/hy320/debloat.txt
+# Undo: TV_HOST=<tv ip> tools/restore.sh examples/hy320/debloat.txt com.htc.htclauncherhighenglishd08
# Everything is DISABLED, not uninstalled. Comment out anything you use.
#
# Kept on purpose:
# - com.htc.htcsettings: projector's own settings (Wi-Fi, picture, keystone)
-# - com.htc.htclauncherhighenglishd08: stock launcher, disabled by build-and-install.sh after
-# the new launcher is installed and confirmed as Home. This firmware's Home key uses a custom
-# HOME.JM category; the launcher's manifest was updated to handle it.
+# - com.htc.htclauncherhighenglishd08: stock launcher, disabled during setup. build-and-install.sh does
+# not know it (it is not one of the stock launchers that script recognises), so run it with
+# STOCK_LAUNCHER=none and set Home with cmd package set-home-activity. This firmware's Home key also
+# carries a custom HOME.JM category, which the launcher in this repository does not declare: see the
+# folder README and #1799.
# - com.softwinner.tcorrection: projection/keystone settings
# - com.droidlogic.updater: firmware updater (kept enabled; firmware updaters are better left on)
# - com.droidlogic.tvinput: HDMI/input hardware layer (TV_INPUT_HARDWARE permission)
diff --git a/tests/test_hy320_folder.py b/tests/test_hy320_folder.py
new file mode 100644
index 000000000..f274cba1c
--- /dev/null
+++ b/tests/test_hy320_folder.py
@@ -0,0 +1,164 @@
+"""examples/hy320 describes a manifest change and an undo that are not this repository's.
+
+The folder records a projector whose Home key arrives as android.intent.category.HOME.JM, and it said
+the launcher's AndroidManifest.xml had been updated to accept that category. The manifest here declares
+android.intent.category.HOME on MainActivity and no HOME.JM, so that sentence described a build of the
+owner's own: an owner who follows the folder from a clean checkout does not get the filter at all, and
+the folder cannot be reproduced from this repository (#1799).
+
+Two smaller statements in the same folder are checked here too, because they are the other two places
+an owner is sent to a command that stops: the header said build-and-install.sh disabled the projector's
+stock launcher, which the script cannot do by itself - com.htc.htclauncherhighenglishd08 is not one of
+the launchers it recognises, so it stops at "not a stock launcher this script knows" unless
+STOCK_LAUNCHER is given - and the Undo line named no stock launcher, so restore.sh fell back to
+com.google.android.tvlauncher, the Android TV default this projector does not ship, leaving the stock
+Home off after an undo.
+"""
+import re
+import unittest
+from pathlib import Path
+
+
+ROOT = Path(__file__).resolve().parents[1]
+FOLDER = ROOT / "examples" / "hy320"
+MANIFEST = ROOT / "launcher" / "app" / "src" / "main" / "AndroidManifest.xml"
+INSTALL = ROOT / "launcher" / "build-and-install.sh"
+
+HOME_JM = "android.intent.category.HOME.JM"
+HOME = "android.intent.category.HOME"
+
+# An <intent-filter> is what makes an activity answer an intent; the categories of a <queries> block
+# (the one naming HOME there is stock_home_redirect's lookup) declare nothing about the launcher.
+FILTER = re.compile(r"<intent-filter\b[^>]*>(.*?)</intent-filter>", re.S)
+CATEGORY = re.compile(r'<category\s+android:name="([^"]+)"')
+KNOWN_LAUNCHERS = re.compile(r'^KNOWN_STOCK_LAUNCHERS="([^"]+)"', re.M)
+STOCK_BULLET = re.compile(r"^# - (\S+): stock launcher", re.M)
+
+
+def filter_categories(manifest_text):
+ """The categories the manifest's intent filters declare."""
+ names = set()
+ for block in FILTER.findall(manifest_text):
+ names.update(CATEGORY.findall(block))
+ return names
+
+
+def known_stock_launchers(script_text):
+ """The packages build-and-install.sh accepts as a stock launcher on its own."""
+ found = KNOWN_LAUNCHERS.search(script_text)
+ if not found:
+ raise ValueError("build-and-install.sh no longer declares KNOWN_STOCK_LAUNCHERS")
+ return found.group(1).split()
+
+
+def header_lines(text):
+ return [line for line in text.splitlines() if line.startswith("#")]
+
+
+def undo_arguments(text):
+ """The words after tools/restore.sh on the list's '# Undo:' line."""
+ for line in header_lines(text):
+ if line.startswith("# Undo:"):
+ words = line.split("# Undo:", 1)[1].split()
+ if "tools/restore.sh" not in words:
+ raise ValueError(f"the Undo line does not run tools/restore.sh: {line.strip()}")
+ return words[words.index("tools/restore.sh") + 1:]
+ raise ValueError("the list has no '# Undo:' line")
+
+
+def stock_launcher(text):
+ """The package the header's 'Kept on purpose' bullet calls the stock launcher."""
+ found = STOCK_BULLET.search("\n".join(header_lines(text)))
+ if not found:
+ raise ValueError("the header has no '# - <package>: stock launcher' bullet")
+ return found.group(1)
+
+
+class Hy320FolderTest(unittest.TestCase):
+ def setUp(self):
+ self.readme = (FOLDER / "README.md").read_text(encoding="utf-8")
+ self.list = (FOLDER / "debloat.txt").read_text(encoding="utf-8")
+ self.categories = filter_categories(MANIFEST.read_text(encoding="utf-8"))
+ # A reader that found nothing would let the comparisons below pass on any page.
+ self.assertIn(HOME, self.categories,
+ "MainActivity's HOME filter is the one this folder's Home key goes through")
+
+ def test_the_firmware_category_note_is_true_of_this_manifest(self):
+ declared = HOME_JM in self.categories
+ text = self.readme + "\n" + self.list
+ if declared:
+ # The filter is in the repository now, so the note that says it is missing has to go.
+ self.assertNotIn("#1799", text,
+ "the launcher declares HOME.JM now: drop the note that says it does not")
+ else:
+ self.assertIn("#1799", text,
+ "the folder has to say the launcher here does not declare HOME.JM (#1799)")
+ self.assertNotIn("manifest was updated", text,
+ "no HOME.JM filter was ever committed to launcher/AndroidManifest.xml")
+
+ def test_the_undo_line_passes_the_stock_launcher(self):
+ # restore.sh's default is com.google.android.tvlauncher; a set that does not ship it keeps its
+ # stock Home disabled after an undo unless the package is named (#1308 did this for five lists).
+ self.assertEqual(undo_arguments(self.list),
+ ["examples/hy320/debloat.txt", stock_launcher(self.list)])
+
+ def test_the_folder_says_the_install_script_does_not_know_its_stock_launcher(self):
+ stock = stock_launcher(self.list)
+ known = known_stock_launchers(INSTALL.read_text(encoding="utf-8"))
+ self.assertNotIn(stock, known,
+ f"{stock} is a launcher build-and-install.sh recognises now: the folder can "
+ f"stop telling the owner to pass STOCK_LAUNCHER")
+ for name, text in (("README.md", self.readme), ("debloat.txt", self.list)):
+ self.assertIn("STOCK_LAUNCHER=none", text,
+ f"{name} sends the owner to build-and-install.sh without saying that it "
+ f"refuses this set's stock launcher")
+
+
+class ReaderTest(unittest.TestCase):
+ def test_a_queries_entry_is_not_an_intent_filter(self):
+ manifest = ('<manifest><queries><intent>'
+ f'<category android:name="{HOME}" />'
+ '</intent></queries>'
+ '<application><activity><intent-filter>'
+ '<category android:name="android.intent.category.DEFAULT" />'
+ '</intent-filter></activity></application></manifest>')
+ self.assertEqual(filter_categories(manifest), {"android.intent.category.DEFAULT"})
+
+ def test_every_filter_category_is_read(self):
+ manifest = ('<intent-filter><category android:name="a.ONE" />'
+ '<category android:name="a.TWO" /></intent-filter>'
+ '<intent-filter><category android:name="a.TWO" />'
+ '<category android:name="a.THREE" /></intent-filter>')
+ self.assertEqual(filter_categories(manifest), {"a.ONE", "a.TWO", "a.THREE"})
+
+ def test_the_known_launchers_come_from_the_script(self):
+ self.assertEqual(known_stock_launchers('KNOWN_STOCK_LAUNCHERS="com.a com.b"\n'), ["com.a", "com.b"])
+ with self.assertRaises(ValueError):
+ known_stock_launchers("no such line\n")
+
+ def test_the_undo_arguments_skip_the_host_prefix(self):
+ # TV_HOST=<tv ip> holds a space, so the words before the script name cannot be counted.
+ text = ("# Apply: TV_HOST=<tv ip> tools/disable.sh examples/x/debloat.txt\n"
+ "# Undo: TV_HOST=<tv ip> tools/restore.sh examples/x/debloat.txt com.a.launcher\n")
+ self.assertEqual(undo_arguments(text), ["examples/x/debloat.txt", "com.a.launcher"])
+
+ def test_an_undo_line_without_a_launcher_reads_as_one_argument(self):
+ text = "# Undo: TV_HOST=<tv ip> tools/restore.sh examples/x/debloat.txt\n"
+ self.assertEqual(undo_arguments(text), ["examples/x/debloat.txt"])
+
+ def test_a_list_with_no_undo_line_is_refused(self):
+ with self.assertRaises(ValueError):
+ undo_arguments("# Apply: TV_HOST=<tv ip> tools/disable.sh examples/x/debloat.txt\n")
+
+ def test_the_stock_launcher_is_the_one_the_bullet_names(self):
+ header = ("# Kept on purpose:\n"
+ "# - com.htc.htcsettings: projector's own settings\n"
+ "# - com.htc.htclauncher: stock launcher, disabled during setup\n"
+ "# - com.softwinner.tcorrection: projection/keystone settings\n")
+ self.assertEqual(stock_launcher(header), "com.htc.htclauncher")
+ with self.assertRaises(ValueError):
+ stock_launcher("# - com.htc.htcsettings: projector's own settings\n")
+
+
+if __name__ == "__main__":
+ unittest.main()