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 #2698: tools: tv.py answers a mistyped flag before asking for TV_HOST
Gathin234a123505815c
diff --cc tools/tv.pyindex 628a1163a,6a59f0500..05384f93f--- a/tools/tv.py+++ b/tools/tv.py@@@ -13,9 -13,9 +13,10 @@@ Set TV_HOST to the TV's IP (or IP:port)tv.py --help this text; needs neither the venv nor a TVExit status: 0 the command ran (the TV's own answer is in its output), 1 the screenshot came back-empty or failed, 2 it was refused before anything ran on the TV - a flag it does not have, one of its-own with the wrong number of words, a local path that cannot be used, a port it could not open. A flag-and its count are judged before TV_HOST is read, so a typo names the usage instead of the TV's address.+empty or failed, or a command's answer was lost when the TV dropped the connection,- 2 it was refused before anything ran on the TV - a flag it does not have, a local path that cannot be- used, a port it could not open.++2 it was refused before anything ran on the TV - a flag it does not have, one of its own with the wrong++number of words, a local path that cannot be used, a port it could not open. A flag and its count are++judged before TV_HOST is read, so a typo names the usage instead of the TV's address.Set TV_ADB_BINARY to the Google adb executable to use an already connected, paired transport(including encrypted Wireless debugging). See tools/native-adb.md.@@@ -295,51 -344,6 +345,36 @@@ def connect_error(e)return None+def lost_connection(e, command, position=None):+ """What to print when a shell command failed because the TV dropped the connection, or None.++ A TV that resets the TCP connection between two commands of a batch ended tv.py with adb_shell's+ ConnectionResetError traceback (#2663). Under `set -euo pipefail` tools/disable.sh stopped there, and+ the traceback named neither the command that was running nor whether the TV had run it: on the+ SHIELD in that report it had, and only its answer was lost. So the drop is answered in words, with+ the command and, in a batch, its place among the commands sent - comments and blank lines are not+ commands, so the count lines up with the `$ command` headings printed above it.++ The exit status stays 1, which is what a run that reached the TV and failed already answered (the+ traceback exited 1 too). Anything that is not a lost connection keeps its traceback: that is a bug+ in this script or in adb_shell, and a traceback is where it shows.+ """+ # Imported here rather than with the client above, as connect_error does, so a stub adb_shell that+ # answers only adb_device and auth still loads this file.+ from adb_shell.exceptions import AdbConnectionError, AdbTimeoutError, TcpTimeoutException+ if not isinstance(e, (OSError, NativeAdbError, AdbConnectionError, AdbTimeoutError,+ TcpTimeoutException)):+ return None+ where = f" (command {position} of this batch)" if position else ""+ rest = ("and the commands after it were not sent: look at the TV before running the batch again"+ if position else+ "look at the TV before running it again")+ return (f'the connection to the TV dropped while running "{command}"{where}: '+ f"{type(e).__name__}: {e}\n"+ f"The TV may or may not have run it, {rest} (`tv.py \"pm list packages -d\"` names the "+ f"packages a debloat batch disabled). See docs/TROUBLESHOOTING.md#connecting.")++- USAGE = """usage:- tv.py --probe- tv.py --screenshot <local.png> [KEY ...] [--wait SECONDS]- tv.py --push <local> <remote>- tv.py --pull <remote> <local>- tv.py --batch < commands.txt- tv.py --reboot- tv.py --help- tv.py <shell command...>- """- # Arguments each known flag takes, the flag included. The shell branch takes anything, so a flag- # with the wrong count listed here is a typo, not a command for the TV.- # --screenshot takes its file and then any number of keys, so it is checked by screenshot_args instead.- ARITY = {"--probe": 1, "--push": 3, "--pull": 3, "--batch": 1, "--reboot": 1}-# screencap writes the PNG on the TV and we pull the file afterwards: adb_shell's shell() decodes# what comes back as text, which corrupts an image, and `exec-out screencap -p` returns a broken# PNG on some MediaTek sets (docs/TROUBLESHOOTING.md). /data/local/tmp is writable from shell.