Skip to content

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

philips-google-tv-ta7: add install and restore automation

Wesley Prado45aa71ec0e0f
diff --git a/examples/philips-google-tv-ta7/install.sh b/examples/philips-google-tv-ta7/install.sh
new file mode 100755
index 000000000..3c5fb72f0
--- /dev/null
+++ b/examples/philips-google-tv-ta7/install.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+# Build the launcher, install it on the Philips Google TV TA7 as Home and push this TV's theme.
+# Safe to run again after editing theme/config.json or the launcher source.
+# 1. disables the setup wizard (its RecoveryActivity otherwise takes Home), unless it owns a saved
+# Wi-Fi network: Android deletes that network when the wizard is disabled
+# 2. launcher/build-and-install.sh with HOME_KEY_SERVICE=1, so the remote's gear button opens
+# Settings; it disables the stock launcher on the first run
+# 3. tools/theme.sh with theme/ (dock order, greeting, hidden apps)
+#
+# Usage: TV_HOST=192.168.0.10 examples/philips-google-tv-ta7/install.sh
+# FORCE_SETUPWRAITH=1 skips the Wi-Fi check (the network the wizard owns is one you don't use)
+set -euo pipefail
+: "${TV_HOST:?set TV_HOST to the TV IP address, e.g. TV_HOST=192.168.0.10 $0}"
+export TV_HOST
+HERE="$(cd "$(dirname "$0")" && pwd)"
+ROOT="$(cd "$HERE/../.." && pwd)"
+PY="$ROOT/tools/venv/bin/python"
+[ -x "$PY" ] || { echo "run: python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements.txt" >&2; exit 1; }
+tv() { "$PY" -I "$ROOT/tools/tv.py" "$@"; }
+
+SETUP=com.google.android.tungsten.setupwraith
+if tv "pm list packages -e $SETUP" | grep -q "$SETUP"; then
+ if tv "dumpsys wifi" | grep -o 'cname=[^ ]*' | grep -q setupwraith && [ -z "${FORCE_SETUPWRAITH:-}" ]; then
+ echo "The setup wizard owns a saved Wi-Fi network, and disabling it deletes that network." >&2
+ echo "If that is the network the TV is on, forget it and join it again in Settings > Network first." >&2
+ echo "If it is an old network you don't use, run again with FORCE_SETUPWRAITH=1." >&2
+ exit 1
+ fi
+ tv "pm disable-user --user 0 $SETUP"
+fi
+
+# The stock launcher is disabled on the first run; later runs find Home already ours and leave it.
+STOCK=none
+if tv "pm list packages -e com.google.android.apps.tv.launcherx" | grep -q launcherx; then
+ STOCK=com.google.android.apps.tv.launcherx
+fi
+STOCK_LAUNCHER=$STOCK HOME_KEY_SERVICE=1 "$ROOT/launcher/build-and-install.sh"
+"$ROOT/tools/theme.sh" "$HERE/theme"
diff --git a/examples/philips-google-tv-ta7/restore.sh b/examples/philips-google-tv-ta7/restore.sh
new file mode 100755
index 000000000..b84f22d8a
--- /dev/null
+++ b/examples/philips-google-tv-ta7/restore.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# Undo everything done to the Philips Google TV TA7 from this folder, without needing the recovery
+# record that tools/disable.sh keeps in ~/.cleanyourtv (tools/restore.sh uses that one instead):
+# - switches off the launcher's HomeKeyService (the gear button fix)
+# - re-enables every package in debloat.txt, the stock launcher and setup wizard included
+# - gives Home back to the stock Google TV launcher
+# - puts Private DNS back to automatic (AdGuard off)
+# Packages the owner had disabled before (see the debloat.txt header) stay disabled.
+# UNINSTALL_LAUNCHER=1 also removes the new launcher (com.gathin.tvhome).
+#
+# Usage: TV_HOST=192.168.0.10 examples/philips-google-tv-ta7/restore.sh
+set -euo pipefail
+: "${TV_HOST:?set TV_HOST to the TV IP address, e.g. TV_HOST=192.168.0.10 $0}"
+HERE="$(cd "$(dirname "$0")" && pwd)"
+ROOT="$(cd "$HERE/../.." && pwd)"
+PY="$ROOT/tools/venv/bin/python"
+[ -x "$PY" ] || { echo "run: python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements.txt" >&2; exit 1; }
+STOCK=com.google.android.apps.tv.launcherx
+PKGS=$(grep -vE '^\s*(#|$)' "$HERE/debloat.txt" | sed -E 's/\s+#.*$//' | awk '{print $1}')
+
+# One command per line: tools/tv.py --batch runs each as its own shell call, so a failure in one
+# cannot silently skip the rest.
+{
+ echo "settings put secure enabled_accessibility_services \"\$(settings get secure enabled_accessibility_services | tr ':' '\n' | grep -v com.gathin.tvhome | paste -sd: -)\""
+ # The stock launcher and the setup wizard first, so Home has an owner before anything else changes.
+ echo "pm enable --user 0 com.google.android.tungsten.setupwraith"
+ echo "pm enable --user 0 $STOCK"
+ echo "cmd package set-home-activity --user 0 $STOCK/.home.HomeActivity"
+ printf '%s\n' "$PKGS" | grep -vxF -e "$STOCK" -e com.google.android.tungsten.setupwraith | sed 's/^/pm enable --user 0 /'
+ echo "settings put global private_dns_mode opportunistic"
+ if [ "${UNINSTALL_LAUNCHER:-0}" = 1 ]; then echo "pm uninstall com.gathin.tvhome"; fi
+ echo "cmd package resolve-activity --brief -a android.intent.action.MAIN -c android.intent.category.HOME"
+} | TV_HOST="$TV_HOST" "$PY" -I "$ROOT/tools/tv.py" --batch
+echo "Restored. Press Home on the remote: the stock Google TV home should come back."