Skip to content

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

theme.ps1: the same accessibility write-back order as theme.sh

Caner3f2216ad7550
diff --git a/tools/theme.ps1 b/tools/theme.ps1
index 8f79c5a04..68e63751e 100644
--- a/tools/theme.ps1
+++ b/tools/theme.ps1
@@ -25,10 +25,13 @@ $revision = [guid]::NewGuid().ToString('N')
# put the list back if it had ours. Writing the same list back is not enough: the force-stop also turns
# accessibility_enabled off, and the service only binds again once the list changes. So restart first, then
# clear the list, switch accessibility off (some TVs keep the service "crashed" and unbound otherwise), write
-# the list back and switch accessibility on again. When the launcher is already Home it comes back through the Home
+# the list back and switch accessibility on again. On some TVs (Xiaomi MiTV-MOOR2, Android 11) Android has already
+# emptied the list and switched accessibility off by then, so clearing it changes nothing and the services stay
+# crashed: write the list back first, so the clear is a change (the same order as theme.sh). When the launcher is
+# already Home it comes back through the Home
# intent, since `am start -n` from the shell leaves a second MainActivity behind the Home one; before the handover
# it is started by name as before.
-$restart = "a=`$(settings get secure enabled_accessibility_services); am force-stop $pkg; case `"`$(cmd package resolve-activity --brief -a android.intent.action.MAIN -c android.intent.category.HOME | tail -n 1)`" in $pkg/*) am start -a android.intent.action.MAIN -c android.intent.category.HOME >/dev/null ;; *) am start -n $pkg/.MainActivity >/dev/null ;; esac; case `"`$a`" in *$pkg*) sleep 1; settings put secure enabled_accessibility_services ''; settings put secure accessibility_enabled 0; sleep 1; settings put secure enabled_accessibility_services `"`$a`"; settings put secure accessibility_enabled 1 ;; esac"
+$restart = "a=`$(settings get secure enabled_accessibility_services); am force-stop $pkg; case `"`$(cmd package resolve-activity --brief -a android.intent.action.MAIN -c android.intent.category.HOME | tail -n 1)`" in $pkg/*) am start -a android.intent.action.MAIN -c android.intent.category.HOME >/dev/null ;; *) am start -n $pkg/.MainActivity >/dev/null ;; esac; case `"`$a`" in *$pkg*) sleep 1; settings put secure enabled_accessibility_services `"`$a`"; settings put secure accessibility_enabled 1; sleep 1; settings put secure enabled_accessibility_services ''; settings put secure accessibility_enabled 0; sleep 1; settings put secure enabled_accessibility_services `"`$a`"; settings put secure accessibility_enabled 1 ;; esac"
# Some firmware (TCL G07, Android 11) locks the shell out of Android/data. Files are staged in
# /data/local/tmp and copied in, or written through the launcher's ThemeProvider when that is refused.