Skip to content

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

tools: check.py refuses an installed launcher argument that answers no HOME activity, instead of drift --fix cannot clear

Mazin Kanugacb63efa96f31
diff --git a/tests/test_check_command_line.py b/tests/test_check_command_line.py
index 6a0d105d1..511f509ba 100644
--- a/tests/test_check_command_line.py
+++ b/tests/test_check_command_line.py
@@ -246,6 +246,53 @@ class CheckCommandLineTest(unittest.TestCase):
self.assertIn(f"nothing drifted: 2 listed packages are still disabled and Home is {LAUNCHERX}/",
result.stdout)
+ def test_an_installed_app_that_is_not_a_launcher_is_refused_not_drift(self):
+ # A typo that lands on another installed app: every weekly run reported drift no --fix could
+ # clear, and --fix itself stopped with exit 1, the code that means the TV drifted.
+ self.drifted_home(installed=["com.example.music", "com.example.store", STOCK, CUSTOM, LAUNCHERX,
+ "com.android.vending"])
+ for args in ((str(self.list_path), "com.android.vending"),
+ ("--fix", str(self.list_path), "com.android.vending")):
+ with self.subTest(args=args):
+ result = self.run_check(*args)
+ self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
+ self.assertIn(f"{args[-1]} is installed but", result.stderr)
+ self.assertIn("nothing was changed", result.stderr)
+ self.assertNotIn("drift", result.stdout)
+ self.assert_untouched(result)
+
+ def test_a_disabled_launcher_is_named_as_disabled(self):
+ # Disabled, its HOME activity is gone from the list: say how to turn it back on.
+ self.drifted_home(disabled=["com.example.music", "com.example.store", STOCK, CUSTOM],
+ home_activities=[f"{LAUNCHERX}/.home.HomeActivity"])
+ result = self.run_check(str(self.list_path), CUSTOM)
+ self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
+ self.assertIn(f"{CUSTOM} is installed but disabled", result.stderr)
+ self.assertIn(f"pm enable --user 0 {CUSTOM}", result.stderr)
+ self.assert_untouched(result)
+
+ def test_a_package_whose_only_home_is_a_fallback_is_refused(self):
+ # A vendor FallbackHome answers HOME but is a placeholder, not a launcher (#435).
+ vendor = "com.tcl.keycustomfunctionservice"
+ self.drifted_home(installed=["com.example.music", "com.example.store", STOCK, CUSTOM,
+ LAUNCHERX, vendor],
+ home_activities=[f"{LAUNCHERX}/.home.HomeActivity", f"{CUSTOM}/.MainActivity",
+ f"{vendor}/.FallbackHome"])
+ result = self.run_check(str(self.list_path), vendor)
+ self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
+ self.assertIn(f"{vendor} is installed but answers no HOME activity", result.stderr)
+ self.assert_untouched(result)
+
+ def test_a_tv_that_lists_no_real_home_activity_keeps_the_old_check(self):
+ # No working `cmd`, or a TV still locked after a reboot that lists only its FallbackHome
+ # placeholder: nothing to judge by, so the named launcher is taken on trust.
+ for claims in ([], ["com.android.tv.settings/.system.FallbackHome"]):
+ with self.subTest(claims=claims):
+ self.drifted_home(home_activities=claims)
+ result = self.run_check(str(self.list_path), CUSTOM)
+ self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
+ self.assertIn(f"Home is {LAUNCHERX}/.home.HomeActivity, not {CUSTOM}", result.stdout)
+
def test_a_tv_that_answers_no_packages_is_not_drift(self):
self.tv(installed=[], disabled=[])
result = self.run_check(str(self.list_path))
diff --git a/tools/check.py b/tools/check.py
index f4e949ba9..2aa44cb87 100644
--- a/tools/check.py
+++ b/tools/check.py
@@ -25,10 +25,11 @@ Exit codes: 0 in sync (or fixed), 1 drift, an incomplete fix, or packages a safe
2 the TV or the list could not be read, which includes ADB timing out or failing partway (after which
a --fix may be partial, and the next check says what is left), a run with no TV_HOST set or no ADB
client to read the TV with, or the command line asked for something this script does not do, which
-includes naming a launcher the TV does not have. That last one matters: README.md tells an owner to
+includes naming a launcher the TV does not have: not installed, or installed with no HOME activity
+(a disabled launcher, or an app that is not one). That last one matters: README.md tells an owner to
run this from a weekly job and hear about it on exit 1, so a mistyped flag must not come back as
-drift, nor a mistyped launcher as "nothing drifted". A recovery record --fix cannot read or update is
-2 as well, with nothing changed on the TV.
+drift, nor a mistyped launcher as "nothing drifted" or as drift no --fix can clear. A recovery record
+--fix cannot read or update is 2 as well, with nothing changed on the TV.
"""
import os
import re
@@ -434,6 +435,23 @@ def main():
f"against it; there is no report and nothing was changed. Check the "
f"package name of the launcher Home should be on, and run this again.\n")
return 2
+ if preferred:
+ # Installed is not enough: a typo that lands on another app (com.android.vending) made
+ # every run report Home drift that no --fix could clear, and --fix then stopped in
+ # launcher_to_use with exit 1. Judged only when the TV listed a real HOME activity: a
+ # firmware without a working `cmd` lists none, and one still locked after a reboot lists
+ # only its FallbackHome placeholders, and then nothing can be told apart.
+ claims = [c for c in home_activities(dev) if not FALLBACK_HOME_RE.search(c)]
+ if claims and not any(home_of(c) == preferred for c in claims):
+ if preferred in disabled:
+ why = (f"{preferred} is installed but disabled, so it answers no HOME activity: "
+ f"turn it back on (pm enable --user 0 {preferred}) or name the launcher "
+ f"Home should be on")
+ else:
+ why = (f"{preferred} is installed but answers no HOME activity on this TV, so "
+ f"Home cannot be checked against it: name the launcher Home should be on")
+ sys.stderr.write(f"{why}. There is no report and nothing was changed.\n")
+ return 2
code = report(list_path, listed, home, back_on, gone, home_drifted, expected)
if code and wanted:
# restore.sh puts back only what the recovery record holds, so before anything is disabled,