android-web-otg 0.2.1__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- android_web_otg-0.2.1.data/scripts/android-web-otg.exe +0 -0
- android_web_otg-0.2.1.dist-info/METADATA +357 -0
- android_web_otg-0.2.1.dist-info/RECORD +6 -0
- android_web_otg-0.2.1.dist-info/WHEEL +4 -0
- android_web_otg-0.2.1.dist-info/licenses/LICENSE +21 -0
- android_web_otg-0.2.1.dist-info/sboms/android-web-otg.cyclonedx.json +3432 -0
|
Binary file
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: android-web-otg
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Environment :: Console
|
|
6
|
+
Classifier: Environment :: Web Environment
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
|
+
Classifier: Operating System :: MacOS
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Programming Language :: Rust
|
|
12
|
+
Classifier: Topic :: System :: Hardware :: Universal Serial Bus (USB)
|
|
13
|
+
Classifier: Topic :: Utilities
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Summary: Recover & steer any broken-screen Android phone over USB OTG (AOAv2 HID) from your browser or MCP agent — pure Rust, with optional live ADB Screen Mirroring.
|
|
16
|
+
Keywords: android,aoav2,usb-otg,hid,mcp,broken-screen,screen-mirror
|
|
17
|
+
Home-Page: https://github.com/Maverick0351a/android-web-otg
|
|
18
|
+
Author: Oscillink
|
|
19
|
+
License: MIT
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
22
|
+
Project-URL: Homepage, https://github.com/Maverick0351a/android-web-otg
|
|
23
|
+
Project-URL: Issues, https://github.com/Maverick0351a/android-web-otg/issues
|
|
24
|
+
Project-URL: Repository, https://github.com/Maverick0351a/android-web-otg
|
|
25
|
+
|
|
26
|
+
<div align="center">
|
|
27
|
+
<img src="docs/logo.svg" alt="android-web-otg logo" width="108" />
|
|
28
|
+
<h1>android-web-otg</h1>
|
|
29
|
+
<p><sub><strong>by Oscillink</strong></sub></p>
|
|
30
|
+
<p>
|
|
31
|
+
<strong>Recover and steer any broken-screen Android phone from your browser over USB OTG (<code>AOAv2 HID</code>)</strong><br />
|
|
32
|
+
Pure Rust for <strong>Linux, macOS, and Windows</strong> — works before USB Debugging (<code>adb</code>) is enabled, plus optional live Screen Mirroring and a built-in stdio MCP server once ADB is on.
|
|
33
|
+
</p>
|
|
34
|
+
<p>
|
|
35
|
+
<a href="https://github.com/Maverick0351a/android-web-otg/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Maverick0351a/android-web-otg/ci.yml?branch=main&style=flat-square&logo=githubactions&logoColor=white&label=CI&labelColor=0a0a0d" alt="CI Status" height="18" /></a>
|
|
36
|
+
<a href="https://github.com/Maverick0351a/android-web-otg/releases"><img src="https://img.shields.io/github/v/release/Maverick0351a/android-web-otg?style=flat-square&label=Release&labelColor=0a0a0d&color=ef233c" alt="Latest Release" height="18" /></a>
|
|
37
|
+
<a href="Cargo.toml"><img src="https://img.shields.io/badge/Rust-1.85%2B-ef233c?style=flat-square&logo=rust&logoColor=white&labelColor=0a0a0d" alt="Rust 1.85+" height="18" /></a>
|
|
38
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/Maverick0351a/android-web-otg?style=flat-square&label=License&labelColor=0a0a0d&color=22c55e" alt="License" height="18" /></a>
|
|
39
|
+
</p>
|
|
40
|
+
<p>
|
|
41
|
+
<a href="#demo--screenshots">Demo</a> ·
|
|
42
|
+
<a href="#how-it-works">How It Works</a> ·
|
|
43
|
+
<a href="#platform-support--usb-permissions">Platform Support</a> ·
|
|
44
|
+
<a href="#quickstart">Quickstart</a> ·
|
|
45
|
+
<a href="#screen-mirroring--ai-agents-mcp">Mirroring & MCP</a> ·
|
|
46
|
+
<a href="#deployment-templates">Docker & Systemd</a> ·
|
|
47
|
+
<a href="#security-architecture">Security</a>
|
|
48
|
+
</p>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
> [!IMPORTANT]
|
|
54
|
+
> **No video feed while USB Debugging is off:** Android does not expose screen pixels over USB before ADB is authorized. When `adb` is disabled, `android-web-otg` gives you **physical USB mouse, keyboard, TalkBack shortcuts, and hardware USB inspection** over **EP0 AOAv2 HID** so you can unlock the phone and turn on USB Debugging. Once ADB is authorized, click **Mirror Screen** in the cockpit to stream live video (**H.264 WebCodecs** or **PNG**) inside the phone bezel with calibrated **Tap Mirror** clicks and swipes.
|
|
55
|
+
|
|
56
|
+
## Demo & Screenshots
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
<img src="docs/demo.gif" alt="Live Demo — Free Trackpad, Inline Guide, TalkBack, and USB Specs Modal" width="900" />
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
| Cockpit Dashboard (Volcanic Obsidian UI) | USB & AOAv2 Hardware Specs Modal |
|
|
63
|
+
|---|---|
|
|
64
|
+
|  |  |
|
|
65
|
+
|
|
66
|
+
- **Calm, popup-free controls:** **Free Trackpad** is active by default so dragging and tapping never trigger browser Pointer Lock banners unless you choose **Pointer Lock** (`Esc` releases). **? Guide** expands inline below the header, and actions confirm in place without floating toast overlays.
|
|
67
|
+
- **Pre-ADB inspection:** Click **Phone Specs** at any time to read USB `VID:PID`, AOAv2 protocol version, negotiated link speed, `bMaxPower`, bus/address, and active interface descriptors directly over USB.
|
|
68
|
+
|
|
69
|
+
## Why `android-web-otg`?
|
|
70
|
+
|
|
71
|
+
| Capability | Details |
|
|
72
|
+
|---|---|
|
|
73
|
+
| **Pre-ADB Broken-Screen Rescue** | Uses Android Open Accessory v2 (`EP0` requests `51`, `54`, `55`, `56`, `57`) so hardware mouse and keyboard work before USB Debugging is enabled — leaving MTP and `adb` interfaces untouched. |
|
|
74
|
+
| **Native USB Adapter via `nusb`** | Pure-Rust async [`nusb`](https://crates.io/crates/nusb) (`features = ["tokio"]`) talks directly to **Linux `usbfs`**, **macOS `IOKit`**, and **Windows `WinUSB`** with zero `libusb` or Python/Node runtime. |
|
|
75
|
+
| **Built-In Live Screen Mirror** | Optional pure-Rust mirror (`src/mirror.rs`) uses host `adb exec-out` with **WebCodecs H.264** (`screenrecord`), instant first-frame & automatic **PNG** fallback (`screencap`), and letterbox-accurate **Tap Mirror** clicks & swipes right inside the phone bezel. |
|
|
76
|
+
| **Built-In Stdio MCP & Skill** | Launch `android-web-otg --mcp` to give **Antigravity, Claude Code, Cursor, Codex, or Gemini CLI** 9 structured tools (`otg_status`, `otg_mouse`, `otg_screen_capture`, `otg_tap`, etc.), paired with [`skills/android-web-otg/SKILL.md`](skills/android-web-otg/SKILL.md). |
|
|
77
|
+
| **Resilient `f_accessory` Timing** | Waits `200 ms` after registering HID report descriptors for Android's kernel `hid_add_device()` workqueue and retries transient `Stall` frames cleanly without unregistering HID IDs. |
|
|
78
|
+
| **Zero-Storage Secret Isolation** | Quick Unlock PINs/passcodes and `ANDROID_WEB_OTG_UNLOCK_CODE` are ASCII-validated, zeroized in memory (`zeroize`), never logged or saved in `localStorage`, and never exposed to MCP tools. |
|
|
79
|
+
| **Local Telemetry & JSONL Export** | Lock-free `AtomicU64` packet/reconnect/error counters, `avg / last / max` HID round-trip latency in the UI, Server-Sent Events (`/api/telemetry/stream` with `Last-Event-ID`), and 1-click JSONL export. |
|
|
80
|
+
|
|
81
|
+
## How It Works
|
|
82
|
+
|
|
83
|
+
```mermaid
|
|
84
|
+
flowchart LR
|
|
85
|
+
UI["Browser Cockpit or MCP Agent<br/>(Free Trackpad · Tap Mirror · Quick Unlock)"] <-->|"WS /ws/hid, /ws/screen & SSE · Stdio MCP"| Srv["android-web-otg<br/>(Pure Rust: Axum · AoaActor · Mirror)"]
|
|
86
|
+
Srv -->|"EP0 AOAv2 HID (Zero ADB)"| Usb["nusb Native USB Adapter<br/>(Linux usbfs · macOS IOKit · Windows WinUSB)"]
|
|
87
|
+
Srv -.->|"Optional ADB Video & Tap"| Adb["Host adb exec-out<br/>(H.264 WebCodecs / PNG)"]
|
|
88
|
+
Usb --> Phone["Android Phone<br/>(Cracked Screen / ADB Off or On)"]
|
|
89
|
+
Adb -.-> Phone
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Platform Support & USB Permissions
|
|
93
|
+
|
|
94
|
+
| Host OS | Binary Support | Driver / Setup Notes |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| **Linux** (Desktop, Laptop, Raspberry Pi, Headless Server) | **Native (`x86_64`, `aarch64`)** — uses kernel `usbfs` directly | Install [`deploy/51-android.rules`](deploy/51-android.rules) (`MODE="0660", GROUP="plugdev", TAG+="uaccess"`, 29 OEM VIDs + `ID_MTP_DEVICE`), reload udev, join `plugdev`, and replug USB. If using our **non-root Docker container** (`USER otg`), you still need `51-android.rules` on the host. |
|
|
97
|
+
| **macOS** (`Apple Silicon` & `Intel`) | **Native (`aarch64`, `x86_64`)** — uses Apple `IOKit` directly | Close exclusive MTP/PTP helpers (*Android File Transfer*, *OpenMTP*, Image Capture / `ptpcamera`) if the device reports busy. Clear Gatekeeper quarantine once on downloaded binaries (`xattr -d com.apple.quarantine`). *(Physical hardware verification so far is Linux-tested; macOS IOKit builds and passes unit/integration CI tests.)* |
|
|
98
|
+
| **Windows 10/11** (`x86_64`) | **Native `.exe`** *(or WSL2)* — uses Microsoft `WinUSB` | **Important when ADB is OFF:** almost every Android phone defaults to MTP (`0x06`, claimed by inbox `WUDFWpdMtp`), which blocks raw EP0 transfers. Nearly all ADB-off Windows users will bind **WinUSB once via Zadig** (same Windows limitation as `scrcpy --otg`) **or** attach USB into **WSL2** with `usbipd-win`. |
|
|
99
|
+
|
|
100
|
+
## Quickstart
|
|
101
|
+
|
|
102
|
+
### Install Options (Prebuilt, Rust, Python `uvx`, Docker)
|
|
103
|
+
|
|
104
|
+
- **GitHub Releases (Direct Binaries):** Grab the archive for Linux (`x86_64` / `aarch64`), macOS (`aarch64` / `x86_64`), or Windows (`x86_64`) from [**Releases**](https://github.com/Maverick0351a/android-web-otg/releases/latest) (each paired with `SHA256SUMS-*.txt`).
|
|
105
|
+
- **Rust (`crates.io`):** `cargo install android-web-otg --locked`
|
|
106
|
+
- **Python / AI Agents (`uvx` / `pipx` via PyPI):** `uvx android-web-otg` (or `uvx android-web-otg --mcp`)
|
|
107
|
+
- **Docker / Raspberry Pi (`ghcr.io` `amd64` + `arm64`):** `docker pull ghcr.io/maverick0351a/android-web-otg:latest` *(see [Docker & Systemd](#deployment-templates) below)*
|
|
108
|
+
|
|
109
|
+
### 1. Prebuilt Binary Setup by OS
|
|
110
|
+
|
|
111
|
+
Grab your OS archive from the [**latest GitHub Release**](https://github.com/Maverick0351a/android-web-otg/releases/latest) (or run `cargo install android-web-otg --locked`):
|
|
112
|
+
|
|
113
|
+
#### macOS
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
tar -xzf android-web-otg-v*-apple-darwin.tar.gz
|
|
117
|
+
xattr -d com.apple.quarantine ./android-web-otg
|
|
118
|
+
./android-web-otg
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Open **`http://127.0.0.1:8095`** in Safari or Chrome. Close *Android File Transfer* / *OpenMTP* (or kill `ptpcamera` if Image Capture grabs the device).
|
|
122
|
+
|
|
123
|
+
#### Windows 10/11
|
|
124
|
+
|
|
125
|
+
1. Extract `android-web-otg.exe` from the release `.zip`.
|
|
126
|
+
2. **If your phone has ADB off / reports USB access denied (`WUDFWpdMtp`):**
|
|
127
|
+
- Download [**Zadig**](https://zadig.akeo.ie/), open **Options → List All Devices**, select your Android device (composite parent or MTP/ADB interface), choose **WinUSB**, and click **Replace Driver**.
|
|
128
|
+
- *(Reverting later takes 10 seconds in **Device Manager** → right-click device → **Uninstall device** → check **Attempt to remove the driver** → replug USB to restore Windows Explorer MTP.)*
|
|
129
|
+
3. Run the bridge in PowerShell and open **`http://127.0.0.1:8095`**:
|
|
130
|
+
```powershell
|
|
131
|
+
.\android-web-otg.exe
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
<details>
|
|
135
|
+
<summary>Optional Windows zero-Zadig setup using WSL2 + usbipd-win</summary>
|
|
136
|
+
|
|
137
|
+
1. Install `usbipd-win` once in an elevated PowerShell prompt:
|
|
138
|
+
```powershell
|
|
139
|
+
winget install usbipd
|
|
140
|
+
```
|
|
141
|
+
2. Find and attach your Android phone's `<BUSID>` to WSL2:
|
|
142
|
+
```powershell
|
|
143
|
+
usbipd list
|
|
144
|
+
usbipd bind --busid <BUSID>
|
|
145
|
+
usbipd attach --wsl --busid <BUSID>
|
|
146
|
+
```
|
|
147
|
+
3. Inside **WSL2 Ubuntu/Debian**, use the **Linux** `.tar.gz` release binary (or `cargo build --release` inside WSL2 — not the Windows `.exe`), install [`deploy/51-android.rules`](deploy/51-android.rules) (ensure `systemd=true` is enabled in `/etc/wsl.conf` so `systemd-udevd` runs, or fix permissions / run `plugdev` reload), and run:
|
|
148
|
+
```bash
|
|
149
|
+
./android-web-otg
|
|
150
|
+
```
|
|
151
|
+
Then open **`http://127.0.0.1:8095`** in your Windows browser.
|
|
152
|
+
|
|
153
|
+
</details>
|
|
154
|
+
|
|
155
|
+
#### Linux (Desktop, Laptop, Raspberry Pi, or Headless Server)
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
tar -xzf android-web-otg-v*-linux-gnu.tar.gz
|
|
159
|
+
sudo cp deploy/51-android.rules /etc/udev/rules.d/
|
|
160
|
+
sudo udevadm control --reload-rules && sudo udevadm trigger
|
|
161
|
+
|
|
162
|
+
# Non-Debian distros (Fedora, Arch, RHEL) may need: sudo groupadd -f plugdev
|
|
163
|
+
sudo usermod -aG plugdev "$USER"
|
|
164
|
+
# Log out and back in (or run `newgrp plugdev`), and unplug + replug the USB data cable
|
|
165
|
+
|
|
166
|
+
./android-web-otg
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Open **`http://127.0.0.1:8095`** in your browser.
|
|
170
|
+
|
|
171
|
+
### 2. Build from Source
|
|
172
|
+
|
|
173
|
+
Prerequisites: [Rust 1.85+](https://rustup.rs/) (`rustup`), `git`, and your OS C/linker toolchain (**Windows:** Visual Studio C++ Build Tools; **macOS:** `xcode-select --install`; **Linux:** `build-essential` / `gcc`).
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
git clone https://github.com/Maverick0351a/android-web-otg.git
|
|
177
|
+
cd android-web-otg
|
|
178
|
+
cargo build --release --locked
|
|
179
|
+
./target/release/android-web-otg
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
> [!TIP]
|
|
183
|
+
> **Dead or pitch-black LCD?** Hold **Volume Up + Volume Down** on the phone for ~3 seconds to toggle Android **TalkBack**, then switch to the **TalkBack (Broken LCD)** tab in **Quick Controls** (`Alt+←`, `Alt+→`, `Alt+Enter`) to navigate by spoken feedback and turn on **Developer Options → USB debugging**.
|
|
184
|
+
|
|
185
|
+
## Screen Mirroring & AI Agents (`--mcp`)
|
|
186
|
+
|
|
187
|
+
### Live Screen Mirroring (Once USB Debugging Is Enabled)
|
|
188
|
+
|
|
189
|
+
1. Use **Free Trackpad** / **Quick Unlock** / **TalkBack** to enable **USB debugging** on the phone (`Settings → Developer options`), and accept the **"Allow USB debugging?"** RSA prompt (`Tab → Tab → Enter` or mouse click).
|
|
190
|
+
2. Ensure [`adb`](https://developer.android.com/tools/releases/platform-tools) is on your `PATH` (or pass `--adb-path /path/to/adb`). The header pill switches to **`Mirror: Ready`**.
|
|
191
|
+
3. Click **Mirror Screen** above the phone chassis:
|
|
192
|
+
- **`Auto (H.264 / PNG)`** captures an instant PNG frame first, streams low-latency `screenrecord` Annex-B **H.264** into your browser's `VideoDecoder`, and automatically falls back to **PNG** on plain HTTP LAN/Tailscale or unsupported decoders.
|
|
193
|
+
- Switch between **Free Trackpad** (steer hardware USB pointer over live video) and **Tap Mirror** (direct letterbox-calibrated pixel taps and drag swipes via ADB).
|
|
194
|
+
|
|
195
|
+
### Built-In Stdio MCP Server (`android-web-otg --mcp`)
|
|
196
|
+
|
|
197
|
+
Add `android-web-otg` directly to **Antigravity, Claude Code, Cursor, Codex, or Gemini CLI** — zero Python or Node wrapper needed. Use `uvx` for zero-setup remote launching (recommended once published on PyPI) or point directly at the native binary:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"mcpServers": {
|
|
202
|
+
"android-web-otg": {
|
|
203
|
+
"command": "uvx",
|
|
204
|
+
"args": ["android-web-otg", "--mcp"],
|
|
205
|
+
"env": {
|
|
206
|
+
"ANDROID_WEB_OTG_ADB": "adb"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
<details>
|
|
214
|
+
<summary>Alternative: point MCP directly at a local/prebuilt <code>android-web-otg</code> binary</summary>
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"mcpServers": {
|
|
219
|
+
"android-web-otg": {
|
|
220
|
+
"command": "android-web-otg",
|
|
221
|
+
"args": ["--mcp"],
|
|
222
|
+
"env": {
|
|
223
|
+
"ANDROID_WEB_OTG_ADB": "adb"
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
</details>
|
|
231
|
+
|
|
232
|
+
And copy [`skills/android-web-otg/SKILL.md`](skills/android-web-otg/SKILL.md) into your agent's skills folder so agents automatically follow the two-phase **Pre-ADB Rescue → Post-ADB Visual** workflow and never request phone PINs in chat logs.
|
|
233
|
+
|
|
234
|
+
| MCP Tool | Phase | Purpose |
|
|
235
|
+
|---|---|---|
|
|
236
|
+
| `otg_status` / `otg_specs` | Pre & Post ADB | Inspect live USB AOAv2 state, ADB mirror state, resolution, and hardware descriptors |
|
|
237
|
+
| `otg_mouse` / `otg_swipe_up` / `otg_key` / `otg_text` | Pre-ADB (AOAv2 HID) | Wake phone, steer mouse, trigger TalkBack / Home / Back, accept ADB RSA dialog, type non-secret text |
|
|
238
|
+
| `otg_screen_capture` / `otg_tap` / `otg_swipe` | Post-ADB | Return inline Base64 PNG frame to vision agents and send exact pixel taps or swipes |
|
|
239
|
+
|
|
240
|
+
## Common CLI Flags
|
|
241
|
+
|
|
242
|
+
By default `android-web-otg` binds to `--host 127.0.0.1 --port 8095`.
|
|
243
|
+
|
|
244
|
+
**macOS / Linux (bash/zsh):**
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Bind to a private VPN/Tailscale or LAN IP (token is REQUIRED when non-loopback; open TCP 8095 in firewall)
|
|
248
|
+
export ANDROID_WEB_OTG_TOKEN="replace-with-strong-random-token"
|
|
249
|
+
android-web-otg --host <tailscale-or-lan-ip> --port 8095
|
|
250
|
+
|
|
251
|
+
# Pin by USB serial or VID/PID, ignore an unrelated USB device, set custom adb, and save JSONL telemetry
|
|
252
|
+
android-web-otg --vid 0e8d --pid 2008 --serial ABC123456 --ignore-vid 148f --adb-path /usr/bin/adb --log-file ./otg-telemetry.jsonl
|
|
253
|
+
|
|
254
|
+
# Single-shot auto-insert of unlock PIN/password once per newly attached phone
|
|
255
|
+
export ANDROID_WEB_OTG_UNLOCK_CODE="1234"
|
|
256
|
+
android-web-otg --auto-unlock --unlock-wake swipe
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Windows (PowerShell):**
|
|
260
|
+
|
|
261
|
+
```powershell
|
|
262
|
+
$env:ANDROID_WEB_OTG_TOKEN = "replace-with-strong-random-token"
|
|
263
|
+
.\android-web-otg.exe --host <tailscale-or-lan-ip> --port 8095
|
|
264
|
+
|
|
265
|
+
$env:ANDROID_WEB_OTG_UNLOCK_CODE = "1234"
|
|
266
|
+
.\android-web-otg.exe --auto-unlock --unlock-wake swipe
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Hardware Verification
|
|
270
|
+
|
|
271
|
+
Verified live (Linux Docker host + pure-Rust `v0.1` core) against a physical broken-screen Android phone (**`PCD Bengal Max`**, USB `0e8d:2008`, MediaTek, High Speed 480 Mbps, 500 mA) running inside an unprivileged non-root container (`--cap-drop=ALL`, `USER otg`):
|
|
272
|
+
|
|
273
|
+
- **AOAv2 HID attach:** Attached cleanly in `mtp` configuration (`AOA v2`) without claiming MTP or requiring `adb`.
|
|
274
|
+
- **Physical screen wakeup & HID response:** Verified directly on hardware that the broken phone's display lit up and responded live to WebSocket HID cursor movements and left clicks at **`0.42–0.60 ms` EP0 round-trip latency** with zero stalled transfers.
|
|
275
|
+
- **Clean shutdown:** `SIGINT` / `SIGTERM` unregisters both virtual HID devices (`hid=1` mouse, `hid=2` keyboard) cleanly (~`0.12s` stop time).
|
|
276
|
+
|
|
277
|
+
## Deployment Templates
|
|
278
|
+
|
|
279
|
+
<details>
|
|
280
|
+
<summary><strong>Linux udev rules, systemd service, and least-privilege non-root Docker commands</strong></summary>
|
|
281
|
+
|
|
282
|
+
- **`udev` rules (`0660`, `plugdev`, `uaccess`):** [`deploy/51-android.rules`](deploy/51-android.rules)
|
|
283
|
+
- **Hardened `systemd` service:** [`deploy/android-web-otg.service`](deploy/android-web-otg.service)
|
|
284
|
+
- Requires creating the service user and installing the binary:
|
|
285
|
+
```bash
|
|
286
|
+
sudo groupadd -f plugdev
|
|
287
|
+
sudo useradd -r -g plugdev -s /sbin/nologin otg
|
|
288
|
+
sudo install -m 0755 android-web-otg /usr/local/bin/android-web-otg
|
|
289
|
+
sudo install -m 0600 /dev/null /etc/android-web-otg.env # add ANDROID_WEB_OTG_TOKEN / ANDROID_WEB_OTG_UNLOCK_CODE
|
|
290
|
+
sudo cp deploy/android-web-otg.service /etc/systemd/system/
|
|
291
|
+
sudo systemctl daemon-reload && sudo systemctl enable --now android-web-otg
|
|
292
|
+
```
|
|
293
|
+
- `ANDROID_WEB_OTG_UNLOCK_CODE` enables the UI **"Unlock with Server Preset"** button; add `--auto-unlock` to `ExecStart` to auto-type on USB attach.
|
|
294
|
+
- **Least-privilege non-root Docker container (`debian:bookworm-slim`, `USER otg`, `linux/amd64` & `linux/arm64`, zero `--privileged`):**
|
|
295
|
+
> Install [`deploy/51-android.rules`](deploy/51-android.rules) on the Linux host first so `/dev/bus/usb/*/*` grants `0660 plugdev` write access.
|
|
296
|
+
```bash
|
|
297
|
+
# Pull prebuilt multi-arch image from GitHub Packages (or build locally with: docker build -t ghcr.io/maverick0351a/android-web-otg -f deploy/Dockerfile .)
|
|
298
|
+
docker pull ghcr.io/maverick0351a/android-web-otg:latest
|
|
299
|
+
|
|
300
|
+
PLUGDEV_GID="$(getent group plugdev | cut -d: -f3 || true)"
|
|
301
|
+
|
|
302
|
+
# Default container entrypoint listens on 0.0.0.0:8095 and fails closed without ANDROID_WEB_OTG_TOKEN:
|
|
303
|
+
docker run --rm --network host \
|
|
304
|
+
--cap-drop=ALL \
|
|
305
|
+
--device-cgroup-rule='c 189:* rmw' \
|
|
306
|
+
-v /dev/bus/usb:/dev/bus/usb \
|
|
307
|
+
${PLUGDEV_GID:+--group-add "$PLUGDEV_GID"} \
|
|
308
|
+
-e ANDROID_WEB_OTG_TOKEN="replace-with-strong-random-token" \
|
|
309
|
+
ghcr.io/maverick0351a/android-web-otg:latest
|
|
310
|
+
|
|
311
|
+
# Or override entrypoint for loopback-only testing without --token:
|
|
312
|
+
docker run --rm --network host \
|
|
313
|
+
--cap-drop=ALL \
|
|
314
|
+
--device-cgroup-rule='c 189:* rmw' \
|
|
315
|
+
-v /dev/bus/usb:/dev/bus/usb \
|
|
316
|
+
${PLUGDEV_GID:+--group-add "$PLUGDEV_GID"} \
|
|
317
|
+
--entrypoint /usr/local/bin/android-web-otg \
|
|
318
|
+
ghcr.io/maverick0351a/android-web-otg:latest --host 127.0.0.1 --port 8095
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
</details>
|
|
322
|
+
|
|
323
|
+
## Security Architecture
|
|
324
|
+
|
|
325
|
+
> [!CAUTION]
|
|
326
|
+
> Because `android-web-otg` injects real physical keyboard and mouse HID events into any matched Android device over USB, **never expose it on an untrusted LAN or the public internet without a strong `--token` and firewall/VPN isolation**.
|
|
327
|
+
|
|
328
|
+
- **Fail-closed non-loopback binds:** Starting HTTP mode on any non-loopback `--host` (such as `0.0.0.0`, `::`, or a LAN/VPN IP) without a non-empty `--token` / `ANDROID_WEB_OTG_TOKEN` **exits immediately with status code `2`** before touching USB (`validate_bind_auth` in `src/server.rs`).
|
|
329
|
+
- **Session cookie & header auth:** `POST /api/auth` validates the token using constant-time comparison (`subtle`) and issues an `HttpOnly; SameSite=Strict` CSPRNG session cookie. Query-string `?token=` URL parameters are rejected to keep credentials out of browser history and logs.
|
|
330
|
+
- **DNS rebinding & CSWSH defense:** On loopback binds (`127.0.0.0/8`, `localhost`, `::1`), `/api/*` and `/ws/*` enforce a strict `Host` allowlist (`allowed_hosts_for_bind`). When `Origin` or `Sec-Fetch-Site` headers are present they are verified as same-origin, and WebSocket upgrades on both `/ws/hid` and `/ws/screen` strictly require a matching `Origin` header.
|
|
331
|
+
- **Secret isolation:** Manual unlock codes and `ANDROID_WEB_OTG_UNLOCK_CODE` are ASCII-validated, normalized, wrapped in `Zeroizing`, excluded from `localStorage`, JSON responses, telemetry logs, and omitted from MCP tool schemas.
|
|
332
|
+
|
|
333
|
+
## Troubleshooting & Limitations
|
|
334
|
+
|
|
335
|
+
<details>
|
|
336
|
+
<summary><strong>Common issues, USB cables, keyboard layout, and vs. scrcpy</strong></summary>
|
|
337
|
+
|
|
338
|
+
- **Phone not detected (`No Android USB device detected`):** Check your USB cable first — **charge-only cables lack `D+/D-` data pins**. Swap to a known data cable or direct motherboard port.
|
|
339
|
+
- **Text or PIN characters mistyped:** HID scancodes in `src/hid.rs` use the **US QWERTY** layout and accept ASCII printable characters only. Switch Android's on-device physical keyboard layout to English (US) if punctuation/letters remap.
|
|
340
|
+
- **Before First Unlock (BFU) / OEM AOAv2 blocks:** Android requires hardware PIN entry on a cold reboot before unlocking credential-encrypted storage; some devices restrict USB accessories at BFU (`USB Restricted Mode`) or disable `CONFIG_USB_F_ACCESSORY` in custom kernels.
|
|
341
|
+
- **macOS exclusive access / Gatekeeper:** If `android-web-otg` says `"cannot be opened because the developer cannot be verified"`, run `xattr -d com.apple.quarantine ./android-web-otg`. If `IOKit` reports busy, quit *Android File Transfer* / *OpenMTP* / *Image Capture*.
|
|
342
|
+
- **Revert Windows Zadig WinUSB back to MTP:** Open **Device Manager → Universal Serial Bus devices** → right-click the phone → **Uninstall device** → check **Attempt to remove the driver** → replug USB.
|
|
343
|
+
- **How this differs from `scrcpy --otg`:** `scrcpy --otg` is a great native desktop SDL window; `android-web-otg` serves a browser cockpit (trackpad, Quick Unlock, TalkBack macros, USB descriptor inspector, JSONL telemetry, LAN/Tailscale remote rescue) **plus** optional WebCodecs/PNG mirroring and a native stdio MCP server (`--mcp`) with zero `libusb`, `SDL`, or `FFmpeg` dependencies.
|
|
344
|
+
|
|
345
|
+
</details>
|
|
346
|
+
|
|
347
|
+
## Roadmap
|
|
348
|
+
|
|
349
|
+
Multi-device switching, custom clean-room server APK/DEX telemetry (live Accessibility UI tree, battery/thermal/storage stats, 1-click backup), macro recording/replay, and native **Antigravity MCP App** side-pane packaging live in a companion **Oscillink Pro / Android USB Workbench** effort so `android-web-otg` remains a lean, focused, MIT-licensed rescue utility.
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
<div align="center">
|
|
354
|
+
<img src="docs/oscillink-logo.svg" alt="Oscillink" width="96" />
|
|
355
|
+
<p>Built by <strong>Oscillink</strong> · <a href="LICENSE">MIT License</a></p>
|
|
356
|
+
</div>
|
|
357
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
android_web_otg-0.2.1.data/scripts/android-web-otg.exe,sha256=XzHGWpfg_RFHtAsAbvO8r5X-q9hdiWm2BmaHhybe14I,3425280
|
|
2
|
+
android_web_otg-0.2.1.dist-info/METADATA,sha256=WuG_8HzLUWBA35tr2jajhAqrnEB6Tyt3svamcnuV0LQ,23174
|
|
3
|
+
android_web_otg-0.2.1.dist-info/WHEEL,sha256=Uvw7WSmy7Kj2FBk8Va4L_dq4MDW8X5Ynby-pOX3ZNS0,94
|
|
4
|
+
android_web_otg-0.2.1.dist-info/licenses/LICENSE,sha256=xEie0ZuG4RML-Ruc7ASShwjvxooQ1XpGxP0DfuIc_gQ,1092
|
|
5
|
+
android_web_otg-0.2.1.dist-info/sboms/android-web-otg.cyclonedx.json,sha256=TuCJtkCAo7nhvmnXvG7G5zDNjIr0nsDUvxy1EPC8tSk,109029
|
|
6
|
+
android_web_otg-0.2.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Travis Johnson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|