Skip to content

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

Launcher: build-and-install stops the instance restarted mid-update (#1101)

SiirGustav397a500a97d2
diff --git a/launcher/build-and-install.ps1 b/launcher/build-and-install.ps1
index 81a7fd843..6a094d027 100644
--- a/launcher/build-and-install.ps1
+++ b/launcher/build-and-install.ps1
@@ -65,6 +65,11 @@ if ($LASTEXITCODE -ne 0) { throw 'APK upload failed' }
$out = & $py -I ..\tools\tv.py 'pm install -r /data/local/tmp/tvhome.apk; rm -f /data/local/tmp/tvhome.apk'
Write-Host $out
if ("$out" -notmatch 'Success') { throw 'pm install failed; the stock launcher was left untouched' }
+# Stop the instance Android restarted mid-update, which can come up non-occluding (see build-and-install.sh,
+# #1101), and write back a key helper the force stop took off the list. Through stdin: Windows PowerShell 5.1
+# drops the inner double quotes from a native argument.
+'s=$(settings get secure enabled_accessibility_services); a=$(settings get secure accessibility_enabled); am force-stop com.gathin.tvhome; case "$s" in *com.gathin.tvhome*) settings put secure enabled_accessibility_services ""; settings put secure enabled_accessibility_services "$s"; settings put secure accessibility_enabled "$a" ;; esac' |
+ & $py -I ..\tools\tv.py --batch | Out-Null
# Android 9 only accepts a component here; Android 10+ also takes a bare package name.
$out = & $py -I ..\tools\tv.py 'cmd package set-home-activity --user 0 com.gathin.tvhome/.MainActivity'
Write-Host $out
diff --git a/launcher/build-and-install.sh b/launcher/build-and-install.sh
index 9c56b66d0..391d18dd8 100755
--- a/launcher/build-and-install.sh
+++ b/launcher/build-and-install.sh
@@ -103,6 +103,12 @@ case "$OUT" in
exit 1 ;;
*) echo "ERROR: pm install failed; the stock launcher was left untouched." >&2; exit 1 ;;
esac
+# Replacing the launcher while it is Home lets Android restart it mid-update, and on a TCL G03
+# (Android 11) that instance came up with mOccludesParent=false: Home then left the previous app or
+# HDMI picture on screen (#1101). `am start` below would only reuse it, so stop it first; the start
+# then creates a fresh one. A force stop also takes the key helpers off the enabled list, so a helper
+# that was on is written back (cleared first: Android binds again only when the list changes).
+"$PY" -I ../tools/tv.py 's=$(settings get secure enabled_accessibility_services); a=$(settings get secure accessibility_enabled); am force-stop com.gathin.tvhome; case "$s" in *com.gathin.tvhome*) settings put secure enabled_accessibility_services ""; settings put secure enabled_accessibility_services "$s"; settings put secure accessibility_enabled "$a" ;; esac' >/dev/null
# Start the launcher on its own, before the stock Home is touched. In the batch below a start that
# fails only prints an "Error:" line, and the stock launcher would be disabled anyway, leaving the TV
# with no usable Home (#239). "Status: ok" from `am start -W` means the activity really came up;