Skip to content

Dadb Integration Boundary

星冉 edited this page Jul 21, 2026 · 2 revisions

dadb Integration Boundary

中文

Last updated: 2026-07-22

Current integration

Screen Remote uses the local dadb 2.0.0 included build through includeBuild("../external/dadb") in Screen-Remote/settings.gradle.kts. Dependency substitution maps:

  • dev.mobile:dadb to external/dadb/dadb
  • dev.mobile:dadb-android to external/dadb/dadb-android

external/dadb is a separate Git worktree and upstream capability boundary, not a general directory for app-specific ADB utilities.

Subproject responsibilities

Subproject Ownership
dadb General JVM ADB protocol, messages, streams, shell/sync, install/uninstall, forward/reverse, and transport abstractions.
dadb-android Android runtime wrapper, USB Host transport, STLS/TLS, Wireless Debugging pairing, mDNS discovery, certificates/storage, and Android-specific error mapping.
dadb-helper Device-side helper; its JAR is built and synchronized into app assets by the main build.

Main-app consumption boundary

  • ScreenRemoteApp chooses the app-private runtime root and initializes AdbRuntimeProvider at startup.
  • AdbRuntimeProvider owns one initialized AdbRuntime and does not expose new global connection policy to UI.
  • infrastructure/adb connects dadb transport, pairing, USB, and mDNS primitives to the app's session and connection lifecycle.
  • feature calls scenario-level app APIs and does not reimplement ADB protocol or transports inside Compose pages.

Current capability boundary

  • Ordinary TCP ADB transport.
  • Android USB Host transport and ADB connection after USB permission.
  • STLS/TLS transport upgrade and Wireless Debugging pairing-code flow.
  • _adb-tls-pairing._tcp and _adb-tls-connect._tcp mDNS discovery with continuous StateFlow state.
  • ADB identity, TLS storage, and runtime files under an app-private root.
  • DadbSession routing: a logical network session owns a compatibility-first primary connection plus one shared/retryable delayed-ACK streaming connection; exclusive USB maps both routes to one transport.
  • Explicit operation results such as SyncResult, InstallResult, and UninstallResult; the app must not treat failure as success.

These capabilities have current implementation evidence in both the library and app. One-off upstream commit-comparison records from the old page are intentionally not retained.

Connection identity

The app uses ConnectionCandidate to distinguish transports and generate ADB transport serials:

Transport Identity form
USB usb:<serial>
TCP tcp:<host>:<port>, with normalized IPv6 host/port representation.
mDNS mdns:<service-name>

A transport serial identifies a connection entry, not a merged physical device. USB, TCP, and mDNS remain different candidate routes even when they reach the same device. mDNS retains the service name and does not replace persistent identity with the resolved ip:port.

Error and lifecycle boundary

  • dadb maps transport failures to explicit ADB/TLS/USB error types or operation results.
  • The app owns session policy, connection candidates, reconnection, runtime state, and UI feedback.
  • dadb provides transports and protocol primitives; it does not replace the Screen Remote session state machine.
  • Changes at the dadb/app boundary must review cancellation, socket/stream cleanup, delayed_ack, TLS upgrade, and error classification together.

Updating and verification

A dadb upgrade is more than a version-number change. At minimum:

  1. Review API and protocol changes across dadb, dadb-android, and the helper.
  2. Verify every main-app consumer of SyncResult, install, and uninstall results.
  3. Run dadb JVM/Android tests, including DadbSessionTest, plus focused app tests for ADB, USB, mDNS, connections, and scrcpy socket order.
  4. Run the app's testDebugUnitTest and assembleDebug.
  5. Validate connection, cancellation, and reconnection on real devices for affected transports.

The app and external/dadb continue to manage status, commits, and pushes independently.

Clone this wiki locally