Skip to content

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

disable: a vendor FallbackHome is not a second launcher in the Home guard

Eddy Sangalli0e43620b1b1b
diff --git a/tests/test_home_guard.py b/tests/test_home_guard.py
index 722794026..7b8a11f7e 100644
--- a/tests/test_home_guard.py
+++ b/tests/test_home_guard.py
@@ -54,7 +54,7 @@ def answer(command):
if command.startswith("cmd package query-activities"):
if state["claims_fail"]:
sys.exit(1)
- return "".join(f" {name}/.MainActivity\n" for name in state["claims"])
+ return "".join(f" {c if '/' in c else c + '/.MainActivity'}\n" for c in state["claims"])
if command.startswith("cmd package resolve-activity"):
if state["home_fails"]:
sys.exit(1)
@@ -205,6 +205,21 @@ class HomeGuardTest(unittest.TestCase):
"the setup wizard is not a launcher to fall back on")
self.assertIn(f"Skipping {STOCK}", self.output(result))
+ def test_a_vendor_fallback_home_does_not_count_as_another_home(self):
+ # Android TV sets register a FallbackHome activity so the firmware has something to show when
+ # no launcher is enabled. It answers category.HOME, but it is not a home the viewer can use.
+ # Verified on a TCL BeyondTV2 (Android TV 9): com.tcl.keycustomfunctionservice/.FallbackHome
+ # and com.android.tv.settings/.system.FallbackHome both answer HOME.
+ for entry in self.entries():
+ with self.subTest(entry=entry):
+ self.tv(claims=[STOCK, "com.tcl.keycustomfunctionservice/.FallbackHome",
+ "com.android.tv.settings/.system.FallbackHome"])
+ result, sent = self.disable(entry)
+ self.assertEqual(result.returncode, 0, self.output(result))
+ self.assertNotIn(f"pm disable-user --user 0 {STOCK}", sent,
+ "a vendor fallback is not a launcher to fall back on")
+ self.assertIn(f"Skipping {STOCK}", self.output(result))
+
def test_a_tv_that_cannot_list_its_homes_is_left_with_one(self):
# tv.py fails or the TV answers nothing: the owner is the only Home this run knows about.
for entry in self.entries():
diff --git a/tools/disable.ps1 b/tools/disable.ps1
index 831fb41fe..0a409fa0b 100644
--- a/tools/disable.ps1
+++ b/tools/disable.ps1
@@ -58,7 +58,11 @@ if (-not $env:FORCE_HOME) {
# Every package with a HOME activity the TV can start now; a disabled one does not answer.
$claimQuery = 'cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.HOME'
$claims = @(& $py -I (Join-Path $repo 'tools\tv.py') $claimQuery | ForEach-Object {
- if ($_ -match '^\s*([A-Za-z0-9_.]+)/') { $Matches[1] }
+ # Keep the class: a vendor fallback is named FallbackHome and is not a usable launcher
+ # (TCL Android TV sets register com.tcl.keycustomfunctionservice/.FallbackHome).
+ if ($_ -match '^\s*([A-Za-z0-9_.]+)/([A-Za-z0-9_.$]+)$') {
+ if ($Matches[2] -notmatch 'FallbackHome$') { $Matches[1] }
+ }
} | Sort-Object -Unique)
# The setup wizard and the settings apps answer HOME too, but they are not launchers (disable.sh).
$notLaunchers = @('com.google.android.tungsten.setupwraith', 'com.android.tv.settings', 'com.android.settings', 'com.android.provision')
diff --git a/tools/disable.sh b/tools/disable.sh
index 8d8161f65..123ec4d07 100755
--- a/tools/disable.sh
+++ b/tools/disable.sh
@@ -66,12 +66,16 @@ if [ -n "$HOME_PKG" ] && printf '%s\n' "$PKGS" | grep -xF "$HOME_PKG" >/dev/null
# Every package with a HOME activity the TV can start now: disabled packages do not answer, so this
# is "what could take Home if the list went through".
CLAIMS=$("$PY" -I tools/tv.py 'cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.HOME' 2>/dev/null \
- | tr -d '\r' | grep -o '^ *[A-Za-z0-9_.]*/' | tr -d ' /' | sort -u || true)
+ | tr -d '\r' | grep -oE '^ *[A-Za-z0-9_.]+/[A-Za-z0-9_.$]+' | sed -E 's/^ +//' | sort -u || true)
# Nothing left to answer Home once the list is applied, or the TV could not say who does: either
# way the owner is the only Home this run knows about, so it stays enabled.
# The setup wizard and the settings apps answer HOME too, but they are not launchers: on Google TV,
# setupwraith taking Home is the crash loop this guard exists to prevent. They don't count.
- OTHERS=$(printf '%s\n' "$CLAIMS" | grep -vxF "$HOME_PKG" | grep -vxF "$PKGS" \
+ # A vendor's own fallback does not count either: TCL Android TV sets register
+ # com.tcl.keycustomfunctionservice/.FallbackHome (and com.android.tv.settings/.system.FallbackHome),
+ # a placeholder the firmware shows when no launcher is enabled, not a home the viewer can use.
+ OTHERS=$(printf '%s\n' "$CLAIMS" | grep -vE '/[^ ]*FallbackHome$' | cut -d/ -f1 | sort -u \
+ | grep -vxF "$HOME_PKG" | grep -vxF "$PKGS" \
| grep -vxF -e com.google.android.tungsten.setupwraith -e com.android.tv.settings -e com.android.settings -e com.android.provision || true)
if [ -z "$OTHERS" ]; then
echo "Skipping $HOME_PKG: it owns Home, and no other app that can answer Home is installed and" >&2