Skip to main content

Slim async Portal client + Android device driver, extracted from mobilerun.

Project description

mobilerun-core-cli is the slim async Portal + Android device driver core of mobilerun.
No CLI, no agent, no LLM providers — just enough to drive a real Android device through the Mobilerun Portal app over ADB. Intended as an embedding library for higher-level tools.


  • 📱 Drive a real Android device — tap, swipe, type, screenshot, get_ui_tree, start_app, install_app, …
  • ⚡ TCP-with-content-provider fallback — fast HTTP path over adb forward, transparent fallback to content-provider RPC.
  • 🛠 Portal lifecycle — download, install, accessibility enablement, auto-upgrade.
  • 🪶 Slim — four files, four runtime deps (async_adbutils, httpx, requests, rich).
  • 🔌 Embeddable — designed to be wrapped by sync facades (e.g. mobilerun-core) or used directly.
  • 🤝 In sync with upstream — verbatim slice of droidrun/mobilerun; behaviour and API track upstream.

📦 Installation

Note: Python >=3.11,<3.14. Requires ADB on PATH and a device with USB debugging enabled.

uv pip install mobilerun-core-cli

🚀 Quick usage

import asyncio
from async_adbutils import adb
from mobilerun_core_cli import AndroidDriver, ensure_portal_ready


async def main():
    # 1. Make sure Portal is installed + accessibility is on.
    device = await adb.device()
    await ensure_portal_ready(device)

    # 2. Drive the device.
    driver = AndroidDriver(serial=device.serial, use_tcp=True)
    await driver.connect()

    await driver.tap(540, 1200)
    await driver.swipe(540, 1600, 540, 400, duration_ms=300)
    await driver.input_text("hello", clear=True)
    png_bytes = await driver.screenshot()
    tree = await driver.get_ui_tree()


asyncio.run(main())

🧱 Layout

mobilerun_core_cli/
├── __init__.py            Re-exports the public surface
├── portal.py              Portal APK lifecycle + content-provider helpers
├── driver/
│   ├── base.py            DeviceDriver ABC, DeviceDisconnectedError
│   └── android.py         AndroidDriver — ADB-backed concrete driver
└── transport/
    └── portal_client.py   PortalClient — TCP-with-content-provider fallback

📚 Public API

Re-exported from mobilerun_core_cli:

Symbol What it is
AndroidDriver ADB+Portal device driver. Async methods: tap, swipe, input_text, press_button, start_app, install_app, screenshot, get_ui_tree, get_apps, list_packages, get_date.
DeviceDriver Abstract base for drivers. supported: set[str] declares which verbs a subclass implements.
DeviceDisconnectedError Raised when the device drops mid-call.
PortalClient HTTP-or-content-provider client for the on-device Portal. Used internally by AndroidDriver; can be constructed directly for low-level access.
setup_portal(device) Download + install + enable the Portal APK on a device.
ensure_portal_ready(device) Idempotent: install/upgrade Portal and enable accessibility if needed.
setup_keyboard(device) Switch the device to the Mobilerun IME.
ping_portal(device) Verify Portal is installed and reachable.
PORTAL_PACKAGE_NAME, A11Y_SERVICE_NAME Portal identifiers.
portal_content_uri(pkg, path) Build content://<pkg>/<path> URIs.
portal_a11y_service(pkg), portal_ime_id(pkg) Accessibility service / IME component names.

AndroidDriver accepts:

  • serial: str | None — ADB serial; None picks the only connected device.
  • use_tcp: bool = False — when True, the underlying PortalClient port-forwards Portal's HTTP server (localhost:N → device:8080) and uses it instead of the content provider. Faster but requires a working forward; falls back transparently.

🪵 Logging

All output goes through the "mobilerun_core_cli" logger. Configure it yourself; the package attaches no handlers.

import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger("mobilerun_core_cli").setLevel(logging.DEBUG)

🔗 Relationship to upstream mobilerun

This package is a verbatim slice of the upstream framework's Android driver + Portal modules, with imports rewritten under mobilerun_core_cli and loggers renamed. It tracks the upstream API for those four files; new features (iOS driver, recording driver, cloud driver, agent/CLI) stay upstream.

Use mobilerun-core-cli when you only need to drive a real Android device and want to keep the dependency footprint small. Use mobilerun when you want the full LLM-agent experience, CLI/TUI, and multi-platform support out of the box.

📄 License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mobilerun_core_cli-0.1.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mobilerun_core_cli-0.1.0-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file mobilerun_core_cli-0.1.0.tar.gz.

File metadata

  • Download URL: mobilerun_core_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mobilerun_core_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fb137e2b084d51c8d19ae8d64d6f4ed7efe41072f10cc3b724d1025fc0b337a2
MD5 fe48e35f68e17419c95c2188b0a6956e
BLAKE2b-256 f3c1fcd8dae643a3e3aebe97b47a5e3f90615d84ec5a7ba349c89dcd3cdc8e53

See more details on using hashes here.

Provenance

The following attestation bundles were made for mobilerun_core_cli-0.1.0.tar.gz:

Publisher: publish.yml on droidrun/mobilerun-core-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mobilerun_core_cli-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mobilerun_core_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44b9735e486976db48bad9143875cbdcc2744cdba758d7539224cf15f295eaed
MD5 1a0809fade4216173c42b288343969bd
BLAKE2b-256 8bb081683eec1a9d27a06cb3d0674844f7b898ee2220444305b80b741f4a7ec8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mobilerun_core_cli-0.1.0-py3-none-any.whl:

Publisher: publish.yml on droidrun/mobilerun-core-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page