adbcentral 1.0.0__py3-none-any.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.
Files changed (89) hide show
  1. adbcentral/README.md +719 -0
  2. adbcentral/__init__.py +178 -0
  3. adbcentral/__main__.py +6 -0
  4. adbcentral/adbproc.py +443 -0
  5. adbcentral/assets/icon-light.ico +0 -0
  6. adbcentral/assets/icon-light.png +0 -0
  7. adbcentral/assets/icon.ico +0 -0
  8. adbcentral/assets/icon.png +0 -0
  9. adbcentral/audio.py +976 -0
  10. adbcentral/bin/adbcentral-gui.exe +4 -0
  11. adbcentral/cli.py +3652 -0
  12. adbcentral/config.py +397 -0
  13. adbcentral/core.py +6761 -0
  14. adbcentral/devices.py +1544 -0
  15. adbcentral/embed.py +386 -0
  16. adbcentral/embed_qt.py +223 -0
  17. adbcentral/exceptions.py +146 -0
  18. adbcentral/gui/__init__.py +22 -0
  19. adbcentral/gui/__main__.py +7 -0
  20. adbcentral/gui/adb_path.py +90 -0
  21. adbcentral/gui/app.py +643 -0
  22. adbcentral/gui/apps_panel.py +476 -0
  23. adbcentral/gui/connect_dialog.py +750 -0
  24. adbcentral/gui/console.py +4060 -0
  25. adbcentral/gui/control_api.py +752 -0
  26. adbcentral/gui/controls_panel.py +884 -0
  27. adbcentral/gui/deploy_dialog.py +404 -0
  28. adbcentral/gui/device_access.py +154 -0
  29. adbcentral/gui/device_commands.py +145 -0
  30. adbcentral/gui/device_tab.py +7387 -0
  31. adbcentral/gui/display_controls.py +147 -0
  32. adbcentral/gui/display_wall.py +612 -0
  33. adbcentral/gui/embedding.py +452 -0
  34. adbcentral/gui/file_browser.py +4302 -0
  35. adbcentral/gui/file_icons.py +295 -0
  36. adbcentral/gui/file_open.py +283 -0
  37. adbcentral/gui/fileutil.py +1009 -0
  38. adbcentral/gui/flowlayout.py +189 -0
  39. adbcentral/gui/icons.py +617 -0
  40. adbcentral/gui/local_terminal.py +1363 -0
  41. adbcentral/gui/log_panel.py +277 -0
  42. adbcentral/gui/logcat_view.py +2326 -0
  43. adbcentral/gui/main_window.py +4624 -0
  44. adbcentral/gui/mirror_panel.py +6137 -0
  45. adbcentral/gui/page_bar.py +266 -0
  46. adbcentral/gui/phone_panel.py +1864 -0
  47. adbcentral/gui/qtutil.py +532 -0
  48. adbcentral/gui/report_dialog.py +279 -0
  49. adbcentral/gui/screen_view.py +274 -0
  50. adbcentral/gui/screencap_view.py +1304 -0
  51. adbcentral/gui/scrollback.py +703 -0
  52. adbcentral/gui/session_dialog.py +281 -0
  53. adbcentral/gui/sessions.py +432 -0
  54. adbcentral/gui/settings.py +581 -0
  55. adbcentral/gui/settings_dialog.py +552 -0
  56. adbcentral/gui/shell_colors.py +265 -0
  57. adbcentral/gui/shell_icons.py +422 -0
  58. adbcentral/gui/status_bar.py +294 -0
  59. adbcentral/gui/taskbar.py +152 -0
  60. adbcentral/gui/terminal.py +126 -0
  61. adbcentral/gui/theme.py +1429 -0
  62. adbcentral/gui/tools_window.py +409 -0
  63. adbcentral/gui/transfer_log.py +624 -0
  64. adbcentral/gui/transfer_panel.py +667 -0
  65. adbcentral/gui/vtscreen.py +1112 -0
  66. adbcentral/gui/welcome.py +282 -0
  67. adbcentral/launcher.py +780 -0
  68. adbcentral/licenses/GPL-3.0.txt +674 -0
  69. adbcentral/licenses/LGPL-3.0.txt +165 -0
  70. adbcentral/licenses/THIRD-PARTY-NOTICES.md +59 -0
  71. adbcentral/netdoctor.py +391 -0
  72. adbcentral/netfetch.py +340 -0
  73. adbcentral/proctree.py +346 -0
  74. adbcentral/py.typed +0 -0
  75. adbcentral/remote_deploy.py +472 -0
  76. adbcentral/remotefs.py +712 -0
  77. adbcentral/results.py +274 -0
  78. adbcentral/scrcpy.py +901 -0
  79. adbcentral/tools.py +1588 -0
  80. adbcentral/toolsdl.py +2304 -0
  81. adbcentral/touch.py +257 -0
  82. adbcentral/update.py +617 -0
  83. adbcentral/winshell.py +527 -0
  84. adbcentral-1.0.0.dist-info/METADATA +1167 -0
  85. adbcentral-1.0.0.dist-info/RECORD +89 -0
  86. adbcentral-1.0.0.dist-info/WHEEL +5 -0
  87. adbcentral-1.0.0.dist-info/entry_points.txt +7 -0
  88. adbcentral-1.0.0.dist-info/licenses/LICENSE +674 -0
  89. adbcentral-1.0.0.dist-info/top_level.txt +1 -0
