Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
Install scripts: only disable a stock launcher we recognise, detect it on Windows too
Gathin23ed06e6d6a14f
diff --git a/launcher/build-and-install.ps1 b/launcher/build-and-install.ps1index 41cf56ace..749a9c9b6 100644--- a/launcher/build-and-install.ps1+++ b/launcher/build-and-install.ps1@@ -2,12 +2,13 @@# default home screen. Uses Android Studio's bundled JDK and the default SDK location unless# JAVA_HOME / ANDROID_HOME are set.#-# Usage: launcher\build-and-install.ps1 -TvHost 192.168.1.50 [-StockLauncher com.google.android.tvlauncher]+# Usage: launcher\build-and-install.ps1 -TvHost 192.168.1.50 [-StockLauncher <package>|none]+# The stock launcher is detected from the TV when -StockLauncher is not given.# [-InputKeyService] remote's Input button opens the input switcher (Google TV); re-pass on every install# [-HomeKeyService] remotes whose Home button sends KEYCODE_ALL_APPS (Xiaomi sticks)param([string]$TvHost = $env:TV_HOST,- [string]$StockLauncher = 'com.google.android.tvlauncher',+ [string]$StockLauncher = '',[switch]$InputKeyService,[switch]$HomeKeyService)@@ -33,6 +34,20 @@ if (-not (Test-Path local.properties)) {if ($LASTEXITCODE -ne 0) { throw 'Gradle build failed' }$py = '..\tools\venv\Scripts\python.exe'+# Which app owns Home differs by build; ask the TV, but only accept a launcher we recognise (the answer+# can also be Android's chooser "android", the setup wizard, or another third-party launcher).+$knownStock = @('com.google.android.tvlauncher', 'com.google.android.apps.tv.launcherx', 'com.google.android.leanbacklauncher')+if (-not $StockLauncher) {+ $homePkg = & $py -I ..\tools\tv.py 'cmd package resolve-activity --brief -a android.intent.action.MAIN -c android.intent.category.HOME' | Select-Object -Last 1+ if ($LASTEXITCODE -ne 0 -or -not $homePkg) { throw 'could not ask the TV which launcher owns Home; check -TvHost and the debugging prompt, or pass -StockLauncher <package>' }+ $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.' }+ 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"+$disableStock = if ($StockLauncher -eq 'none') { 'echo stock launcher left alone' } else { "pm disable-user --user 0 $StockLauncher" }+$apk = 'app\build\outputs\apk\release\app-release.apk'& $py -I ..\tools\b64push.py $apk /data/local/tmp/tvhome.apkif ($LASTEXITCODE -ne 0) { throw 'APK upload failed' }@@ -47,14 +62,14 @@ if ("$out" -match 'Error') { throw 'could not set the new launcher as home; the'pm grant com.gathin.tvhome android.permission.ACCESS_FINE_LOCATION 2>/dev/null; echo location-granted','cmd package compile -m speed -f com.gathin.tvhome',"am start -W -n com.gathin.tvhome/.MainActivity | grep -E '^(Status|Error)'",- "pm disable-user --user 0 $StockLauncher",+ $disableStock,'cmd package set-home-activity --user 0 com.gathin.tvhome/.MainActivity') | & $py -I ..\tools\tv.py --batch# Order matters, see build-and-install.sh: start the new launcher, disable the stock one, set the# preference last, then check where Home ended up and put the stock launcher back if it is not ours.$homeNow = (& $py -I ..\tools\tv.py 'cmd package resolve-activity --brief -c android.intent.category.HOME -a android.intent.action.MAIN' | Select-Object -Last 1).Trim()if ($homeNow -notlike 'com.gathin.tvhome/*') {- & $py -I ..\tools\tv.py "pm enable --user 0 $StockLauncher" | Out-Null+ if ($StockLauncher -ne 'none') { & $py -I ..\tools\tv.py "pm enable --user 0 $StockLauncher" | Out-Null }throw "Home resolves to '$homeNow', not to the new launcher; $StockLauncher was re-enabled. On Google TV this usually means com.google.android.tungsten.setupwraith also claims Home: add it to your debloat list (see README, Troubleshooting), apply it, then run this script again."}Write-Host "Home now resolves to $homeNow"diff --git a/launcher/build-and-install.sh b/launcher/build-and-install.shindex 8552d81d2..fc4a9d088 100755--- a/launcher/build-and-install.sh+++ b/launcher/build-and-install.sh@@ -13,16 +13,32 @@ PY=../tools/venv/bin/pythonexport MSYS_NO_PATHCONV=1# Which app owns Home differs by build (com.google.android.tvlauncher on Android TV,# com.google.android.apps.tv.launcherx on newer Google TV), so ask the TV instead of guessing.-# Ignore an answer of our own launcher, left over from a previous run of this script.+# Only a launcher we recognise is accepted: the answer can also be Android's chooser ("android"),+# the setup wizard, or another third-party launcher, none of which should be disabled by accident.+# Pass STOCK_LAUNCHER=<package> to name it yourself, or STOCK_LAUNCHER=none to disable nothing.+KNOWN_STOCK_LAUNCHERS="com.google.android.tvlauncher com.google.android.apps.tv.launcherx com.google.android.leanbacklauncher"if [ -z "${STOCK_LAUNCHER:-}" ]; then- STOCK_LAUNCHER=$("$PY" -I ../tools/tv.py \- 'cmd package resolve-activity --brief -a android.intent.action.MAIN -c android.intent.category.HOME' \- | tail -n 1 | cut -d/ -f1 || true)- case "$STOCK_LAUNCHER" in- com.gathin.tvhome | *[!a-zA-Z0-9._]* | "") STOCK_LAUNCHER=com.google.android.tvlauncher ;;+ HOME_PKG=$("$PY" -I ../tools/tv.py 'cmd package resolve-activity --brief -a android.intent.action.MAIN -c android.intent.category.HOME' \+ | tail -n 1 | tr -d '\r' | cut -d/ -f1) || {+ echo "ERROR: could not ask the TV which launcher owns Home. Check TV_HOST and the debugging prompt on the TV," >&2+ echo "or pass STOCK_LAUNCHER=<package> yourself." >&2; exit 1; }+ case " $KNOWN_STOCK_LAUNCHERS " in+ *" $HOME_PKG "*) STOCK_LAUNCHER=$HOME_PKG ;;+ *)+ if [ "$HOME_PKG" = com.gathin.tvhome ]; then+ STOCK_LAUNCHER=none; echo "Home already belongs to this launcher; nothing will be disabled."+ 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+ echo " com.google.android.tungsten.setupwraith = Google TV's setup wizard; see README, Troubleshooting" >&2+ echo " anything else = another launcher is the default" >&2+ echo "Run again with STOCK_LAUNCHER=<package to disable> or STOCK_LAUNCHER=none." >&2; exit 1+ fi ;;esac- echo "Stock launcher: $STOCK_LAUNCHER"fi+echo "Stock launcher: $STOCK_LAUNCHER"+if [ "$STOCK_LAUNCHER" = none ]; then DISABLE_STOCK="echo stock launcher left alone"+else DISABLE_STOCK="pm disable-user --user 0 $STOCK_LAUNCHER"; fiAPK=app/build/outputs/apk/release/app-release.apk"$PY" -I ../tools/b64push.py "$APK" /data/local/tmp/tvhome.apkprintf '%s\n' \@@ -31,7 +47,7 @@ printf '%s\n' \"pm grant com.gathin.tvhome android.permission.ACCESS_FINE_LOCATION 2>/dev/null; echo location-granted" \"cmd package compile -m speed -f com.gathin.tvhome" \"am start -W -n com.gathin.tvhome/.MainActivity | grep -E '^(Status|Error)'" \- "pm disable-user --user 0 $STOCK_LAUNCHER" \+ "$DISABLE_STOCK" \"cmd package set-home-activity --user 0 com.gathin.tvhome/.MainActivity" \| "$PY" -I ../tools/tv.py --batch# Order matters: the new launcher is started before the stock one is disabled, and the home@@ -43,7 +59,7 @@ HOME_NOW=$("$PY" -I ../tools/tv.py 'cmd package resolve-activity --brief -c andrcase "$HOME_NOW" incom.gathin.tvhome/*) echo "Home now resolves to $HOME_NOW" ;;*)- "$PY" -I ../tools/tv.py "pm enable --user 0 $STOCK_LAUNCHER" >/dev/null || true+ [ "$STOCK_LAUNCHER" = none ] || "$PY" -I ../tools/tv.py "pm enable --user 0 $STOCK_LAUNCHER" >/dev/null || trueecho "ERROR: Home resolves to ${HOME_NOW:-nothing}, not to the new launcher; $STOCK_LAUNCHER was re-enabled." >&2echo "On Google TV this usually means com.google.android.tungsten.setupwraith also claims Home: add it to" >&2echo "your debloat list (see README, Troubleshooting), apply the list, then run this script again." >&2