Skip to content

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

addons: let Sleep Timer, TV Static and Photo screensaver auto-start on every TCL build

KhoeLe92bd4371ef77
diff --git a/addons/photo-screensaver/build-and-install.ps1 b/addons/photo-screensaver/build-and-install.ps1
index e56efa2f2..66964bc7a 100644
--- a/addons/photo-screensaver/build-and-install.ps1
+++ b/addons/photo-screensaver/build-and-install.ps1
@@ -34,5 +34,5 @@ $apk = Join-Path $here 'app\build\outputs\apk\release\app-release.apk'
if ($LASTEXITCODE) { throw 'sending the APK failed' }
Tv 'pm install -r /data/local/tmp/photodream.apk; rm -f /data/local/tmp/photodream.apk'
# TCL's TclAppBoot blocks the app's provider until it may auto-start; elsewhere the op doesn't exist.
-Tv "appops set $pkg APP_AUTO_START allow 2>/dev/null; appops write-settings 2>/dev/null; true" | Out-Null
+Tv "appops set $pkg AUTO_START allow 2>/dev/null; appops set $pkg APP_AUTO_START allow 2>/dev/null; appops write-settings 2>/dev/null; true" | Out-Null
Write-Host "Installed. Now: addons\photo-screensaver\sync.ps1 -TvHost $TvHost"
diff --git a/addons/photo-screensaver/build-and-install.sh b/addons/photo-screensaver/build-and-install.sh
index e637cc915..659a44d3e 100644
--- a/addons/photo-screensaver/build-and-install.sh
+++ b/addons/photo-screensaver/build-and-install.sh
@@ -26,5 +26,5 @@ fi
"$PY" -I "$TOOLS/b64push.py" "$HERE/app/build/outputs/apk/release/app-release.apk" /data/local/tmp/photodream.apk >/dev/null
tv "pm install -r /data/local/tmp/photodream.apk; rm -f /data/local/tmp/photodream.apk"
# TCL's TclAppBoot blocks the app's provider until it may auto-start; elsewhere the op doesn't exist.
-tv "appops set $PKG APP_AUTO_START allow 2>/dev/null; appops write-settings 2>/dev/null; true" >/dev/null
+tv "appops set $PKG AUTO_START allow 2>/dev/null; appops set $PKG APP_AUTO_START allow 2>/dev/null; appops write-settings 2>/dev/null; true" >/dev/null
echo "Installed. Now: TV_HOST=$TV_HOST addons/photo-screensaver/sync.sh"
diff --git a/addons/sleep-timer/README.md b/addons/sleep-timer/README.md
index 819deb1db..96aa102e1 100644
--- a/addons/sleep-timer/README.md
+++ b/addons/sleep-timer/README.md
@@ -47,6 +47,9 @@ it without waiting, the first lines of `build-and-install.sh` have an adb comman
app open its warning from the background when it holds this. The app draws no overlay window.
- **Exact alarms** (`SCHEDULE_EXACT_ALARM`), granted with `appops` where it exists (Android 12+), so the
timer fires on the minute; without it the alarm may come a few minutes late.
+- **Auto-start** (`AUTO_START` or `APP_AUTO_START`, TCL only), granted with `appops` and saved with
+ `appops write-settings`: TCL's TclAppBoot otherwise refuses to bind `SleepService` while the app is not
+ running, so the timer ends without putting the TV to standby. Other TVs do not have the op and ignore it.
- No network, no storage permission, no background service: between setting the timer and its end there are
two alarms and nothing running.
- **`AlarmReceiver`** is exported only to callers holding `WRITE_SECURE_SETTINGS`, which the adb shell has and
diff --git a/addons/sleep-timer/build-and-install.ps1 b/addons/sleep-timer/build-and-install.ps1
index 68143a47c..d8cbeea81 100644
--- a/addons/sleep-timer/build-and-install.ps1
+++ b/addons/sleep-timer/build-and-install.ps1
@@ -41,4 +41,6 @@ if ($LASTEXITCODE) { throw 'sending the APK failed; run this again' }
Tv 'pm install -r /data/local/tmp/sleeptimer.apk; rm -f /data/local/tmp/sleeptimer.apk'
Tv ('s=$(settings get secure enabled_accessibility_services); case :$s: in *:SVC:*) ;; *) if [ -z $s ] || [ $s = null ]; then s=SVC; else s=$s:SVC; fi; settings put secure enabled_accessibility_services $s;; esac; settings put secure accessibility_enabled 1'.Replace('SVC', $svc))
Tv "appops set $pkg SYSTEM_ALERT_WINDOW allow; appops set $pkg SCHEDULE_EXACT_ALARM allow 2>/dev/null; true"
+# TCL's TclAppBoot refuses to bind SleepService unless the app may auto-start; write-settings keeps it past a reboot.
+Tv "appops set $pkg AUTO_START allow 2>/dev/null; appops set $pkg APP_AUTO_START allow 2>/dev/null; appops write-settings 2>/dev/null; true" | Out-Null
Write-Host 'Installed. Pick a time on the Sleep Timer card.'
diff --git a/addons/sleep-timer/build-and-install.sh b/addons/sleep-timer/build-and-install.sh
index e0a4fb835..c653b37a3 100755
--- a/addons/sleep-timer/build-and-install.sh
+++ b/addons/sleep-timer/build-and-install.sh
@@ -32,4 +32,7 @@ tv "s=\$(settings get secure enabled_accessibility_services); case :\$s: in *:$S
# Android 10 and later only let an app open its warning from the background when it may draw over other apps;
# Android 12 and later need the exact-alarm grant for the timer to fire on the minute.
tv "appops set $PKG SYSTEM_ALERT_WINDOW allow; appops set $PKG SCHEDULE_EXACT_ALARM allow 2>/dev/null; true"
+# TCL's TclAppBoot refuses to bind SleepService while the app is not running unless it may auto-start (AUTO_START
+# on G08 builds, APP_AUTO_START on G10); elsewhere the op doesn't exist. write-settings saves it before the next reboot.
+tv "appops set $PKG AUTO_START allow 2>/dev/null; appops set $PKG APP_AUTO_START allow 2>/dev/null; appops write-settings 2>/dev/null; true" >/dev/null
echo "Installed. Pick a time on the Sleep Timer card."
diff --git a/addons/tv-static/build-and-install.ps1 b/addons/tv-static/build-and-install.ps1
index 29bbd9c48..f67130282 100644
--- a/addons/tv-static/build-and-install.ps1
+++ b/addons/tv-static/build-and-install.ps1
@@ -39,8 +39,9 @@ if ($LASTEXITCODE) { throw 'sending the APK failed; run this again' }
Tv 'pm install -r /data/local/tmp/tvstatic.apk; rm -f /data/local/tmp/tvstatic.apk'
# Android 10 and later let an app open a screen from the background only when it may draw over other apps.
Tv "appops set $pkg SYSTEM_ALERT_WINDOW allow"
-# TCL's TclAppBoot keeps apps from starting at boot unless they may auto-start; elsewhere the op doesn't exist.
-Tv "appops set $pkg APP_AUTO_START allow 2>/dev/null; true" | Out-Null
+# TCL's TclAppBoot keeps apps from starting at boot unless they may auto-start (AUTO_START on G08 builds,
+# APP_AUTO_START on G10); elsewhere the op doesn't exist. write-settings saves it before the next reboot.
+Tv "appops set $pkg AUTO_START allow 2>/dev/null; appops set $pkg APP_AUTO_START allow 2>/dev/null; appops write-settings 2>/dev/null; true" | Out-Null
# Starting the watcher once takes the app out of the stopped state, without which Android withholds BOOT_COMPLETED.
Tv "am start-foreground-service -n $pkg/.WatchService --ez play $(if ($NoPlay) { 'false' } else { 'true' })"
Write-Host 'Installed. The static plays whenever the screen turns on; its settings are on the TV Static card.'
diff --git a/addons/tv-static/build-and-install.sh b/addons/tv-static/build-and-install.sh
index e690496cb..c0b71ce81 100755
--- a/addons/tv-static/build-and-install.sh
+++ b/addons/tv-static/build-and-install.sh
@@ -28,8 +28,9 @@ PLAY=true
tv "pm install -r /data/local/tmp/tvstatic.apk; rm -f /data/local/tmp/tvstatic.apk"
# Android 10 and later let an app open a screen from the background only when it may draw over other apps.
tv "appops set $PKG SYSTEM_ALERT_WINDOW allow"
-# TCL's TclAppBoot keeps apps from starting at boot unless they may auto-start; elsewhere the op doesn't exist.
-tv "appops set $PKG APP_AUTO_START allow 2>/dev/null; true" >/dev/null
+# TCL's TclAppBoot keeps apps from starting at boot unless they may auto-start (AUTO_START on G08 builds,
+# APP_AUTO_START on G10); elsewhere the op doesn't exist. write-settings saves it before the next reboot.
+tv "appops set $PKG AUTO_START allow 2>/dev/null; appops set $PKG APP_AUTO_START allow 2>/dev/null; appops write-settings 2>/dev/null; true" >/dev/null
# Starting the watcher once takes the app out of the stopped state, without which Android withholds BOOT_COMPLETED.
tv "am start-foreground-service -n $PKG/.WatchService --ez play $PLAY"
echo "Installed. The static plays whenever the screen turns on; its settings are on the TV Static card."