adbcentral/README.md ADDED
@@ -0,0 +1,719 @@
1
+ # ADB Central
2
+
3
+ **An Android ADB + scrcpy device toolkit for automotive/embedded Android
4
+ (Android Automotive OS / IVI head units) and general Android work.**
5
+
6
+ ADB Central wraps Google's `adb` and `scrcpy` behind one robust, structured layer
7
+ you can drive three ways from a single install:
8
+
9
+ 1. **Python API** — `import adbcentral` for scripts and test frameworks.
10
+ 2. **CLI** — `adbcentral …`, fully argument-driven (argparse).
11
+ 3. **Desktop GUI** — `adbcentral-gui`, a full PySide6 (Qt 6) app shipped as a
12
+ prebuilt Windows `.exe` (PySide6 baked in) so it runs even where PySide6 has no
13
+ wheel — **no PySide6 install required**.
14
+
15
+ Every action returns a structured result (`CommandResult` / `TransferResult` /
16
+ `StreamResult`), with a **safe mode** that returns an `OperationResult` instead
17
+ of raising, and a typed exception hierarchy (`ADBError` base). All blocking work
18
+ can run on background threads, so it never blocks or crashes the caller.
19
+
20
+ ---
21
+
22
+ ## Table of contents
23
+
24
+ - [Install](#install)
25
+ - [The GUI](#the-gui)
26
+ - [Quick start (API)](#quick-start-api)
27
+ - [Connecting — USB vs network (Wi-Fi / Ethernet)](#connecting--usb-vs-network-wifi--ethernet)
28
+ - [Running shell commands](#running-shell-commands)
29
+ - [Live logcat (continuous logs)](#live-logcat-continuous-logs)
30
+ - [File transfer (push / pull)](#file-transfer-push--pull)
31
+ - [App management](#app-management)
32
+ - [Media — screenshot & screen record](#media--screenshot--screen-record)
33
+ - [Port forwarding (forward / reverse)](#port-forwarding-forward--reverse)
34
+ - [scrcpy mirroring (the visual session)](#scrcpy-mirroring-the-visual-session)
35
+ - [Embedding the GUI in your own program](#embedding-the-gui-in-your-own-program)
36
+ - [Automotive (Android Automotive OS / IVI)](#automotive-android-automotive-os--ivi)
37
+ - [Result objects & error handling](#result-objects--error-handling)
38
+ - [CLI reference](#cli-reference)
39
+ - [API map](#api-map)
40
+ - [Building the GUI exe & releasing](#building-the-gui-exe--releasing)
41
+ - [License](#license)
42
+
43
+ ---
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install adbcentral
49
+ ```
50
+
51
+ That gives you the Python API, the `adbcentral` CLI and `adbcentral-gui`. On Windows
52
+ the wheel bundles the GUI executable, so `adbcentral-gui` works without PySide6. To
53
+ run the GUI from the Python package instead, install the optional GUI dependency:
54
+ `pip install "adbcentral[gui]"`. ADB Central is on PyPI; each GitHub Release has the same wheel and the standalone executable.
55
+
56
+ ADB Central needs Google's **platform-tools (`adb`)** and, for mirroring,
57
+ **`scrcpy`**. It auto-detects them on your `PATH`, in the Android SDK, or in
58
+ common install locations. If they're missing, **let ADB Central fetch them for you**:
59
+
60
+ ```bash
61
+ adbcentral fetch-tools # installs adb and scrcpy
62
+ adbcentral doctor # shows where adb / scrcpy were found
63
+ ```
64
+
65
+ **It's automatic, too.** ADB Central ships neither tool. The first time you run it,
66
+ it installs what is missing: through **winget** on Windows (`Google.PlatformTools`
67
+ and `Genymobile.scrcpy`, no administrator prompt), and where there is no winget or
68
+ it fails, from Google and GitHub into a per-user cache (`~/.adbcentral/tools/`).
69
+ Disable with **`ADBCENTRAL_AUTO_FETCH=0`** (for offline/CI/locked-down machines),
70
+ then install manually with `adbcentral fetch-tools`.
71
+
72
+ - **GUI:** installs automatically on launch (progress bar), or use
73
+ **Tools → adb & scrcpy (versions, updates)…** to update or reinstall them.
74
+ - **Python:** `adbcentral.fetch_tools()` (explicit) or it happens on first device use.
75
+
76
+ > Why not at `pip install` time? Wheels don't run code on install, and
77
+ > downloading during install breaks offline/CI/proxy setups and can hang pip.
78
+ > A first-run install (the Playwright model) gives the same "just works" result.
79
+
80
+ - `adb`: <https://developer.android.com/tools/releases/platform-tools>
81
+ - `scrcpy`: <https://github.com/Genymobile/scrcpy>
82
+ (Windows: `winget install scrcpy` · macOS: `brew install scrcpy` · Linux: `apt install scrcpy`)
83
+
84
+ Override detection any time with `ADBConfig(adb_path=..., scrcpy_path=...)`,
85
+ the `ADBCENTRAL_ADB` / `ADBCENTRAL_SCRCPY` environment variables, or the GUI's
86
+ Settings dialog.
87
+
88
+ ---
89
+
90
+ ## The GUI
91
+
92
+ ```bash
93
+ adbcentral-gui # or: python -m adbcentral.gui (from source)
94
+ adbcentral-shortcut # make a Desktop shortcut (Windows)
95
+ ```
96
+
97
+ A tabbed, multi-device workspace:
98
+
99
+ - **One tab row** — **Sessions** (the session tree), the device tabs, **New ▾**
100
+ (connect a device, save a target, discover Wi-Fi devices, pair, restart the ADB
101
+ server), **Quick connect** and **⛶** (F11: only the tabs and their pages). Tabs
102
+ are closable and movable; a tab's icon says what the device is, with a dot for
103
+ its state. Everything else is in the menus (File, View, Themes, Device, Tools,
104
+ Help) and the status bar's ADB server chip.
105
+ - **Session tree** — saved targets in folders, **Recent** sessions **plus a LIVE
106
+ `adb devices`** list that auto-refreshes, one line each; right-click menu (New /
107
+ Open / Edit / Duplicate / Move to folder / Delete). Double-click a live device to
108
+ open it. Connected devices are saved as targets automatically (Settings →
109
+ Startup). It stands beside the start page and folds away while a device tab is
110
+ open: **Sessions** (or Ctrl+B) brings it over the page, its pin keeps it beside
111
+ the pages.
112
+ - **Device pages** — listed down the left edge of each device tab, under the
113
+ device's name, with **Split** (pages side by side, stacked or in a grid) and
114
+ **More ▾** (device health, build details, root and mount, go wireless,
115
+ bugreport, a head unit's Phone page) at the bottom. **Screen ▾**, **Screenshot**
116
+ and **Reboot ▾** sit at the top right of the page. **View › Layout**: Standard
117
+ (names under the icons) or Compact (icons only, slimmer rows). Icons are
118
+ colour-coded per section and follow the theme.
119
+ - **Per-device panels (tabs):**
120
+ - **Terminal** — the Android shell, or **PowerShell** / **CMD** on this PC
121
+ (ADB Central's adb first on PATH, `ANDROID_SERIAL` set), each under a framed
122
+ intro naming ADB Central and the session (the Android one shows the device type). Type
123
+ straight into the terminal; **one Enter runs the command**
124
+ (reliable cooked line-editing, with Up/Down history and Ctrl+C). The
125
+ Android shell runs on a device terminal (`adb shell -t -t`), so output
126
+ streams and Stop sends a real Ctrl+C that keeps the shell, as it does
127
+ inside an `adb shell` typed in PowerShell / CMD. Full
128
+ **native text selection + copy/paste**, **save output to file**, a right-click
129
+ menu (Copy / Paste / Save / Send-key: Tab/Esc/Ctrl-C/D/Z…), scrollback, and
130
+ **auto-reconnect** — after a reboot or unplug it detects the dropped shell and
131
+ reconnects when the device comes back.
132
+ - **Logcat** — live viewer with level, history, tag, regex filter and
133
+ highlight, a Crashes preset, pause, clear, save, and **instant stop**.
134
+ - **Files** — **This PC** and **Device** panes with **Push** / **Pull**, drag
135
+ and drop, open in the PC's own apps (a device file's saves go back to the
136
+ device), new folder / file, a built-in editor, copy / paste, rename, delete
137
+ (Recycle Bin locally, Shift+Delete for good), and a **Transfers** panel:
138
+ overall progress, speed and time left, plus each file's size, progress and
139
+ error, with Retry failed and a copyable report. **New tab** (Ctrl+Shift+T)
140
+ opens more Files tabs on the same device. Rows use the system's own file
141
+ icons. Select with a drag beside the names or Ctrl+A; a refused change
142
+ offers **adb root**, **disable-verity** and **remount**, then retries.
143
+ - **Apps** — install (incl. split APKs), list, uninstall, clear, start, stop.
144
+ - **Device Control** — the device screen (Start screen, or open it in a
145
+ separate window) beside a control centre: Back / Home / Recents, power,
146
+ notifications and settings; volume and **media** (via the active media
147
+ session); one tile each for Wi-Fi / Bluetooth / Mobile data / Airplane /
148
+ Hotspot with On and Off; screen on/off, battery and reboot; **app & web
149
+ shortcuts** (open any URL, web-search, launch Browser / YouTube / Spotify /
150
+ Maps / Play Store / Gallery / Calculator / Camera); and a **text-send box
151
+ that types into the device's focused field** — a keyboard for head units /
152
+ devices with no on-screen keyboard.
153
+ - **Phone** — a **dialler** with a keypad (call / end / answer / open in dialler)
154
+ and a live call-state pill, colour-coded **recent calls** with call back, and
155
+ **SMS messages** with a compose box that opens a draft in the device's
156
+ Messages app, all over adb.
157
+ - **IVI Displays** (cars and multi-display devices) — every display side by
158
+ side and controllable, each stopped until you start it (or Start all, which
159
+ starts them one after another), with Stop all / Rescan, and Maximize /
160
+ Restore on each display.
161
+ - **More ▾ → Root and mount** — `adb root`, `remount`, **Make files
162
+ writable…** (root, disable-verity and remount with the reboots they need),
163
+ `mount -o remount,rw /`,
164
+ `disable-verity` (auto sync + reboot prompt).
165
+ - **Screen** — scrcpy as it runs when started by hand, with a named display picker, shown
166
+ inside Device Control (Windows) or in a separate window from the **Screen ▾**
167
+ menu.
168
+ - **Tools → Check for updates / Upgrade** updates ADB Central from GitHub Releases when a newer
169
+ version exists (then refreshes adb/scrcpy and restarts); otherwise it checks
170
+ adb/scrcpy and downloads **only if a newer version exists**.
171
+ - A dark, color-coded **log dock** at the bottom. With it closed, every action
172
+ still shows in the status bar and a small toast, and errors show a large red
173
+ toast with an alert sound.
174
+ - **Settings** (persisted to `~/.adbcentral/settings.json`, applied live):
175
+ theme, terminal font + size, default scrcpy video and audio options,
176
+ adb/scrcpy paths, logcat format, startup behaviour, and the screen
177
+ renderer (scrcpy, or ADB screencap for builds where scrcpy can't run). The
178
+ default pair is Graphite (dark) and Porcelain (light): layered neutral surfaces
179
+ with soft text. Ocean/Sky, Dusk/Lavender, Evergreen/Meadow, Black/White,
180
+ Slate/Mist (cool blue-grey), Night/Paper (warm reading), Mocha/Latte and High
181
+ contrast (dark and light) are extra pairs; View › Toggle dark / light theme switches
182
+ between your last dark and last light theme, and terminal and log views stay
183
+ dark in every theme. The status bar is coloured by state (connected, errors,
184
+ warnings, the ADB server and devices).
185
+ - **Crash-proof:** a startup-failure native popup + crash log, a global
186
+ exception hook that logs and shows a non-fatal popup, and clean thread
187
+ shutdown when a tab closes.
188
+
189
+ The window/app icon is an automotive **speedometer** fused with the **Android
190
+ robot** and a terminal prompt.
191
+
192
+ ---
193
+
194
+ ## Quick start (API)
195
+
196
+ ```python
197
+ from adbcentral import ADBHandler, ADBConfig
198
+
199
+ # USB: the only attached device (or pass serial="..." to pick one)
200
+ with ADBHandler() as dev:
201
+ print(dev.shell("getprop ro.build.version.release").text)
202
+ dev.push("app.apk", "/data/local/tmp/app.apk")
203
+ dev.install("app.apk", grant_perms=True)
204
+
205
+ # live logs, with a regex match + tee to a file
206
+ dev.logcat(tag="ActivityManager", match=r"ANR|FATAL",
207
+ on_line=print, save_to="boot.log", stop_on_match=True)
208
+
209
+ dev.screenshot("shot.png")
210
+ dev.mirror(max_size=1280) # launch scrcpy
211
+ ```
212
+
213
+ The raw adb path is always available at `dev.adb_path`, and any adb command is a
214
+ call away: `dev.adb("shell", "wm", "size")`.
215
+
216
+ ---
217
+
218
+ ## Connecting — USB vs network (Wi-Fi / Ethernet)
219
+
220
+ **USB (local):**
221
+
222
+ ```python
223
+ from adbcentral import ADBHandler, ADBConfig, list_devices
224
+
225
+ for d in list_devices():
226
+ print(d) # serial, state, model…
227
+
228
+ with ADBHandler(ADBConfig(serial="emulator-5554")) as dev:
229
+ ...
230
+ ```
231
+
232
+ **Network (remote head unit / IVI on the bench LAN):**
233
+
234
+ ```python
235
+ # Enable TCP mode once while on USB, then connect wirelessly:
236
+ with ADBHandler() as usb:
237
+ usb.tcpip(5555)
238
+
239
+ with ADBHandler(ADBConfig(host="192.168.1.50", port=5555)) as hu:
240
+ print(hu.shell("getprop ro.build.characteristics").text)
241
+ ```
242
+
243
+ **Remote machine (device plugged into another PC — e.g. an RDP/bench host):**
244
+
245
+ Drive a device that's physically attached to a *different* machine by talking to
246
+ that machine's adb server — you see and control the devices attached over there,
247
+ with your local files used for push/pull.
248
+
249
+ ```bash
250
+ # 1) ON the machine with the device, expose its adb server once:
251
+ adb -a nodaemon server start # listens on all interfaces (port 5037)
252
+
253
+ # 2) From your machine, point ADB Central at it:
254
+ adbcentral devices --adb-host 192.168.1.20 # 'adb devices' THERE
255
+ adbcentral -s SERIAL --adb-host 192.168.1.20 shell -- getprop ro.product.model
256
+ adbcentral -s SERIAL --adb-host 192.168.1.20 logcat --match "ANR|FATAL"
257
+ ```
258
+
259
+ ```python
260
+ from adbcentral import ADBHandler, ADBConfig, remote_devices
261
+
262
+ print(remote_devices("192.168.1.20")) # devices on that machine
263
+ with ADBHandler(ADBConfig(adb_server_host="192.168.1.20", serial="SERIAL")) as dev:
264
+ print(dev.shell("getprop ro.product.model").text)
265
+ dev.logcat(match="ANR|FATAL", on_line=print)
266
+ dev.mirror() # scrcpy via the remote server
267
+ ```
268
+
269
+ In the **GUI**: **New ▾ → Connect to a device…** → **Remote** — enter the
270
+ machine's IP, press **Scan devices there**, pick a device, and it opens a full
271
+ tab (Terminal / Logcat / Files / Device Control / Apps …) driven through that
272
+ server. Tick **Save this target** to keep it in the session tree. (Keep it on a
273
+ trusted network/VPN — the adb server is unauthenticated; or tunnel 5037 over SSH.)
274
+
275
+ **Android 11+ wireless pairing:**
276
+
277
+ ```python
278
+ dev = ADBHandler(ADBConfig(host="192.168.1.50", port=5555))
279
+ dev.pair("192.168.1.50", 37123, "482913") # host:pairing_port + code
280
+ dev.connect()
281
+ ```
282
+
283
+ `connect()` auto-runs `adb connect host:port` for network targets, waits for the
284
+ device, and verifies it's `device` (not `unauthorized`/`offline`) with a clear,
285
+ actionable error if not. A device that has not authorised this PC yet is waited
286
+ for (up to `connect_timeout`) while you accept its "Allow USB debugging?" prompt.
287
+
288
+ ---
289
+
290
+ ## Running shell commands
291
+
292
+ ```python
293
+ res = dev.shell("pm list packages -3")
294
+ print(res.ok, res.exit_code, res.duration)
295
+ for line in res.lines:
296
+ print(line)
297
+
298
+ dev.shell("settings put global development_settings_enabled 1", check=True)
299
+ dev.shell("svc power stayon true", su=True) # as root, through the device's su
300
+
301
+ # an interactive shell session (used by the GUI terminal, usable in scripts)
302
+ sh = dev.open_shell()
303
+ sh.send_line("top -n 1")
304
+ import time; time.sleep(1)
305
+ print(sh.read().decode(errors="replace"))
306
+ sh.close()
307
+ ```
308
+
309
+ ---
310
+
311
+ ## Live logcat (continuous logs)
312
+
313
+ Stream logcat **live, line by line**, cleanly formatted, with regex matching,
314
+ match callbacks, stop-on-match, and tee-to-file — plus tag/priority filters and
315
+ buffer selection.
316
+
317
+ ```python
318
+ # tag + minimum priority, collect ANR/FATAL, save everything, stop on first hit
319
+ res = dev.logcat(tag="ActivityManager", priority="I",
320
+ match=r"ANR|FATAL", on_match=lambda l: print("HIT:", l),
321
+ save_to="session.log", stop_on_match=True,
322
+ buffers=["main", "system", "crash"], clear_first=True)
323
+ print(res.lines, "lines,", len(res.matches), "matches")
324
+
325
+ # arbitrary streaming command + a stop event from another thread
326
+ import threading
327
+ stop = threading.Event()
328
+ dev.logcat(on_line=print, stop_event=stop) # stop.set() to end
329
+
330
+ dev.logcat_clear() # adb logcat -c
331
+ ```
332
+
333
+ `fmt=` sets the `-v` format (default `threadtime`); `dump=True` does `-d`
334
+ (dump current buffer and exit); `tag="A, B"` takes several tags (each exact,
335
+ everything else silenced); `filterspecs=[...]` passes explicit `TAG:LEVEL`
336
+ specs as logcat takes them (add `"*:S"` to silence the other tags);
337
+ `package=`/`pid=` keep one app's lines (Android 7+). Lines are ANSI/control-char
338
+ cleaned by default (`clean=True`). If adb logcat itself fails before printing a
339
+ line, `logcat()` raises `ADBCommandError` with adb's message; a later failure is
340
+ on the result (`res.exit_code`, `res.stderr`), and `grep=` never hides it.
341
+ `ADBHandler.logcat_args(...)` returns the argument list without running
342
+ anything.
343
+
344
+ ---
345
+
346
+ ## File transfer (push / pull)
347
+
348
+ Files **and** folders, with a live percent callback (the GUI shows a progress
349
+ bar):
350
+
351
+ ```python
352
+ dev.push("local_dir/", "/sdcard/local_dir", on_progress=lambda p: print(p, "%"))
353
+ dev.pull("/sdcard/Download", "out/", on_progress=print)
354
+
355
+ tr = dev.push("big.bin", "/data/local/tmp/big.bin")
356
+ print(tr.human_size, tr.human_speed, tr.duration) # 12.0 MB 48.0 MB/s 0.25
357
+ ```
358
+
359
+ ---
360
+
361
+ ## App management
362
+
363
+ ```python
364
+ dev.install("app.apk", replace=True, grant_perms=True) # adb install -r -g
365
+ dev.install_multiple(["base.apk", "split_config.en.apk"]) # split APKs
366
+ dev.uninstall("com.example.app", keep_data=False)
367
+
368
+ dev.list_packages(third_party=True) # -> ["com.foo", ...]
369
+ dev.clear_app("com.example.app") # pm clear
370
+ dev.start_app("com.example.app") # launcher intent
371
+ dev.start_activity("com.example.app/.MainActivity")
372
+ dev.stop_app("com.example.app") # am force-stop
373
+ dev.grant("com.example.app", "android.permission.CAMERA")
374
+ dev.revoke("com.example.app", "android.permission.CAMERA")
375
+ print(dev.current_activity()) # foreground component
376
+ ```
377
+
378
+ ---
379
+
380
+ ## Media — screenshot & screen record
381
+
382
+ ```python
383
+ dev.screenshot("shot.png") # exec-out screencap -p
384
+ png_bytes = dev.screenshot() # raw PNG bytes if no path
385
+
386
+ # record on-device, then pull it (stop early with a stop_event)
387
+ dev.screen_record("clip.mp4", time_limit=20, size="1280x720", bit_rate="8M")
388
+ ```
389
+
390
+ ---
391
+
392
+ ## Port forwarding (forward / reverse)
393
+
394
+ Stoppable handles (`adb forward` / `adb reverse`):
395
+
396
+ ```python
397
+ fwd = dev.forward("tcp:9222", "localabstract:chrome_devtools_remote")
398
+ # ... use 127.0.0.1:9222 on the host ...
399
+ fwd.close() # adb forward --remove
400
+
401
+ with dev.reverse("tcp:8000", "tcp:8000"): # device reaches your PC:8000
402
+ ...
403
+ print(dev.list_forwards())
404
+ ```
405
+
406
+ ---
407
+
408
+ ## scrcpy mirroring (the visual session)
409
+
410
+ Launch real-time screen mirroring + control — the visual analog of opening a
411
+ remote desktop for a host:
412
+
413
+ ```python
414
+ from adbcentral import ScrcpyOptions
415
+
416
+ sess = dev.mirror(max_size=1280, bit_rate="8M", stay_awake=True)
417
+ # ... a scrcpy window is now mirroring & controlling the device ...
418
+ sess.stop()
419
+
420
+ # full control via ScrcpyOptions (crop is great for IVI displays):
421
+ opts = ScrcpyOptions(crop="1920x1080:0:0", display_id=0,
422
+ record="drive.mp4", turn_screen_off=True)
423
+ dev.mirror(opts)
424
+ ```
425
+
426
+ ---
427
+
428
+ ## Embedding the GUI in your own program
429
+
430
+ The whole ADB Central app can live inside a window of your own program and be driven
431
+ from it through a small control API (JSON over HTTP on 127.0.0.1, with a token):
432
+ PyQt5, PySide6, PyQt6, Qt C++, Python Tk, wxPython, C# WinForms and WPF, Win32,
433
+ Delphi or Electron. It runs as a process of its own, fills the area you give it,
434
+ follows its size, keeps its dialogs in front of your window and closes with it.
435
+ It has been tested inside PyQt5, PySide6, PyQt6, Tk, wxPython, WinForms, WPF,
436
+ plain Win32 and Electron programs.
437
+
438
+ ```python
439
+ from adbcentral.embed_qt import ADBCentralWidget # PyQt5, PySide6, PyQt6 or PySide2
440
+
441
+ view = ADBCentralWidget(hide=("menubar",))
442
+ view.started.connect(lambda: view.client.open("R58M12345", page="files"))
443
+ layout.addWidget(view)
444
+ ```
445
+
446
+ From another language, start `ADBCentral-x.y.z-win64.exe --embed-into <window handle>
447
+ --api-port 0 --handshake-file <file>` and call the API. [EMBEDDING.md](https://github.com/NVNKENNEDY/adbcentral/blob/main/EMBEDDING.md) has the
448
+ whole API, and examples for Python, Delphi and C#.
449
+
450
+ ## Automotive (Android Automotive OS / IVI)
451
+
452
+ ```python
453
+ with ADBHandler(ADBConfig(host="192.168.1.50")) as hu:
454
+ info = hu.device_info()
455
+ print(info["manufacturer"], info["model"], "Android", info["android_version"])
456
+ if hu.is_automotive():
457
+ print("This is an Android Automotive OS head unit.")
458
+
459
+ # head units expose several displays (center stack, cluster, passenger):
460
+ for d in hu.list_displays():
461
+ print("display", d["id"], d["size"])
462
+ hu.mirror(display_id=2) # mirror a specific IVI display
463
+
464
+ # the head unit's sound as car playback, as its own batch files start scrcpy
465
+ # (--audio-source=playback --audio-dup --require-audio):
466
+ hu.mirror(ScrcpyOptions().use_automotive_audio())
467
+ ```
468
+
469
+ `device_info()` includes an `automotive` flag and a `kind` from `device_kind()`:
470
+ `automotive` (the Android Automotive feature or build characteristic),
471
+ `headunit` (ordinary Android with no telephony and a landscape display), `tv`,
472
+ `watch`, `tablet` or `phone`, with the evidence in `kind_reason`. Both car kinds
473
+ set `automotive`, so you can branch IVI-specific flows; the GUI forwards such a
474
+ screen's sound as car playback and shows the type in the terminal's intro.
475
+
476
+ **In the GUI**, automotive devices (and any device with several displays) get an
477
+ **IVI Displays** tab that shows every discovered display side by side.
478
+ Each tile is a real, controllable screen with Start / Stop, Separate window,
479
+ Screenshot and Record. Every display starts stopped — opening the tab, a rescan
480
+ or a newly found display never starts one — so start the ones you need, or
481
+ **Start all** to start them one after another; **Maximize** shows one display (Esc restores), and **Start all**, **Stop all** and
482
+ **Rescan** sit at the top (**Device Control → Options → All displays** opens it).
483
+ The Device Control display picker lists every display with its name and size as
484
+ soon as the device connects. The screen starts scrcpy as it runs when it is
485
+ started by hand: its own video, renderer and audio defaults (audio is on or off;
486
+ a head unit's is car playback). If a mirror fails, the log window shows scrcpy's
487
+ own error and the exact command.
488
+
489
+ **Why scrcpy sometimes fails on IVI — and what ADB Central does about it**
490
+
491
+ | Symptom on a head unit | ADB Central's fix |
492
+ |-------------------------------------------|--------------------------------------------------|
493
+ | Black screen / wrong screen mirrored | `list_displays()` + `display_id=` to pick the right one |
494
+ | "Could not open video stream" / encoder error | scrcpy's own error is shown; scrcpy retries at a smaller size by itself; `video_codec="h264"` when you want to try it |
495
+ | Audio capture is unavailable on Android <11 | ADB Central continues with video; disable Audio or use an Android 11+ device |
496
+ | Bandwidth/lag over Wi-Fi | `max_size=`, `bit_rate=`, `max_fps=` |
497
+
498
+ ---
499
+
500
+ ## Result objects & error handling
501
+
502
+ Every operation returns a structured result:
503
+
504
+ | Result | Key fields / props |
505
+ |-----------------|----------------------------------------------------------------|
506
+ | `CommandResult` | `.ok`, `.exit_code`, `.stdout`, `.stderr`, `.duration`, `.text`, `.lines` |
507
+ | `TransferResult`| `.size_bytes`, `.duration`, `.files`, `.human_size`, `.human_speed` |
508
+ | `StreamResult` | `.lines`, `.matches`, `.matched`, `.saved_to` |
509
+ | `OperationResult`| `.success`/`bool`, `.value`, `.error`, `.unwrap()` (safe mode) |
510
+
511
+ **Raise mode (default)** — great for test automation:
512
+
513
+ ```python
514
+ try:
515
+ dev.shell("false", check=True)
516
+ except ADBError as exc:
517
+ print("failed:", exc)
518
+ ```
519
+
520
+ **Safe mode** — great for GUIs (never throws):
521
+
522
+ ```python
523
+ dev = ADBHandler(cfg, safe=True)
524
+ res = dev.install("app.apk")
525
+ if res: # OperationResult is falsy on failure
526
+ print("ok:", res.value)
527
+ else:
528
+ print("error:", res.error)
529
+ ```
530
+
531
+ Exception hierarchy (catch `ADBError` for everything):
532
+ `ADBNotFoundError`, `ADBConnectionError`, `ADBTimeoutError`,
533
+ `ADBNotConnectedError`, `ADBCommandError`, `ADBTransferError`,
534
+ `ADBInstallError`, `ScrcpyError`. A command that runs out of time keeps what it
535
+ printed: `ADBTimeoutError.result` is its `CommandResult` (exit code -1).
536
+
537
+ ---
538
+
539
+ ## CLI reference
540
+
541
+ The complete reference, with every option and example, is at
542
+ <https://github.com/NVNKENNEDY/adbcentral/blob/main/CLI.md> and
543
+ <https://nvnkennedy.github.io/adbcentral/cli.html>.
544
+
545
+ ```
546
+ adbcentral doctor # is adb / scrcpy installed?
547
+ adbcentral fetch-tools [--adb-only|--scrcpy-only --force] # download into the cache
548
+ adbcentral upgrade-tools [--check] # update adb/scrcpy only if a newer version exists
549
+ adbcentral devices # list attached/known devices
550
+ adbcentral info [-s S] # device identity / build / automotive flag
551
+ adbcentral state | serialno | ip | wait [SECONDS] [-s S]
552
+ adbcentral targets list | add NAME usb|network|remote ADDRESS [SERIAL] | remove NAME | export F | import F
553
+ adbcentral shell [-s S] [-- CMD…] [--su --all --batch FILE --keep-going] # no CMD: interactive
554
+ adbcentral adb [-s S] -- ARGS… # any adb command for this device
555
+ adbcentral logcat [-s S] [--tag T --priority I --filter TAG:LEVEL --crashes --grep RE --match RE --save F --clear --dump --tail N]
556
+ adbcentral logcat-clear[-s S]
557
+ adbcentral push [-s S] LOCAL REMOTE
558
+ adbcentral pull [-s S] REMOTE LOCAL
559
+ adbcentral ls [PATH] | mkdir PATH… | touch PATH… | rm [-r] PATH… | mv [-f] SRC DST | cp SRC DST | stat PATH [-s S]
560
+ adbcentral edit [-s S] PATH [--editor "code --wait"] # edit a device text file locally
561
+ adbcentral install [-s S] APK [APK…] [--grant --downgrade --no-replace --test]
562
+ adbcentral uninstall [-s S] PKG [--keep-data]
563
+ adbcentral packages [-s S] [--third-party --system --enabled --disabled --path] [FILTER]
564
+ adbcentral clear [-s S] PKG
565
+ adbcentral start|stop [-s S] PKG
566
+ adbcentral start-activity [-s S] PKG/.Activity [--action A --data URI --es K V --ei K V --ez K V]
567
+ adbcentral activity | grant PKG PERM | revoke PKG PERM [-s S]
568
+ adbcentral displays [-s S] [--method auto|adb|scrcpy]
569
+ adbcentral screenshot [-s S] PATH [--display N]
570
+ adbcentral record [-s S] PATH [--time-limit 30 --size 1280x720 --bit-rate 8M --display N --continuous]
571
+ adbcentral forward [-s S] LOCAL REMOTE [--no-wait] | --list | --remove SPEC | --remove-all
572
+ adbcentral reverse [-s S] REMOTE LOCAL [--no-wait] | --list | --remove SPEC | --remove-all
573
+ adbcentral scrcpy [-s S] [--display-id N --automotive-audio --max-size 1280 --bit-rate 8M --record F --log F --wait …]
574
+ adbcentral connect HOST:PORT
575
+ adbcentral restart-server # kill+start adb server (device-not-visible fixes)
576
+ adbcentral disconnect [HOST:PORT]
577
+ adbcentral tcpip [-s S] [PORT]
578
+ adbcentral pair HOST:PAIRPORT CODE
579
+ adbcentral wireless [-s S] [PORT] # USB device -> Wi-Fi adb in one step
580
+ adbcentral discover [--connect] # find wireless-debugging devices (mDNS)
581
+ adbcentral reboot [-s S] [recovery|bootloader|fastboot|sideload] [--wait --wait-timeout 180]
582
+ adbcentral root | unroot | mount-rw [PATH] [-s S]
583
+ # device controls (same as the GUI's Device controls panel):
584
+ adbcentral key [-s S] KEY… [--longpress --display N] # home|back|recents|vol_up|play_pause|…
585
+ adbcentral text [-s S] [--display N] hello world # type into the focused field
586
+ adbcentral tap [-s S] [X Y] [--display N]
587
+ adbcentral swipe [-s S] X1 Y1 X2 Y2 [--ms 200 --display N]
588
+ adbcentral scroll [-s S] up|down|left|right [--display N]
589
+ adbcentral media [-s S] play-pause|next|previous|stop
590
+ adbcentral brightness [-s S] 0.6 | --get | --level N | --step N
591
+ adbcentral notifications [-s S] expand|collapse
592
+ adbcentral wifi|bluetooth|airplane|hotspot|mobile-data|screen [-s S] on|off
593
+ adbcentral open [-s S] youtube.com | youtube|maps|spotify|browser|play-store
594
+ adbcentral search [-s S] weather today
595
+ adbcentral settings | camera | gallery | calculator | close-apps [-s S]
596
+ adbcentral battery | health [--full -o F] | build-info [--full -o F] | getprop [NAME] [-s S]
597
+ adbcentral bugreport [-s S] [PATH]
598
+ adbcentral remount | disable-verity [--reboot] | enable-verity [--reboot] [-s S]
599
+ adbcentral tap-burst X Y [--count N] [--rate R] [--duration S] [--method auto|input|events]
600
+ adbcentral touch-device | access | make-writable | stop-server [-s S]
601
+ # phone:
602
+ adbcentral dial NUMBER | call NUMBER | answer | end-call | call-state [-s S]
603
+ adbcentral call-log [--limit N] | sms [--limit N] | send-sms NUMBER message… [-s S]
604
+ adbcentral phone-support [-s S] # telephony + the dialler / call / SMS apps it has
605
+ # sharing and maintenance:
606
+ adbcentral serve [--startup-task | --uninstall-startup | --status | --stop] # share this PC's devices
607
+ adbcentral deploy-serve HOST [HOST…] -u USER [--ssl --test --password-stdin] # adbcentral[winrm]
608
+ adbcentral self-update [--check] # upgrade ADB Central, then adb/scrcpy
609
+ adbcentral shortcut # desktop / Start-menu shortcut (Windows)
610
+ adbcentral gui # launch the desktop GUI
611
+ ```
612
+
613
+ `-s` accepts a USB serial, a `host:port` network target, or `@NAME` for a saved
614
+ target. `--timeout` also sets how long a push or pull may go without progress,
615
+ and `--scrcpy-path` picks the scrcpy executable. Add `--json` for machine-readable output. Examples:
616
+
617
+ ```bash
618
+ adbcentral -s 192.168.1.50:5555 shell -- dumpsys power | findstr mWakefulness
619
+ adbcentral logcat --tag ActivityManager --priority I --match "ANR|FATAL" --save boot.log
620
+ adbcentral install base.apk split_config.en.apk --grant
621
+ adbcentral screenshot dash.png
622
+ adbcentral scrcpy --max-size 1280 --bit-rate 8M
623
+ ```
624
+
625
+ Other console scripts: `adbcentral-gui`, `adbcentral-docs`, `adbcentral-shortcut`.
626
+
627
+ ---
628
+
629
+ ## API map
630
+
631
+ ```
632
+ adbcentral
633
+ ├── ADBHandler(config=ADBConfig|None, *, serial=, safe=, quiet=, log_callback=)
634
+ │ ├── connect() / disconnect() / is_connected / get_state() / wait_for_device()
635
+ │ ├── tcpip(port) / connect_tcp(host, port) / pair(host, port, code)
636
+ │ ├── reboot(mode) / root() / unroot() / remount()
637
+ │ ├── getprop(name?) / device_info() / device_kind() / is_automotive()
638
+ │ ├── shell(cmd, su=, check=) / shell_many() / open_shell() -> ShellSession
639
+ │ ├── iter_lines(args) / stream(args, …) / logcat(…) / logcat_clear()
640
+ │ ├── push(local, remote, on_progress=) / pull(remote, local, on_progress=)
641
+ │ ├── install() / install_multiple() / uninstall() / list_packages()
642
+ │ ├── clear_app() / start_app() / start_activity() / stop_app()
643
+ │ ├── grant() / revoke() / current_activity()
644
+ │ ├── keyevent(name|code) / input_text(text) / tap() / swipe()
645
+ │ ├── set_wifi() / set_bluetooth() / set_airplane() / set_hotspot() / screen_on/off()
646
+ │ ├── remount() / mount_rw() / disable_verity() / enable_verity()
647
+ │ ├── screenshot(path?) / screen_record(path, …)
648
+ │ ├── forward(local, remote) / reverse(remote, local) -> ForwardHandle
649
+ │ ├── list_forwards() / remove_all_forwards()
650
+ │ ├── list_displays() · mirror(options?|**opts) -> ScrcpySession
651
+ │ └── adb(*args) · adb_path · serial
652
+ ├── ADBConfig / ScrcpyOptions
653
+ ├── Device / list_devices() / first_online()
654
+ ├── launch_scrcpy() / ScrcpySession
655
+ ├── find_adb() / find_scrcpy() / adb_available() / scrcpy_available() / diagnose()
656
+ ├── fetch_tools() / download_platform_tools() / download_scrcpy() / tools_dir()
657
+ ├── CommandResult / TransferResult / StreamResult / OperationResult / strip_ansi
658
+ └── ADBError + ADBNotFoundError / ADBConnectionError / ADBTimeoutError /
659
+ ADBNotConnectedError / ADBCommandError / ADBTransferError /
660
+ ADBInstallError / ScrcpyError
661
+ ```
662
+
663
+ ---
664
+
665
+ ## Building the GUI exe & releasing
666
+
667
+ ```bash
668
+ python scripts/make_icon.py # (re)generate the icon
669
+ python scripts/build_exe.py # -> dist/ADBCentral-<version>-win64.exe
670
+ # release.py bundles that exe into the wheel (building it when dist/ has none):
671
+ python scripts/release.py patch # bump -> test -> exe -> build -> twine check -> upload
672
+ ```
673
+
674
+ `adbcentral-gui` runs from the installed package when PySide6 is available
675
+ (`adbcentral[gui]`) and otherwise starts the executable bundled in the wheel
676
+ (`adbcentral/bin/adbcentral-gui.exe`). The same executable is attached to the GitHub
677
+ Release, whose page shows that version's section of `CHANGELOG.md`
678
+ (`python scripts/release_notes.py` prints it). Pushing a `v*` tag builds the exe,
679
+ the wheel and the source archive (about 37 MB each, because both carry the exe)
680
+ and attaches them to that release. `scripts/release.py` builds the same files
681
+ locally; it supports `--rebuild-exe` to rebuild the executable first, and
682
+ `--no-exe` for a lean package.
683
+
684
+ ---
685
+
686
+ ## Troubleshooting (incl. Remote Desktop / RDP)
687
+
688
+ **Running ADB Central on a machine you reach over RDP**
689
+
690
+ - **adb works over RDP** — it's just a local process on the RDP host. But a device
691
+ plugged into *your* laptop is **not** visible on the remote host unless USB is
692
+ redirected. Easiest path — in the GUI use **New ▾ → Connect to a device…**
693
+ → **Network** (or `adbcentral connect HOST:5555`):
694
+ - **Network adb** (recommended for IVI/head units): on the device do
695
+ `adb tcpip 5555` once over USB, then connect by IP from the RDP host — no USB
696
+ redirection needed. Android 11+: **New ▾ → Pair device (Android 11+)…**.
697
+ - If a device is plugged into the remote host but shows offline/missing, use
698
+ **New ▾ → Restart ADB server** (or `adbcentral restart-server`) — that clears
699
+ the common adb-version-mismatch that hides devices.
700
+ - Or enable **USB redirection** in your RDP client (mstsc → Local Resources →
701
+ More → your device).
702
+ - **scrcpy over RDP** runs as scrcpy does by itself, at the display's full size. If
703
+ it cannot use the session's graphics (scrcpy says it could not create its
704
+ renderer), tick **Options → Software rendering**, or open it in a separate window.
705
+
706
+ **"scrcpy won't work" on a head unit** → pick the right display from the display
707
+ picker in Device Control (see the automotive table above); the log window shows
708
+ scrcpy's own error and the exact command, the same scrcpy you can start by hand.
709
+
710
+ **adb not found / outdated** → `adbcentral doctor` shows what's resolved;
711
+ `adbcentral upgrade-tools` updates to the latest only if newer; set
712
+ `ADBCENTRAL_AUTO_FETCH=0` to stop automatic downloads.
713
+
714
+ ## License
715
+
716
+ Copyright © 2026 Naveen Daniel Kennedy. ADB Central is free software under the
717
+ [GNU General Public License version 3](https://github.com/NVNKENNEDY/adbcentral/blob/main/LICENSE), with no warranty. The Windows app
718
+ contains PySide6, Shiboken6 and Qt 6 (GNU LGPL v3); see the
719
+ [third-party notices](https://github.com/NVNKENNEDY/adbcentral/blob/main/adbcentral/licenses/THIRD-PARTY-NOTICES.md).