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 #421: tools: keep the packages that drive the HDMI/AV inputs
Gathin23f578854c9354
diff --cc tools/disable.ps1index 831fb41fe,946038c11..bd1c7cd2c--- a/tools/disable.ps1+++ b/tools/disable.ps1@@@ -69,6 -69,30 +69,30 @@@ if (-not $env:FORCE_HOME)}}}+ # Same as disable.sh (#321): a package that asks for android.permission.TV_INPUT_HARDWARE is the software+ # layer under the HDMI, AV and tuner inputs. Disable one and the port still notices the cable but shows+ # "No Signal" for good; re-enabling the pieces in batches does not bring the picture back, a full restore+ # and a cold boot do. Keep them; `$env:TVINPUT_ALLOW=1` disables them anyway.+ if (-not $env:TVINPUT_ALLOW -and $pkgs.Count -gt 0) {+ # Trailing `; true`: the loop's status is the last package's `grep -q`, which is nonzero whenever the+ # last listed package is not an input driver, and would look like a failed check.- $loop = 'for p in ' + ($pkgs -join ' ') + '; do dumpsys package $p | grep -q TV_INPUT_HARDWARE && echo $p; done; true'++ $loop = 'for p in ' + ($pkgs -join ' ') + '; do dumpsys package $p | sed -n -E ''/requested permissions:/,/(install|runtime) permissions:|User [0-9]+:/p'' | grep -q TV_INPUT_HARDWARE && echo $p; done; true'+ # Windows PowerShell turns redirected stderr into an error that 'Stop' would throw (see getprop).+ $ErrorActionPreference = 'Continue'+ $tvhw = @(& $py -I (Join-Path $repo 'tools\tv.py') $loop 2>$null)+ $checked = $LASTEXITCODE -eq 0+ $ErrorActionPreference = 'Stop'+ if (-not $checked) {+ Write-Warning 'Could not check which listed packages drive the HDMI/AV inputs (tv.py failed). Check every input after this run: a port that notices the cable and stays black means one of them was disabled, and only a full restore and a cold boot bring it back (#321).'+ } else {+ foreach ($p in ($tvhw | ForEach-Object { $_.Trim() } | Where-Object { $_ })) {+ if ($pkgs -contains $p) {+ Write-Warning "Skipping ${p}: it asks for android.permission.TV_INPUT_HARDWARE, so it is the software layer under the HDMI/AV/tuner inputs. With it disabled those inputs still notice the cable but stay black (No Signal), and re-enabling the pieces in batches does not restore the picture: a full restore plus a cold boot does (#321). Set `$env:TVINPUT_ALLOW=1 to disable it."+ $pkgs = @($pkgs | Where-Object { $_ -ne $p })+ }+ }+ }+ }# Same as disable.sh: the state undo needs is recorded before the first command reaches the TV, and# a failed save leaves the TV untouched (#239).& $py -I (Join-Path $repo 'tools\recovery.py') --save $Listdiff --cc tools/disable.shindex 8d8161f65,d189fb64d..12ccfe51a--- a/tools/disable.sh+++ b/tools/disable.sh@@@ -81,6 -81,41 +81,43 @@@ if [ -n "$HOME_PKG" ] && printf '%s\n'fifi++# Only the package's own "requested permissions" block counts: a vendor app in a shared UID would otherwise++# match through its shared user's permissions and be skipped by mistake.+ # A package that asks for android.permission.TV_INPUT_HARDWARE is the software layer under the HDMI, AV+ # and tuner inputs: routing, the HDCP handshake and scaling live in it. Disable one and the port still+ # notices the cable but shows "No Signal" for good; re-enabling the pieces in batches does not bring the+ # picture back, a full restore and a cold boot do (#321, OnePlus TV on Android 11). Keep those packages;+ # TVINPUT_ALLOW=1 disables them anyway.+ if [ -n "$PKGS" ] && [ -z "${TVINPUT_ALLOW:-}" ]; then+ # One round trip: the loop runs on the TV, where `dumpsys package` prints the permissions a package+ # asks for. Every name was checked as a bare package name above, so none of them can add shell syntax+ # here. </dev/null so the client cannot read this script's stdin (that is the piped batch below);+ # tr -d '\r' because adb can end lines with CRLF, which would leave a CR on every name.+ NAMES="$(printf '%s ' $PKGS)"+ # Trailing `; true`: the loop's status is the last package's `grep -q`, which is nonzero whenever+ # the last listed package is not an input driver — the common case — and would look like a failed+ # check. Only a real failure (tv.py cannot reach the TV) should reach the warning below.+ if TV_HW="$("$PY" -I tools/tv.py \- "for p in $NAMES; do dumpsys package \$p | grep -q TV_INPUT_HARDWARE && echo \$p; done; true" \++ "for p in $NAMES; do dumpsys package \$p | sed -n -E '/requested permissions:/,/(install|runtime) permissions:|User [0-9]+:/p' | grep -q TV_INPUT_HARDWARE && echo \$p; done; true" \+ </dev/null 2>/dev/null | tr -d '\r')"; then+ for p in $TV_HW; do+ # grep without -q: with pipefail an early exit could SIGPIPE printf and fail the run (see above).+ printf '%s\n' "$PKGS" | grep -xF "$p" >/dev/null || continue+ echo "Skipping $p: it asks for android.permission.TV_INPUT_HARDWARE, so it is the software layer" >&2+ echo "under the HDMI/AV/tuner inputs. With it disabled those inputs still notice the cable but stay" >&2+ echo "black (\"No Signal\"), and re-enabling the pieces in batches does not restore the picture: a" >&2+ echo "full restore plus a cold boot does (#321). Set TVINPUT_ALLOW=1 to disable it." >&2+ PKGS="$(printf '%s\n' "$PKGS" | grep -vxF "$p" || true)"+ done+ else+ # Do not skip anything on a guess, but say the check did not run: a black input is easy to blame on+ # the cable, and the ports are the one thing the owner cannot test from here.+ echo "Could not check which listed packages drive the HDMI/AV inputs (tv.py failed). Check every" >&2+ echo "input after this run: a port that notices the cable and stays black means one of them was" >&2+ echo "disabled, and only a full restore and a cold boot bring it back (#321)." >&2+ fi+ fi+# The state undo needs goes to disk before the first command reaches the TV, and a failed save stops# here with the TV untouched: a record written afterwards would describe a TV that is already broken,# and a retry must not overwrite the one taken before the first change (#239).