Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
Merge PR #214: setupwraith no longer deletes the TV's Wi-Fi when disabled
Gathin23f76a2f30b35a
diff --cc docs/TROUBLESHOOTING.mdindex 3c11674d7,539b9e321..736feff39--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@@ -55,6 -55,15 +55,15 @@@ Things that bit us or contributors, so`com.google.android.tungsten.setupwraith` package is what frees the slot. It is the first-runsetup wizard, so everyday use is unaffected, but re-enable it before a factory reset - list it inyour `debloat.txt` and `tools/restore.sh` does that for you.+ - **The TV drops off Wi-Fi for good the moment setupwraith is disabled**, seen on Google TV 14 (Sony- BRAVIA 9 II, Philips R8G, Skyworth SWTV-24NA-4K NF). A Wi-Fi network saved during the first-run++ BRAVIA 9 II, Philips R8G, Skyworth SWTV-24NA-4K NF, Xiaomi TV Box S 3rd gen MiTV-AFMU0). A Wi-Fi network saved during the first-run+ wizard belongs to setupwraith, and Android deletes an app's saved networks when the app is disabled.+ The TV is fine but offline, so ADB and the phone remote stop working, and a restart doesn't bring+ the network back. Check before disabling it: `tools/tv.py "dumpsys wifi" | grep -o 'cname=[^ ]*'`.+ If it names setupwraith, forget the network and join it again in Settings > Network & Internet (it+ then belongs to `android.uid.system`), or use Ethernet. `tools/disable.sh` skips setupwraith while it+ owns the network (`FORCE_SETUPWRAITH=1` overrides). Already offline? Rejoin from the TV with its own+ remote or a USB keyboard, then turn Wireless debugging back on if it was in use.- **The TV drops off Wi-Fi every minute right after the install**, seen on Google TV 14 (XiaomiMiTV-MZTU0): the same setupwraith `.RecoveryActivity` took Home and system_server crash-loopedon it. The install script now starts the new launcher before disabling the stock one, sets thediff --cc tools/disable.ps1index d11131483,89962bf8e..272e69d1e--- a/tools/disable.ps1+++ b/tools/disable.ps1@@@ -17,11 -17,6 +17,21 @@@ if (-not (Test-Path $py)) { throw 'runif (-not $TvHost) { throw 'pass -TvHost <tv ip> or set $env:TV_HOST' }$env:TV_HOST = $TvHost-$pkgs = Get-Content $List | ForEach-Object { ($_ -replace '#.*$', '').Trim() } | Where-Object { $_ }+$pkgs = Get-Content $List | ForEach-Object { ($_ -replace '#.*$', '').Trim() } | Where-Object { $_ } | ForEach-Object { ($_ -split '\s+')[0] }+# Lists come from contributors and each name is pasted into a shell command on the TV (#165).+$bad = @($pkgs | Where-Object { $_ -notmatch '^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z0-9_]+)+$' })+if ($bad.Count -gt 0) {+ throw "refusing $List, not a package name: $($bad -join ', ')"+}++# A Wi-Fi network saved during the first-run wizard belongs to setupwraith, and Android deletes it when++# setupwraith is disabled. Skip it while it owns the saved network; `$env:FORCE_SETUPWRAITH=1` overrides.++$setup = 'com.google.android.tungsten.setupwraith'++if ($pkgs -contains $setup -and -not $env:FORCE_SETUPWRAITH) {++ $wifi = (& $py -I (Join-Path $repo 'tools\tv.py') 'dumpsys wifi') -join "`n"++ if ($wifi -match 'cname=[^ ]*setupwraith') {++ Write-Warning "Skipping ${setup}: the saved Wi-Fi network belongs to it, and disabling it would delete that network and take the TV off Wi-Fi. Forget the network and join it again in Settings > Network & Internet, then run this again (or set `$env:FORCE_SETUPWRAITH=1 on Ethernet)."++ $pkgs = @($pkgs | Where-Object { $_ -ne $setup })++ }++}$cmds = @($pkgs | ForEach-Object { "pm disable-user --user 0 $_" }) + 'pm list packages -d'$cmds | & $py -I (Join-Path $repo 'tools\tv.py') --batchdiff --cc tools/disable.shindex 071eb4699,b6fc67673..673156d7c--- a/tools/disable.sh+++ b/tools/disable.sh@@@ -13,18 -13,24 +13,34 @@@ PY=tools/venv/bin/pytho[ -x "$PY" ] || PY=tools/venv/Scripts/python.exeexport MSYS_NO_PATHCONV=1[ -x "$PY" ] || { echo "run: python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements.txt"; exit 1; }-PACKAGES="$(grep -vE '^\s*(#|$)' "$LIST" | sed -E 's/\s+#.*$//' | awk '{print $1}')"-+# Lists come from contributors, and the package name is pasted into a shell command on the TV.+# Refuse the whole list unless every entry is a bare package name (#165).+# Normalise first: Notepad on Windows saves a BOM and CRLF, and without this the first "# TV" line+# arrives as a package name and every entry keeps a trailing \r (#208).+PKGS=$(LC_ALL=C awk 'NR==1{sub(/^\357\273\277/,"")} {sub(/\r$/,""); print}' "$LIST" \+ | grep -vE '^\s*(#|$)' | sed -E 's/\s+#.*$//' | awk '{print $1}')+BAD=$(printf '%s\n' "$PKGS" | grep -vE '^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z0-9_]+)+$' || true)+if [ -n "$BAD" ]; then+ { echo "refusing $LIST: not a package name:"; printf '%s\n' "$BAD" | sed 's/^/ /'; } >&2+ exit 1+fi+ # A Wi-Fi network saved during the first-run wizard belongs to setupwraith, and Android deletes it the+ # moment setupwraith is disabled: the TV drops off Wi-Fi, and ADB and the phone remote go with it.+ # Skip it until the network has been forgotten and re-joined in Settings (it then belongs to+ # android.uid.system). FORCE_SETUPWRAITH=1 disables it anyway, e.g. on Ethernet.+ SETUP=com.google.android.tungsten.setupwraith-if grep -qx "$SETUP" <<<"$PACKAGES" && [ -z "${FORCE_SETUPWRAITH:-}" ]; then++if printf '%s\n' "$PKGS" | grep -x "$SETUP" >/dev/null && [ -z "${FORCE_SETUPWRAITH:-}" ]; then+ WIFI="$("$PY" -I tools/tv.py "dumpsys wifi" || true)"- if grep -o 'cname=[^ ]*' <<<"$WIFI" | grep -q setupwraith; then++ # no grep -q here: with pipefail its early exit would SIGPIPE the grep before it and fail open++ if printf '%s\n' "$WIFI" | grep -o 'cname=[^ ]*' | grep setupwraith >/dev/null; then+ echo "Skipping $SETUP: the saved Wi-Fi network belongs to it, and disabling it would delete that" >&2+ echo "network and take the TV off Wi-Fi. On the TV, forget the network and join it again in" >&2+ echo "Settings > Network & Internet, then run this again (or set FORCE_SETUPWRAITH=1 on Ethernet)." >&2- PACKAGES="$(grep -vx "$SETUP" <<<"$PACKAGES" || true)"++ PKGS="$(printf '%s\n' "$PKGS" | grep -vx "$SETUP" || true)"+ fi+ fi+{- awk 'NF {print "pm disable-user --user 0 " $1}' <<<"$PACKAGES"+ [ -n "$PKGS" ] && printf '%s\n' "$PKGS" | sed 's/^/pm disable-user --user 0 /'echo "pm list packages -d"} | "$PY" -I tools/tv.py --batch