Skip to content

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

launcher: ask the TV which app owns Home instead of hardcoding it

Shradha451741a62f18
diff --git a/launcher/build-and-install.sh b/launcher/build-and-install.sh
index 9c9d2ed19..66d537252 100755
--- a/launcher/build-and-install.sh
+++ b/launcher/build-and-install.sh
@@ -3,7 +3,6 @@
set -euo pipefail
cd "$(dirname "$0")"
: "${TV_HOST:?set TV_HOST to the TV IP address, e.g. TV_HOST=192.168.1.50 $0}"
-STOCK_LAUNCHER="${STOCK_LAUNCHER:-com.google.android.tvlauncher}"
export JAVA_HOME="${JAVA_HOME:-$(/usr/libexec/java_home -v 17 2>/dev/null || echo /opt/homebrew/opt/openjdk@17)}"
export ANDROID_HOME="${ANDROID_HOME:-$([ -d ~/Library/Android/sdk ] && echo ~/Library/Android/sdk || echo /opt/homebrew/share/android-commandlinetools)}"
export PATH="$JAVA_HOME/bin:$PATH"
@@ -12,6 +11,18 @@ export PATH="$JAVA_HOME/bin:$PATH"
PY=../tools/venv/bin/python
[ -x "$PY" ] || PY=../tools/venv/Scripts/python.exe
export 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.
+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 ;;
+ esac
+ echo "Stock launcher: $STOCK_LAUNCHER"
+fi
APK=app/build/outputs/apk/debug/app-debug.apk
"$PY" -I ../tools/b64push.py "$APK" /data/local/tmp/tvhome.apk
printf '%s\n' \