Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

tools: the Wireless debugging port's TLS refusal names the Google ADB backend

xbsheng758ce2301b74
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index 1877438c3..c883d5b02 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -43,8 +43,13 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/
USB debugging there. When no app can open it either, see the carrier-box bullet above.
- **USB debugging never opens port 5555** on some Google TV sets (a Skyworth-built Philips among
them). Pair once through Wireless debugging with the stock `adb` (`adb pair <ip>:<port> <code>`,
- then `adb connect`), run `adb tcpip 5555`, and `tools/tv.py` works from then on. `dns-sd -B
- _adb-tls-pairing._tcp` (or `adb mdns services`) shows the pairing port while the code is on screen.
+ then `adb connect`), run `adb tcpip 5555`, and `tools/tv.py` works from then on. Keep 5555 closed
+ if you would rather not open it, since the pairing is enough on its own: with `TV_ADB_BINARY` naming
+ that same platform-tools `adb` and `TV_HOST` naming the Wireless debugging connection port, the tools
+ reach the TV through the paired transport, nothing listens on 5555 and there is no `adb tcpip` to run
+ again ([tools/native-adb.md](../tools/native-adb.md)); read that port again when Wireless debugging is
+ toggled, since it changes. `dns-sd -B _adb-tls-pairing._tcp` (or `adb mdns services`) shows the
+ pairing port while the code is on screen.
Android switches Wireless debugging off whenever Wi-Fi drops; turn it back on and `adb` reconnects
without a new code. Port 5555 from `adb tcpip` usually lasts only until the next reboot. When you
close up, switch Wireless debugging off on its own: on a Chromecast with Google TV 4K (`sabrina`)
diff --git a/docs/firmware-updates.md b/docs/firmware-updates.md
index 78f63a676..ee602cc0c 100644
--- a/docs/firmware-updates.md
+++ b/docs/firmware-updates.md
@@ -23,6 +23,13 @@ TV_HOST=192.168.1.50 tools/venv/bin/python -I tools/check.py examples/<your tv>/
On Windows the same command is `tools\venv\Scripts\python.exe -I tools\check.py <list>`.
+A TV that only offers Wireless debugging does not need the plaintext port at all: leave `adb tcpip 5555`
+out, point `TV_ADB_BINARY` at the same platform-tools `adb` and `TV_HOST` at the Wireless debugging
+connection port, and the check goes through the already paired transport, with nothing listening on 5555
+and no "Allow USB debugging?" prompt to accept
+([tools/native-adb.md](../tools/native-adb.md)). Read that port again before each run, since it changes
+when Wireless debugging is toggled.
+
## Exit codes, and a weekly job
It exits with `0` when the TV still matches the list, `1` when something drifted, and `2` when it
diff --git a/tests/test_tv_connect_errors.py b/tests/test_tv_connect_errors.py
index e3d0c7f76..2bb61a17d 100644
--- a/tests/test_tv_connect_errors.py
+++ b/tests/test_tv_connect_errors.py
@@ -5,10 +5,12 @@ restart, while tv.py connects to 5555 unless TV_HOST or TV_PORT names another po
5555 refuses and tv.py ended with a ConnectionRefusedError traceback. Pointed at the Wireless debugging port,
it ended with adb_shell's `InvalidCommandError: Unknown command: ... 'STLS'`: that port asks for TLS, and
adb_shell 0.4.4 (tools/requirements.txt) has none. Neither says which port to use instead. tv.py now prints
-what happened and the way to port 5555 (pair once with the stock adb, then `adb tcpip 5555`), and exits 2.
-A key file it cannot read and a connection reset in the handshake keep their traceback: neither means the TV
-could not be reached. tv.connect() itself still raises, because check.py (through recovery.connect()) and
-privacy.py catch its errors themselves; recovery.py --save still lets them through.
+what happened, the TV_ADB_BINARY backend that can speak that TLS port without opening 5555
+(tools/native-adb.md), and the way to port 5555 (pair once with the stock adb, then `adb tcpip 5555`), and
+exits 2. A key file it cannot read and a connection reset in the handshake keep their traceback:
+neither means the TV could not be reached. tv.connect() itself still raises, because check.py
+(through recovery.connect()) and privacy.py catch its errors themselves; recovery.py --save still
+lets them through.
These runs use the real adb_shell and real sockets on 127.0.0.1: a port nothing listens on, a server that
answers the handshake with the STLS packet a Chromecast with Google TV 4K (Google TV 14) sent back on its
@@ -213,6 +215,12 @@ class TvConnectErrorTest(unittest.TestCase):
self.assertEqual(b"CNXN", server.first[:4], "tv.py opened the ADB handshake that STLS answers")
self.assertIn(f"127.0.0.1:{server.port} is a Wireless debugging port: it asks for TLS, which tv.py "
"cannot use.", result.stderr)
+ self.assertIn("TV_ADB_BINARY", result.stderr,
+ "the port tv.py cannot speak to itself is the one TV_ADB_BINARY can, and the message "
+ "has to name it or the reader opens the plaintext port instead (tools/native-adb.md)")
+ self.assertIn("keep TV_HOST as it is", result.stderr,
+ "the backend takes the Wireless debugging port in TV_HOST, not port 5555")
+ self.assertIn("tools/native-adb.md", result.stderr, "the backend's guide has to be named")
self.assertIn("`adb pair`", result.stderr)
self.assertIn("`adb tcpip 5555`", result.stderr)
self.assertIn("set TV_HOST to the TV's IP alone and leave TV_PORT unset", result.stderr)
diff --git a/tools/tv.py b/tools/tv.py
index c213b0bee..f41094c25 100755
--- a/tools/tv.py
+++ b/tools/tv.py
@@ -309,8 +309,15 @@ def connect_error(e):
see = "See docs/TROUBLESHOOTING.md#connecting."
if isinstance(e, InvalidCommandError) and "STLS" in str(e):
# Android 11+ answers the handshake on its Wireless debugging port with STLS, a request for TLS.
- # adb_shell 0.4.4 (tools/requirements.txt) has no TLS, so no TV_HOST or TV_PORT gets past it.
+ # adb_shell 0.4.4 (tools/requirements.txt) has no TLS, so no TV_HOST or TV_PORT gets past it - but
+ # Google's own adb does, which is what TV_ADB_BINARY and tools/native-adb.md are for. Sending the
+ # reader to `adb tcpip 5555` alone answered a question the repo already has a better answer to:
+ # that opens the plaintext port the security section asks them to close.
return (f"{target} is a Wireless debugging port: it asks for TLS, which tv.py cannot use.\n"
+ f"Google's adb can use it: pair and connect with it once, then set TV_ADB_BINARY to that "
+ f"adb and keep TV_HOST as it is (the Wireless debugging port) - this same tool then goes "
+ f"through that paired connection, with nothing opened on 5555 "
+ f"(tools/native-adb.md).\n"
f"To use port 5555 instead, {pair}, then set TV_HOST to the TV's IP alone and leave TV_PORT "
f"unset. {reboot} {see}")
if isinstance(e, ConnectionRefusedError):