Skip to content

feat(android): add an AgentDeviceCloud backend - #1498

Closed
hannojg wants to merge 2 commits into
hannojg/backend-baseline-ownershipfrom
hannojg/adc-backend
Closed

hannojg wants to merge 2 commits into
hannojg/backend-baseline-ownershipfrom
hannojg/adc-backend

Conversation

@hannojg

@hannojg hannojg commented Nov 10, 2026 •

Copy link
Copy Markdown

This replaces the ADC portion of #1471 on top of the backend ownership and capability work in #1500. The Android backend lives in src/drivers/android/adc/ and registers its light definition and heavy module through the two registries.

The worker provisions an ADC session, connects it through an authenticated WebSocket to its private ADB server, and exposes a normal Simlock lease. It needs platform-tools and an ADC account API key. It uses ADC's /v2/leases API, which keeps devices allocated until explicit release. Simlock remains the only lease clock; this adds no provider-deadline or renewal hooks.

Provisioning journals a local allocation before requesting a remote device. Each activation has a durable idempotency key, so a lost creation response can be replayed. Shutdown releases the remote session, and a later boot creates a fresh device. Recovery reconnects to the same active session and saved ADB relay port. ADC has its own ADB server record and default port 5039, preserving local-backend servers when the selected backend changes.

Connecting to ADC

From a checkout of this PR, with Node.js, pnpm and adb installed:

pnpm install
pnpm build

export ADC_API_KEY='<your-account-api-key>'
export SIMLOCK_HOME="$HOME/.simlock-adc-v2"
mkdir -p "$SIMLOCK_HOME"

Stop an existing Simlock worker under the same OS user first. Create $SIMLOCK_HOME/config.json:

{
  "drivers": {
    "android": {
      "backend": "adc",
      "apiUrl": "https://api.agentdevicecloud.xyz",
      "apiKeyEnv": "ADC_API_KEY"
    }
  },
  "capacity": {
    "strategy": "fixed",
    "config": {
      "maxRunning": 1,
      "android": { "maxRunning": 1, "maxDevices": 1 }
    }
  },
  "warmPool": { "enabled": false },
  "memoryPressure": { "enabled": false }
}

Start the worker and request an Android 14 device:

node dist/cli/main.js daemon start
node dist/cli/main.js lease --platform android --os 34 --ttl 15m --detach

Copy lease.id and device.address from the returned grant:

LEASE_ID='<lease.id from the grant>'
SERIAL='<device.address from the grant>'

node dist/cli/main.js adb -s "$SERIAL" install app-debug.apk
node dist/cli/main.js adb -s "$SERIAL" shell am start -n com.example.myapp/.MainActivity
node dist/cli/main.js adb -s "$SERIAL" exec-out screencap -p > screen.png

node dist/cli/main.js release "$LEASE_ID"

Use your APK path and component. The detached Simlock lease expires after 15 minutes unless renewed; release or Simlock expiry releases ADC. If the worker stops, ADC keeps its sessions running and accruing usage until explicitly released. The ADC key stays on the worker; gateway agents use their normal Simlock credentials. A worker uses one Android backend, so USB phones are unavailable while ADC is selected.

The ADC tests cover lifecycle, replay after a lost response, ownership, origin validation, and preservation of another backend's ADB server. The restacked branch passes 341 targeted tests and the website/OpenAPI check. I also ran the compiled Simlock API client against a local running ADC service over real HTTP: after advancing its clock by 120 days, the same session remained active; replay and release were idempotent. This test used no real Android device. A live-device check through this Simlock backend against the v2 service remains pending; the earlier prototype also hit an unhandled TLS ECONNRESET during a disconnect, which still needs investigation before unattended use.

Written by an agent.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@hannojg
hannojg force-pushed the hannojg/adc-backend branch from 39d7f39 to 134960a Compare November 10, 2026 19:14
@hannojg
hannojg changed the base branch from hannojg/backend-registry to hannojg/backend-baseline-ownership November 10, 2026 19:14
@hannojg
hannojg added this pull request to stack #1501 November 10, 2026 19:24
@V3RON

V3RON commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #2041. That feature reuses this stack's design: a light backend definition in the driver registry, a heavy backend module in the daemon, and a backend on device and baseline records. It changes one thing: a worker may run several backends per platform (emulator, redroid and phones together), so a backend is chosen per lease rather than per worker. The ADC backend can come back later as another backend on that abstraction. Thank you for the groundwork, @hannojg.

Written by an agent.

@V3RON V3RON closed this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants