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/tv.py --screenshot: honour --wait with no keys, and name a --wait with no number
csponkoj82f7260a8bc0
diff --git a/tests/test_tv_screenshot.py b/tests/test_tv_screenshot.pyindex 2158656b6..afa504a76 100644--- a/tests/test_tv_screenshot.py+++ b/tests/test_tv_screenshot.py@@ -174,6 +174,22 @@ class ScreenshotTest(unittest.TestCase):self.run_tv(["--screenshot", str(Path(tmp) / "a.png")])self.assertEqual(self.sleeps, [])+ def test_wait_without_keys_still_pauses_before_the_capture(self):+ # --wait with no keys used to be read and then dropped, so the capture came straight away.+ with tempfile.TemporaryDirectory() as tmp:+ code, _, err, device = self.run_tv(["--screenshot", str(Path(tmp) / "a.png"), "--wait", "3"])+ self.assertEqual(code, 0, err)+ self.assertEqual(self.sleeps, [3.0])+ self.assertFalse(any("keyevent" in c[1] for c in device.calls if c[0] == "shell"))++ def test_wait_without_a_number_says_so(self):+ # A trailing --wait used to be reported as "not a key name: '--wait'".+ code, _, err, device = self.run_tv(["--screenshot", "a.png", "HOME", "--wait"])+ self.assertEqual(code, 2)+ self.assertIn("--wait needs a number of seconds", err)+ self.assertNotIn("not a key name", err)+ self.assertEqual(device.calls, [], "nothing may reach the TV")+def test_bad_key_names_and_waits_never_reach_the_tv(self):for args in (["--screenshot", "a.png", "home"], ["--screenshot", "a.png", "HOME;reboot"],["--screenshot", "a.png", "--wait", "-1"], ["--screenshot", "a.png", "--wait", "soon"]):diff --git a/tools/tv.py b/tools/tv.pyindex ea82810f4..cd8e42047 100644--- a/tools/tv.py+++ b/tools/tv.py@@ -152,12 +152,16 @@ def screenshot_args(rest):"""`<local.png> [KEY ...] [--wait SECONDS]` into (local, keys, wait), or a usage error before connecting.KEY is an Android key name without the KEYCODE_ prefix (HOME, DPAD_RIGHT), a full name (KEYCODE_BACK)- or a numeric keycode (83). The screenshot is taken --wait seconds after the last key (default 1)."""- local, keys, wait = None, [], 1.0+ or a numeric keycode (83). The screenshot is taken --wait seconds after the last key (default 1). With no+ keys, --wait still pauses before the capture, so a screen that is still loading can settle; without it,+ no keys means no pause."""+ local, keys, wait = None, [], Nonei = 0while i < len(rest):arg = rest[i]- if arg == "--wait" and i + 1 < len(rest):+ if arg == "--wait":+ if i + 1 == len(rest):+ usage_error("--wait needs a number of seconds")try:wait = float(rest[i + 1])except ValueError:@@ -176,6 +180,8 @@ def screenshot_args(rest):i += 1if local is None:usage_error("--screenshot needs the file to save to")+ if wait is None:+ wait = 1.0 if keys else 0.0return local, keys, wait@@ -189,7 +195,7 @@ def keyevent(name):return name if name.isdigit() or name.startswith("KEYCODE_") else "KEYCODE_" + name-def screenshot(dev, local, keys=(), wait=1.0):+def screenshot(dev, local, keys=(), wait=0.0):"""Press `keys`, then capture the TV screen into `local`. Returns 0, or 1 when the capture failed orcame back empty."""# Agents pass paths like shots/01-home.png before that folder exists, and the pull then fails@@ -199,7 +205,7 @@ def screenshot(dev, local, keys=(), wait=1.0):if i:time.sleep(KEY_GAP_S)dev.shell(f"input keyevent {keyevent(key)}")- if keys:+ if wait:time.sleep(wait)# The exit status tells a capture that failed (no file to pull) from one that came back empty: with# Netflix in front a TCL C755 exits 1 and leaves a 0-byte file, which is the empty case below.