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
docs: the network can come over the USB port debugging takes away
xbsheng8738ab5a58f9
diff --git a/PROMPT.md b/PROMPT.mdindex 9b192574b..1cb24a468 100644--- a/PROMPT.md+++ b/PROMPT.md@@ -9,7 +9,11 @@ instead of writing them from scratch, and only needs to edit `launcher/.../valueBefore you start, on the TV: Settings → Device Preferences → About → press OK on "Build" 7 times,then go back → Developer options → turn on USB debugging (and Network/ADB debugging if your TVshows it). Keep the TV on. Some boxes cut power to their USB port while USB debugging is on, so a-USB speaker or drive plugged into it goes dead until you switch debugging off again.+USB speaker or drive plugged into it goes dead until you switch debugging off again. A USB Ethernet+adapter sits on that same port: on some sets it drops the moment debugging is on (on others it+survives until the next reboot), the TV falls back to Wi-Fi without saying so, and the adapter only+comes back with debugging off - which stops `adbd` too. If that is how your TV is wired, do the whole+session in one sitting, and prefer Wireless debugging where the TV offers it.---@@ -39,11 +43,20 @@ ConnectBack up first- Save the full package list, disabled-package list, getprop output and all settings to a backup folderbefore changing anything, and write a restore script that re-enables everything you disable.-- Ask me what is plugged into the TV's USB ports. Some devices cut their power while USB debugging- is on, so warn me, and remind me to switch debugging off once you're done.+- Ask me what is plugged into the TV's USB ports, and ask separately whether the TV's network comes+ through a USB Ethernet adapter: "nothing plugged in" can be true while the network itself is on that+ port. Some devices cut their power while USB debugging is on, so warn me, and remind me to switch+ debugging off once you're done. On a set that reaches the network over USB Ethernet, check before you+ change anything: `dumpsys usb | grep host_connected` (`host_connected=false` means the adapter is+ already gone) and `dumpsys connectivity | grep -o 'Transports: [A-Z]*'` (`WIFI` on a TV I call wired+ means the box fell back, and ADB is running over Wi-Fi). Finish the whole job in one sitting, not+ two: there the port only returns with USB debugging off, and that closes port 5555 as well. Prefer+ Wireless debugging if the TV has it.- When you finish, close network ADB instead of leaving it open: switch USB debugging andNetwork/ADB debugging off on the TV, revoke the USB debugging authorisations, reboot, and check- with `tools/adb-closed.py <tv ip>` that the port refuses the connection. Don't trust `nc` on macOS:+ with `tools/adb-closed.py <tv ip>` that the port refuses the connection. If the TV's network came+ over a USB Ethernet adapter, unplug and replug the adapter once debugging is off - the port comes+ back with it - and have me confirm the TV is on Ethernet again, not Wi-Fi. Don't trust `nc` on macOS:Local Network privacy can block it too, and its "No route to host" proves nothing; only "Connectionrefused" does. Port 5555 is plaintext, and on firmware with `ro.adb.secure=0` any device on the LANcan get a shell.diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex 523e3a37b..83a4ab5ec 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -31,9 +31,20 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/_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` reconnectswithout a new code. Port 5555 from `adb tcpip` usually lasts only until the next reboot.-- **USB devices go dead while USB debugging is on**, seen on the Xiaomi Mi Box S: its firmware- switches the USB port to ADB device mode, which cuts the power to a USB speaker or drive. Switch- USB debugging off when you're done; the launcher doesn't need it.+- **USB devices go dead while USB debugging is on**, seen on the Xiaomi Mi Box S and the Xiaomi TV+ Box S 3rd gen ([MiTV-AFMU0, Google TV 14](https://github.com/Gathin23/cleanyourtv/issues/737)):+ their firmware switches the USB port to ADB device mode, which cuts the power to a USB speaker or+ drive. A **USB Ethernet adapter sits on that same port**, so the network goes with it and the box+ falls back to Wi-Fi without saying so. `dumpsys usb | grep host_connected` prints `false`;+ `dumpsys connectivity | grep -o 'Transports: [A-Z]*'` prints `WIFI` on a set the owner calls wired.+ A bare `eth0` stuck at `NO-CARRIER` is these boards' own socketless MAC, not the adapter - on the+ TCL 65C735 the adapter came up as `eth1`. How long the port survives debugging differs by firmware:+ the two Xiaomi boxes lose it as soon as debugging is on, while the 65C735 kept the adapter until a+ reboot with debugging still on put the port in gadget mode (`sys.usb.config=adb`, `Mstar-udc`) and+ it never came back ([that list's header](../examples/tcl-65c735/debloat.txt)). Either way there is+ no way back from the shell on a set with no Wireless debugging, and switching USB debugging off+ stops `adbd` too, so plan one sitting rather than two: switch debugging off at the end, replug the+ adapter, and confirm Ethernet before handing the TV back. The launcher never needs debugging.- **Close port 5555 when you're done**: plaintext, and a shell for anyone on the LAN when `ro.adb.secure=0`. Steps in the README FAQ.- **The TV sits on a separate VLAN or IoT network** and `tools/tv.py` times out although debuggingis on: the router keeps the computer from reaching it. Add a temporary firewall rule from yourdiff --git a/tests/test_usb_ethernet_note.py b/tests/test_usb_ethernet_note.pynew file mode 100644index 000000000..aa7fb7e0e--- /dev/null+++ b/tests/test_usb_ethernet_note.py@@ -0,0 +1,107 @@+"""Pins the USB-Ethernet warning in PROMPT.md and docs/TROUBLESHOOTING.md (#737).++The prompt used to ask only what was plugged into the USB ports, which an owner can answer+"nothing" while the network itself runs over a USB Ethernet adapter on that port. On the sets in+#737 the port goes to ADB device mode as soon as debugging is on, so the adapter - and with it the+network ADB session - is gone, and it only comes back with debugging off. These tests keep the+question asked, keep the two dumpsys checks that tell the two interfaces apart, and keep the claim+tied to the list header that first reported it (examples/tcl-65c735) instead of drifting away from it.+Whitespace is flattened before matching because every file here wraps its prose.+"""+import re+from pathlib import Path+import unittest+++ROOT = Path(__file__).resolve().parents[1]+PROMPT = ROOT / "PROMPT.md"+TROUBLE = ROOT / "docs" / "TROUBLESHOOTING.md"+C735 = ROOT / "examples" / "tcl-65c735" / "debloat.txt"+++def flat(path):+ return re.sub(r"\s+", " ", path.read_text(encoding="utf-8"))+++def bullet(text, opening):+ """One flattened markdown bullet, from its opening words to the next top-level bullet."""+ start = text.index(opening)+ end = text.find(" - **", start)+ return text[start:end if end != -1 else len(text)]+++class PromptTest(unittest.TestCase):+ def test_the_prompt_names_the_usb_ethernet_case_before_it_starts(self):+ text = flat(PROMPT)+ head = text[:text.index("---")] # the "Before you start, on the TV" paragraph+ self.assertIn("USB Ethernet", head)+ self.assertIn("falls back to Wi-Fi", head)+ self.assertIn("one sitting", head)++ def test_the_backup_step_asks_about_the_network_not_only_the_ports(self):+ text = flat(PROMPT)+ step = bullet(text, "- Ask me what is plugged into the TV's USB ports")+ self.assertIn("whether the TV's network comes through a USB Ethernet adapter", step)+ self.assertIn('"nothing plugged in" can be true', step)+ self.assertIn("dumpsys usb | grep host_connected", step)+ self.assertIn("dumpsys connectivity | grep -o 'Transports: [A-Z]*'", step)+ # Both greetings are needed: the check is worthless if the agent never learns which it is.+ self.assertIn("WIFI", step)+ self.assertIn("ethernet", step.lower())+ self.assertIn("Wireless debugging", step)++ def test_the_closing_step_brings_the_adapter_back(self):+ text = flat(PROMPT)+ step = bullet(text, "- When you finish, close network ADB")+ self.assertIn("replug the adapter", step)+ self.assertIn("on Ethernet again", step)+ # The port comes back with debugging off, so the check has to stay after that switch.+ self.assertLess(step.index("switch USB debugging"), step.index("replug the adapter"))+++class TroubleshootingTest(unittest.TestCase):+ def setUp(self):+ self.text = flat(TROUBLE)+ self.entry = bullet(self.text, "- **USB devices go dead while USB debugging is on**")++ def test_the_entry_covers_the_network_and_not_just_power(self):+ for phrase in (+ "Xiaomi Mi Box S",+ "MiTV-AFMU0",+ "issues/737",+ "USB Ethernet adapter sits on that same port",+ "falls back to Wi-Fi",+ ):+ with self.subTest(phrase=phrase):+ self.assertIn(phrase, self.entry)++ def test_the_entry_gives_both_dumpsys_signatures(self):+ self.assertIn("dumpsys usb | grep host_connected", self.entry)+ self.assertIn("dumpsys connectivity | grep -o 'Transports: [A-Z]*'", self.entry)+ self.assertIn("host_connected` prints `false", self.entry)++ def test_the_entry_keeps_the_eth0_trap_apart_from_the_adapter(self):+ self.assertIn("NO-CARRIER", self.entry)+ self.assertIn("eth1", self.entry)++ def test_the_two_firmware_timings_stay_separate(self):+ self.assertIn("as soon as debugging is on", self.entry)+ self.assertIn("until a reboot", self.entry)+ self.assertIn("sys.usb.config=adb", self.entry)++ def test_the_entry_does_not_promise_a_shell_way_back(self):+ self.assertIn("no way back from the shell", self.entry)+ self.assertIn("stops `adbd`", self.entry)++ def test_the_entry_links_a_list_that_still_says_the_same_thing(self):+ link = "[that list's header](../examples/tcl-65c735/debloat.txt)"+ self.assertIn(link, self.entry)+ self.assertTrue(C735.is_file())+ header = flat(C735)+ self.assertIn("wired through a USB Ethernet adapter (eth1)", header)+ self.assertIn("sys.usb.config=adb", header)+ self.assertIn("Switch USB debugging off once you are done", header)+++if __name__ == "__main__":+ unittest.main()