droidrun-core
High-level Android device automation framework for Rust. Provides the
DeviceDriver trait, DroidRun Portal integration, and a UI state processing
pipeline.
Built on top of droidrun-adb. Part of the droidrun-rs workspace.
Features
DeviceDrivertrait — async interface for all device operations (tap, swipe, text, screenshot, UI tree)AndroidDriver— primary implementation using ADB + DroidRun PortalRecordingDriver— proxy wrapper that logs all actions as JSON- Portal integration — dual-mode communication (TCP + ContentProvider fallback)
- UI state pipeline — accessibility tree filtering → formatting → structured
UIState - Portal management — automatic APK install, accessibility service setup, keyboard IME
Quick Start
[]
= "0.1"
= { = "1", = ["full"] }
Basic Driver Usage
use ;
async
UI State Pipeline
use ;
use ;
async
Recording Driver
use ;
async
Architecture
┌──────────────────┐
│ Your App │
└────────┬─────────┘
│
┌────────▼─────────┐
│ DeviceDriver │ async trait (tap, swipe, text, screenshot, UI tree)
│ ├ AndroidDriver │ ADB + Portal
│ └ RecordingDriver Proxy with action logging
└────────┬─────────┘
│
┌────────▼─────────┐
│ Portal Client │ Dual-mode: TCP (fast) → ContentProvider (fallback)
│ Portal Manager │ APK install, a11y service, keyboard IME
└────────┬─────────┘
│
┌────────▼─────────┐
│ UI Pipeline │ TreeFilter → TreeFormatter → UIState
│ ├ ConciseFilter │ Remove off-screen & tiny elements
│ └ IndexedFormatter Assign indices, format text
└──────────────────┘
Portal Communication
DroidRun Portal is an Android APK that provides accessibility tree access, keyboard input, and screenshots.
| Mode | How | Speed |
|---|---|---|
| TCP | HTTP to Portal server (port 8080, ADB-forwarded) | Fast |
| ContentProvider | adb shell content query/insert |
Slower (fallback) |
Auto-fallback: if TCP fails, ContentProvider is used automatically.
UI State Output Format
index. ClassName: resourceId; checkedState, text - bounds(x1,y1,x2,y2)
Key Types
| Type | Description |
|---|---|
DeviceDriver |
Async trait for device operations |
AndroidDriver |
Primary driver (ADB + Portal) |
RecordingDriver<D> |
Proxy that logs mutating actions |
PortalClient |
Portal TCP + ContentProvider client |
PortalManager |
APK lifecycle & setup |
AndroidStateProvider |
UI state fetch + process pipeline |
UIState |
Processed UI state (elements, formatted text, phone state) |
Element |
Single UI element with bounds, text, class |
TreeFilter / TreeFormatter |
Traits for custom UI processing |
ConciseFilter / IndexedFormatter |
Default implementations |
Examples
Requirements
- Rust 1.85.0+
- ADB server running
- Android device/emulator with DroidRun Portal installed
- Portal accessibility service enabled
License
MIT