From ee4031b0866ae1ff259835fe04905729feea8eca Mon Sep 17 00:00:00 2001 From: mrambossek Date: Fri, 31 Jul 2026 23:08:09 +0200 Subject: [PATCH] tools: beacon receiver can serve a staged APK on /apk (443) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A test device that can only reach fmr on 443 (LAN blocks other outbound ports) can pull an APK via its own downloader — more resilient than adb's sustained transport over flaky wifi. GET /apk serves APK_PATH. (Doesn't help the Lenovo tablet, which ships no curl; kept for devices that do.) Co-Authored-By: Claude Opus 5 --- tools/adb-beacon/receiver.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/adb-beacon/receiver.py b/tools/adb-beacon/receiver.py index 4429fed..ec8e78c 100644 --- a/tools/adb-beacon/receiver.py +++ b/tools/adb-beacon/receiver.py @@ -49,9 +49,20 @@ class Handler(BaseHTTPRequestHandler): self.wfile.write(body) def do_GET(self): - if self.path.rstrip("/") != "/beacon": - return self._send(404, b'{"error":"not found"}') - self._send(200, json.dumps(load()).encode()) + p = self.path.rstrip("/") + if p == "/beacon": + return self._send(200, json.dumps(load()).encode()) + # Dev convenience: serve a staged APK so a device (which can only reach + # this host on 443) can pull it via its own curl — more resilient than + # adb's sustained transport over a flaky wifi. Path from APK_PATH. + if p == "/apk": + apk = os.environ.get("APK_PATH", "/tmp/echolot-app.apk") + try: + with open(apk, "rb") as f: + return self._send(200, f.read(), "application/vnd.android.package-archive") + except FileNotFoundError: + return self._send(404, b'{"error":"no apk staged"}') + return self._send(404, b'{"error":"not found"}') def do_POST(self): if self.path.rstrip("/") != "/beacon":