Skip to content

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

Merge PR #147: b64push works with pre-Nougat adbd

Gathin2354e3dd469cf5
diff --cc tools/b64push.py
index 847dd49d9,98e4418a6..966cfd7ac
--- a/tools/b64push.py
+++ b/tools/b64push.py
@@@ -11,7 -11,9 +11,9 @@@ import sy
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import tv # noqa: E402
- CHUNK = 48 * 1024 # raw bytes per shell command (base64 grows it by 4/3)
-CHUNK = 2048 # raw bytes per shell command (base64 grows it by 4/3).
-# 48 KB worked on Android 10+, but adbd before ~7 rejects ADB open payloads larger than 4096 bytes
-# by aborting the connection, so keep the base64 chunk under ~2.8 KB for Android 5.x TVs.
++CHUNK = 48 * 1024 # raw bytes per shell command (base64 grows it by 4/3); capped per TV in main()
++# adbd before Android 7 aborts the connection on an ADB "open" payload over 4096 bytes, which
++# Android 5.x TVs announce as their max data size. Newer adbd takes the full 48 KB.
def main():
@@@ -19,11 -21,11 +21,12 @@@
data = open(local, "rb").read()
want = hashlib.md5(data).hexdigest()
dev = tv.connect()
++ chunk = min(CHUNK, dev.max_chunk_size * 3 // 4 - 64) # base64 of the chunk plus the echo must fit one payload
tmp = remote + ".b64"
dev.shell(f"rm -f {remote} {tmp}")
-- n = (len(data) + CHUNK - 1) // CHUNK
++ n = (len(data) + chunk - 1) // chunk
for i in range(n):
-- part = base64.b64encode(data[i * CHUNK:(i + 1) * CHUNK]).decode()
++ part = base64.b64encode(data[i * chunk:(i + 1) * chunk]).decode()
out = dev.shell(f"echo '{part}' >> {tmp} && echo ok{i}", read_timeout_s=60.0)
if f"ok{i}" not in out:
print(f"chunk {i} failed: {out}")