v0.5.0: bubble for Android 0.5.0 — text from the Rabbit's SIM on the desktop, and chat names and read status sync, through jai
A relay on jai (server/bubble_relay.py, stdlib + SQLite, tailscale address only, bearer token) carries sealed blobs between the desktop and the Rabbit: AES-256-GCM with a key the desktop makes and hands over USB (Sync to Rabbit), so jai can neither read nor forge anything. It deletes what's been picked up, and anything after 14 days. - Desktop (src/main/relay.ts): "Rabbit SIM" is a number to text from, groups included; the SIM's history and new texts arrive; older photos are fetched when shown; names and read/unread/archived go both ways. Settings → Rabbit relay connects it. - Rabbit (Relay.java, RelayJob): no timer of its own for the battery; it rides along with the background checks, plus one network job after a text, a send or a swipe. Each send from the desktop goes out at most once and not after a day. Plain http only to jai and localhost (network_security_config). - scripts/deploy-jai.sh; tests: server unit tests, an end-to-end relay test, and DEVICE=1 relay.device.test.ts against the dev app.
This commit is contained in:
@@ -5,10 +5,16 @@ Its config is marked sandbox, so the app never goes online.
|
||||
|
||||
python3 android/build.py --dev --install && python3 android/tools/push_sandbox.py
|
||||
|
||||
With --relay URL (and RELAY_TOKEN / RELAY_KEY in the environment) the dev app
|
||||
also gets relay settings, e.g. a throwaway local server/bubble_relay.py reached
|
||||
through `adb reverse tcp:18080 tcp:<port>` with --relay http://127.0.0.1:18080.
|
||||
|
||||
Uses the same copy-in mechanism as the desktop installer: files are piped
|
||||
through `adb shell run-as` into the app's private storage.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sqlite3
|
||||
import subprocess
|
||||
import tempfile
|
||||
@@ -26,8 +32,12 @@ def push(local: Path, name: str):
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--relay", help="relay URL as the Rabbit reaches it (token and key from RELAY_TOKEN / RELAY_KEY)")
|
||||
args = ap.parse_args()
|
||||
subprocess.run(["adb", "shell", "am", "force-stop", PKG], check=True)
|
||||
subprocess.run(["adb", "shell", f"run-as {PKG} sh -c 'mkdir -p files && rm -f files/messages.db*'"], check=True)
|
||||
# Fresh: no history, and no relay cursors left from an earlier run.
|
||||
subprocess.run(["adb", "shell", f"run-as {PKG} sh -c 'mkdir -p files && rm -f files/messages.db* shared_prefs/relay.xml'"], check=True)
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
db = Path(d) / "messages.db"
|
||||
con = sqlite3.connect(db)
|
||||
@@ -65,6 +75,10 @@ def main():
|
||||
NAMED = "5415550101,5415550140"
|
||||
rows.append((2**52 + 20, GV, NAMED, "in", "Booked the cabin!", now - 600 * m, "5415550140"))
|
||||
con.execute("INSERT INTO read_state (did, contact, last_read_ts, name, name_ts) VALUES (?, ?, 0, 'Cabin trip', ?)", (GV, NAMED, now))
|
||||
# The Rabbit's SIM (did 'sim', ids from 2^51 like Sim.java's).
|
||||
SIM_BASE = 2**51
|
||||
rows.append((SIM_BASE + 1, "sim", "5415550150", "in", "Texting your SIM number now", now - 20 * m, None))
|
||||
rows.append((SIM_BASE + 2, "sim", "5415550150", "out", "Got it, this is the SIM", now - 19 * m, None))
|
||||
con.executemany("INSERT INTO messages (id, did, contact, direction, body, ts, sender) VALUES (?,?,?,?,?,?,?)", rows)
|
||||
con.execute("INSERT INTO kv VALUES ('unread_floor', '0')")
|
||||
con.execute("INSERT INTO gv_threads VALUES (?, ?, 'g.demo')", (GV, GROUP))
|
||||
@@ -77,6 +91,7 @@ def main():
|
||||
"gvoice": {"number": GV, "cookies": {}},
|
||||
"dids": [{"did": VOIP, "description": "Demo"}],
|
||||
"defaultDid": VOIP,
|
||||
**({"relay": {"url": args.relay, "token": os.environ["RELAY_TOKEN"], "key": os.environ["RELAY_KEY"]}} if args.relay else {}),
|
||||
}))
|
||||
push(db, "messages.db")
|
||||
push(cfg, "config.json")
|
||||
|
||||
Reference in New Issue
Block a user