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
tools: say when a safety override is on (#1845)
viwe-monaif1bf004c972e
diff --git a/tests/test_override_notice.py b/tests/test_override_notice.pynew file mode 100644index 000000000..b3674281e--- /dev/null+++ b/tests/test_override_notice.py@@ -0,0 +1,59 @@+"""tools/disable.sh and tools/disable.ps1 say when a safety override is on (#1845).++The overrides (FORCE_SETUPWRAITH, FORCE_HOME, TVINPUT_ALLOW, HANDLERS_ALLOW) are read from the+environment. `FORCE_HOME=1 tools/disable.sh ...` lasts one command, but in PowerShell a `$env:` value+stays set until the window closes and reaches child processes (README's `powershell ... -File` form,+check.py --fix), so a later run skips its safety check with nothing in the output saying why. Both+scripts now name every override that is set before they touch the TV.++The fake TV is the Home guard test's (tests/test_home_guard.py), which runs the real scripts against a+simulated transport.++Run from the repository root: python3 -m unittest discover -s tests -v+The PowerShell cases need `pwsh` on PATH and skip without it; CI has no PowerShell.+"""+import sys+import unittest+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parent))+import test_home_guard as home_guard # noqa: E402++OVERRIDES = ("FORCE_SETUPWRAITH", "FORCE_HOME", "TVINPUT_ALLOW", "HANDLERS_ALLOW")+++class OverrideNoticeTest(home_guard.HomeGuardTest):+ def test_an_override_that_is_set_is_named_before_the_tv_is_touched(self):+ for entry in self.entries():+ for override in OVERRIDES:+ with self.subTest(entry=entry, override=override):+ self.tv()+ result, _ = self.disable(entry, extra_env={override: "1"})+ self.assertIn(f"{override}=1", self.output(result),+ "a run with an override on must name it")+ self.assertIn("safety check it overrides stays off", self.output(result),+ "the note must say what the override costs")++ def test_a_run_without_overrides_says_nothing_about_them(self):+ for entry in self.entries():+ with self.subTest(entry=entry):+ self.tv()+ result, _ = self.disable(entry)+ self.assertNotIn("stays off until it is", self.output(result),+ "only a run with an override on carries the note")++ def test_the_powershell_note_says_how_to_clear_the_override(self):+ if not home_guard.PWSH:+ raise unittest.SkipTest("the PowerShell twin needs pwsh on PATH")+ self.tv()+ result, _ = self.disable("ps1", extra_env={"FORCE_HOME": "1"})+ self.assertIn("Remove-Item env:FORCE_HOME", self.output(result))++ def test_the_shell_note_says_how_to_clear_the_override(self):+ self.tv()+ result, _ = self.disable("sh", extra_env={"FORCE_HOME": "1"})+ self.assertIn("unset FORCE_HOME", self.output(result))+++if __name__ == "__main__":+ unittest.main()diff --git a/tools/disable.ps1 b/tools/disable.ps1index 8a3512f45..c4fc907be 100644--- a/tools/disable.ps1+++ b/tools/disable.ps1@@ -17,6 +17,17 @@ if (-not (Test-Path $py)) { throw 'run: python -m venv tools\venv; tools\venv\Scif (-not $TvHost) { throw 'pass -TvHost <tv ip> or set $env:TV_HOST' }$env:TV_HOST = $TvHost+# The safety overrides are read from the environment, and in PowerShell a `$env:` value lasts until+# the window closes and reaches child processes (README's `powershell ... -File` form, check.py --fix).+# Say which ones are on: without it, a later run in the same window skips its safety check and nothing+# in the output says why (#1845).+foreach ($override in 'FORCE_SETUPWRAITH', 'FORCE_HOME', 'TVINPUT_ALLOW', 'HANDLERS_ALLOW') {+ $set = Get-Item "env:$override" -ErrorAction SilentlyContinue+ if ($set) {+ Write-Warning "$override=$($set.Value) is set in this window; the safety check it overrides stays off until it is cleared (Remove-Item env:$override)."+ }+}+$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_]+)+$' })diff --git a/tools/disable.sh b/tools/disable.shindex d097ef056..5c1615c59 100755--- a/tools/disable.sh+++ b/tools/disable.sh@@ -11,6 +11,16 @@ LIST="${1:?usage: disable.sh <debloat list>}"LIST_DIR="$(cd "$(dirname "$LIST")" && { pwd -W 2>/dev/null || pwd; })"LIST="$LIST_DIR/$(basename "$LIST")"cd "$(dirname "$0")/.."+# The safety overrides are read from the environment. `FORCE_HOME=1 tools/disable.sh ...` lasts one+# command, but an exported value stays set for the shell and reaches child processes (check.py --fix).+# Say which ones are on: without it, a later run skips its safety check and nothing in the output says+# why (#1845).+for override in FORCE_SETUPWRAITH FORCE_HOME TVINPUT_ALLOW HANDLERS_ALLOW; do+ if [ -n "${!override:-}" ]; then+ echo "note: $override=${!override} is set; the safety check it overrides stays off until it is" >&2+ echo "cleared (unset $override)." >&2+ fi+donePY=tools/venv/bin/python[ -x "$PY" ] || PY=tools/venv/Scripts/python.exeexport MSYS_NO_PATHCONV=1