Skip to content

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

Install scripts: when Home is Android's chooser, pick the stock launcher among the HOME claimants

Gathin231fa7479ce38a
diff --git a/README.md b/README.md
index 4fb0d03e3..d49efe57e 100644
--- a/README.md
+++ b/README.md
@@ -187,7 +187,9 @@ TV_HOST=192.168.1.50 tools/restore.sh examples/<your tv>/debloat.txt com.google.
```
It leaves the new launcher installed (remove it from the TV's Settings → Apps if you want it gone)
-and does not know about packages you disabled outside the list. If the TV is unreachable, its own
+and does not know about packages you disabled outside the list. To switch back later, run the
+install script again; it works out which launcher to disable even when Home has fallen back to
+Android's chooser. If the TV is unreachable, its own
Settings → Apps page can re-enable packages too.
## When something goes wrong
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index 4f4331fbb..ff7c0f36a 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -77,3 +77,11 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/
If the clock then jumps an hour ahead in spring, a fixed offset keeps it right:
`tools/tv.py 'cmd alarm set-timezone GMT+03:30'`. The same applies to any country whose rules
changed after the firmware was built.
+- **The network pill says "Wi-Fi" instead of the network name** after `pm clear com.gathin.tvhome`
+ or a reinstall from scratch: clearing the launcher's data also drops the location permission
+ Android 10 needs to read the SSID. `pm grant com.gathin.tvhome android.permission.ACCESS_FINE_LOCATION`
+ (the install script does this).
+- **Home is "Select a Home app"** after `tools/restore.sh` followed by re-applying a list: disabling a
+ package that also claims HOME (PatchWall on Xiaomi) makes Android drop the default. The install
+ script now picks the known stock launcher among the candidates by itself; otherwise choose one on
+ the TV or pass `STOCK_LAUNCHER=<package>`.
diff --git a/launcher/build-and-install.ps1 b/launcher/build-and-install.ps1
index 749a9c9b6..a239c32d4 100644
--- a/launcher/build-and-install.ps1
+++ b/launcher/build-and-install.ps1
@@ -43,6 +43,14 @@ if (-not $StockLauncher) {
$homePkg = "$homePkg".Trim().Split('/')[0]
if ($knownStock -contains $homePkg) { $StockLauncher = $homePkg }
elseif ($homePkg -eq 'com.gathin.tvhome') { $StockLauncher = 'none'; Write-Host 'Home already belongs to this launcher; nothing will be disabled.' }
+ elseif ($homePkg -eq 'android') {
+ # Android's chooser: launchers tie and no default is set (a restore followed by a re-applied list
+ # ends here). Take the one known stock launcher among the HOME claimants, if there is exactly one.
+ $claimants = (& $py -I ..\tools\tv.py 'cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.HOME') -join "`n"
+ $found = @($knownStock | Where-Object { $claimants -match ([regex]::Escape($_) + '/') })
+ if ($found.Count -eq 1) { $StockLauncher = $found[0]; Write-Host "Home is Android's chooser; the stock launcher among the candidates is $StockLauncher." }
+ else { throw "Home is Android's launcher chooser and $($found.Count) known stock launchers claim Home: pick a default on the TV first, or run again with -StockLauncher <package to disable> or -StockLauncher none." }
+ }
else { throw "Home currently resolves to '$homePkg', which is not a stock launcher this script knows (android = launcher chooser, com.google.android.tungsten.setupwraith = setup wizard, see README Troubleshooting; anything else = another launcher is the default). Run again with -StockLauncher <package to disable> or -StockLauncher none." }
}
Write-Host "Stock launcher: $StockLauncher"
diff --git a/launcher/build-and-install.sh b/launcher/build-and-install.sh
index fc4a9d088..0d71a6e5c 100755
--- a/launcher/build-and-install.sh
+++ b/launcher/build-and-install.sh
@@ -27,6 +27,22 @@ if [ -z "${STOCK_LAUNCHER:-}" ]; then
*)
if [ "$HOME_PKG" = com.gathin.tvhome ]; then
STOCK_LAUNCHER=none; echo "Home already belongs to this launcher; nothing will be disabled."
+ elif [ "$HOME_PKG" = android ]; then
+ # Android's chooser: two or more launchers tie and no default is set, which is where a TV lands
+ # after tools/restore.sh followed by a re-applied list. Take the one known stock launcher among
+ # the HOME claimants, if there is exactly one.
+ CLAIMANTS=$("$PY" -I ../tools/tv.py 'cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.HOME' \
+ | tr -d '\r' | grep -o '[A-Za-z0-9_.]*/' | tr -d / | sort -u)
+ FOUND=""; N=0
+ for k in $KNOWN_STOCK_LAUNCHERS; do
+ if printf '%s\n' "$CLAIMANTS" | grep -qx "$k"; then FOUND=$k; N=$((N + 1)); fi
+ done
+ if [ "$N" -eq 1 ]; then
+ STOCK_LAUNCHER=$FOUND; echo "Home is Android's chooser; the stock launcher among the candidates is $STOCK_LAUNCHER."
+ else
+ echo "ERROR: Home is Android's launcher chooser and $N known stock launchers claim Home: pick a default on the TV first," >&2
+ echo "or run again with STOCK_LAUNCHER=<package to disable> or STOCK_LAUNCHER=none." >&2; exit 1
+ fi
else
echo "ERROR: Home currently resolves to '${HOME_PKG:-nothing}', which is not a stock launcher this script knows." >&2
echo " android = Android's launcher chooser (two launchers tie); pick a default on the TV first" >&2