Skip to main content

Slim async local device drivers for Android Portal and iOS Portal, extracted from mobilerun.

Project description

mobilerun-core-local is the slim async local-driver core of mobilerun.
No CLI, no agent, no LLM providers โ€” just local Android/iOS drivers for higher-level tools such as mobilerun-core.


  • ๐Ÿ“ฑ Drive local devices โ€” Android over ADB+Portal, Android Portal HTTP-only, or iOS Portal HTTP.
  • โšก TCP-with-content-provider fallback โ€” fast Android HTTP path over adb forward, transparent fallback to content-provider RPC.
  • ๐Ÿ”Œ HTTP-only drivers โ€” connect to already-running Android/iOS portals without taking over setup.
  • ๐Ÿ›  Portal lifecycle โ€” download, install, accessibility enablement, auto-upgrade.
  • ๐Ÿชถ Slim โ€” a small async driver package with 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. The Android ADB driver requires ADB on PATH and a device with USB debugging enabled. HTTP-only drivers require an already-running portal URL.

uv pip install mobilerun-core-local

๐Ÿš€ Quick usage

import asyncio
from async_adbutils import adb
from mobilerun_core_local import AndroidDriver
from mobilerun_core_local.driver.android import 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())

HTTP-only Android:

import asyncio
from mobilerun_core_local import AndroidPortalHttpDriver


async def main():
    driver = AndroidPortalHttpDriver(
        url="http://127.0.0.1:18080",
        token="...",
    )
    await driver.connect()
    await driver.tap(540, 1200)


asyncio.run(main())

iOS Portal:

import asyncio
from mobilerun_core_local import IOSPortalDriver


async def main():
    driver = IOSPortalDriver("http://127.0.0.1:6643")
    await driver.connect()
    await driver.start_app("com.apple.Preferences")


asyncio.run(main())

๐Ÿงฑ Layout

Platform-specific code is namespaced under driver/<platform>/ and transport/<platform>/. Adding a new backend (e.g. iOS over USB, a new Android transport) does not pollute the package root.

mobilerun_core_local/
โ”œโ”€โ”€ __init__.py                       Re-exports the public driver surface
โ”œโ”€โ”€ driver/
โ”‚   โ”œโ”€โ”€ base.py                       DeviceDriver ABC, DeviceDisconnectedError
โ”‚   โ”œโ”€โ”€ android/
โ”‚   โ”‚   โ”œโ”€โ”€ adb.py                    AndroidDriver โ€” ADB-backed driver
โ”‚   โ”‚   โ”œโ”€โ”€ http.py                   AndroidPortalHttpDriver โ€” HTTP-only driver
โ”‚   โ”‚   โ””โ”€โ”€ portal.py                 Portal APK lifecycle + content-provider helpers
โ”‚   โ””โ”€โ”€ ios/
โ”‚       โ””โ”€โ”€ http.py                   IOSPortalDriver โ€” ios-portal HTTP driver
โ””โ”€โ”€ transport/
    โ””โ”€โ”€ android/
        โ””โ”€โ”€ portal_client.py          PortalClient โ€” TCP-with-content-provider fallback

๐Ÿ“š Public API

Re-exported from mobilerun_core_local:

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.
AndroidPortalHttpDriver HTTP-only Android Portal driver. Requires url and bearer token; does not use ADB at runtime.
IOSPortalDriver / IOSDriver iOS Portal HTTP driver. Requires an already-running ios-portal URL.
DeviceDriver Abstract base for drivers. supported: set[str] declares which verbs a subclass implements.
DeviceDisconnectedError Raised when the device drops mid-call.
validate_android_portal_url(url) / validate_ios_portal_url(url) Normalize + sanity-check portal URLs.
discover_ios_portal(...) Scan localhost for a reachable ios-portal HTTP endpoint.

Android Portal helpers live under mobilerun_core_local.driver.android (not at the package root, since they're Android-specific):

Symbol What it is
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.

PortalClient (the TCP-with-content-provider transport) lives at mobilerun_core_local.transport.android.PortalClient โ€” used internally by AndroidDriver, exposed for low-level access.

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_local" logger. Configure it yourself; the package attaches no handlers.

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

๐Ÿ”— Relationship to upstream mobilerun

This package owns local execution drivers. The full framework imports these drivers for CLI/agent flows; mobilerun-core wraps them behind a sync, backend-neutral API.

Use mobilerun-core-local when you need async local drivers directly. 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_local-0.3.0.tar.gz (45.9 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_local-0.3.0-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file mobilerun_core_local-0.3.0.tar.gz.

File metadata

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

File hashes

Hashes for mobilerun_core_local-0.3.0.tar.gz
Algorithm Hash digest
SHA256 de023797f2cecbb2f43cb6d1b37c6e77f3a1c47651d6ab7b466e2bda56446803
MD5 46c9898d1c3b0bd75ba6c89d671c886a
BLAKE2b-256 34056761d7dca1d021334f03f84e2308f9b767b1f4b7402029243a614bece25b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mobilerun_core_local-0.3.0.tar.gz:

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

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_local-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mobilerun_core_local-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3aa27048511ead4c65a5a966250f01cdcb92dd583382e566ec2e5c9da088490
MD5 f13f945448dde4f3e2b129491f9a2f94
BLAKE2b-256 7a7d67221d8454a9d3aa200c6c8dd25ba082b977578c51b3cfe039d5c9176d95

See more details on using hashes here.

Provenance

The following attestation bundles were made for mobilerun_core_local-0.3.0-py3-none-any.whl:

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

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