-
Notifications
You must be signed in to change notification settings - Fork 8
ADB USB and Wireless
This page defines the common model and transport-specific boundaries for TCP, USB, and mDNS connections. A connection-pool identity represents one ADB transport, not a globally unique physical device.
- ADB provides authentication, transports, shell, files, forwarding, and device queries.
- Management features can work once ADB is available.
- Remote control additionally needs the scrcpy server, ordered sockets, metadata, decoders, rendering, and control.
- Therefore management availability does not prove that the remote path is complete, and a remote media failure does not automatically prove that the ADB transport failed.
ConnectionTransport currently has TCP, USB, and MDNS. ConnectionCandidate.deviceIdentifier() produces:
usb:<serial>tcp:<normalized-host>:<port>mdns:<canonical-device-serial>
An mDNS session retains service information for resolution, but runtime identity is normalized to the device serial through DeviceTransportSerial.mdnsDeviceSerial(). A resolved ip:port is only the current endpoint and does not replace mDNS identity. Business code must not automatically merge USB, TCP, and mDNS into one physical-device identity.
A TCP candidate consists of host and port. The connector builds a dadb runtime connection and verifies its serial. Whether it is TLS comes from the actual Dadb connection, not a fixed port or a speculative transport enum. An mDNS connect service ultimately resolves to a network endpoint while the connection pool retains the mDNS transport identity.
The USB path is: scan ADB interfaces → request permission → refresh the authorized UsbDevice → create a dadb USB transport → verify → register the usb:<serial> connection. Permission has an explicit timeout, and scan results include unauthorized candidates so the UI can present them.
Physical detach is a hard transport signal. AdbConnectionManager observes ACTION_USB_DEVICE_DETACHED and, after matching the active USB connection:
- Marks the transport disconnected.
- Removes and closes it in the registry.
- Publishes
UsbDeviceDisconnectedandConnectionLostwith the device id.
Heartbeat is a fallback and must not override or delay detach cleanup. USB recovery must reacquire a valid system device object and permission state instead of applying network-endpoint assumptions.
Wireless Debugging has separate pairing and connect phases. The mDNS monitor observes both TLS pairing and connect services and supplies presence and selection state for saved mDNS sessions. Monitoring starts for tracked sessions or interactive consumers and may pause during a connected game session to reduce unrelated work.
mDNS is not automatic pairing. A pairing service may trigger a pairing prompt; a connect service can create a TLS ADB connection only when trust material is valid. See Device Pairing and Wireless Debugging.
| Symptom | Check first |
|---|---|
| USB absent or unauthorized | ADB-interface scan, permission receiver, post-permission device refresh |
| Still online after unplug | Detach matching, registry removal, disconnect events |
| Pairing failure | Pairing endpoint, code lifetime, Android version, dadb runtime |
| Pairing succeeds but connect fails | Connect service/port, TLS trust material, ADB verification |
| Management works but remote control fails | Server, socket order, metadata, and decoder |
| Both remote control and management fail | ADB registry, transport health, and reconstruction |
-
DeviceTransportSerialTestandConnectionCandidatePolicyTest: identity normalization and candidate policy. -
SessionDataEndpointTestandSessionDialogStateConnectionCandidatesTest: persistence and UI endpoint conversion. -
MdnsSessionPresenceTestandMdnsServiceSelectionTest: discovery, presence, and selection. - USB permission and physical detach still require device acceptance testing.
- Overview / 总览
- Quick Start / 快速开始
- Connection & Pairing / 连接设备与配对
- Session Management / 会话管理
- Remote Control / 远程控制
- Settings / 设置
- Management Features / 管理功能
- FAQ / 常见问题
- Overview / 总览
- Technical Index / 技术文档索引
- Audit Checklist / 初始化与更新清单
- Conventions / 文档维护约定
- Architecture / 架构
- Module Map / 模块地图与边界
- Runtime Path / 运行时主链路
- Session State / 会话状态与事件
- Session Lifecycle / 会话配置与连接生命周期
- ADB, USB & Wireless / ADB、USB 与无线
- ADB Lifecycle / ADB 连接生命周期
- Pairing / 设备配对与无线调试
- Codecs / 编码与解码
- Remote Interaction / 远程交互性能与悬浮菜单
- Clipboard / 剪贴板同步
- Management / 管理功能
- Events & Shell / 事件、监控与 Shell
- Logging / 日志系统与维护
- Troubleshooting / 分层排障方法
- UI Design / UI 设计系统
- Bilingual Copy / 双语与文案
- Remote UI Analysis / 远程 UI 布局分析
- Engineering Rules / 工程与验证规则
- External Research / 外部研究与取舍
Technical topics appear here only after their page-level audit is complete. / 技术主题仅在完成逐页审核后加入侧边栏。