Repository navigation
Conversation
USB bulk endpoints and the Android accessory file descriptor only offer blocking I/O. Each half runs on its own thread, bridged to the async side through an in-memory pipe, so the mux works over them unchanged.
The host polls libusb for devices with an MTP or adb interface, switches one to Android accessory mode and runs the session over its bulk endpoints, so USB works without developer mode. A device whose app never answers is reset and left alone until it is unplugged for a while. Silent accessories stay open between polls so no bytes are lost. On Windows this needs UsbDk; without it the host says so and keeps using adb.
The app opens the accessory the host switched it into, hands the descriptor to the native session and prefers it over the adb loopback and Wi-Fi while it stays attached.
udev rule giving the seat user access to MTP, adb and accessory devices, libusb in the Linux packages and CI, an optional UsbDk download in the Windows installer, and docs.
A tablet still in a session with an earlier host process answers with stats instead of a handshake: reset it so it renegotiates. A device that just showed up is left to settle before switching, and a failed switch is retried a few times before the device is given up on.
The gadget driver lets one opener at a time have /dev/usb_accessory, and a blocked read kept it open after the session ended, even across a replug and while Android froze the app, so the next accessory handshake failed. Share one descriptor between the link threads, point it at /dev/null when the session stops or ends, and interrupt a read in progress.
A USB accessory link never reports a host process that died: the tablet kept showing the last frame. The host answers every ping, so after 5 s without anything from it the client ends the session and reconnects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #3 (Wi-Fi transport). This PR is stacked on
wifi-transport; review the diff against that branch.Summary
automode tries AOA first and falls back to adb.Changes
ezd-linkandezd-host-service, blocking reader and writer halves for link I/O, and a USB transport option in the service config.MainActivityandNativeBridge, with the Rust side inezd-android.uaccessrule for the accessory and switch devices.Scope notes
ezd-fake-clientand protocol crates are unchanged apart from what the transport needs.Verification
cargo fmt --checkcargo clippy --workspace --all-targets -- -D warnings, also with--no-default-featuresforezd-host-service,ezd-trayandezd-host, and for the Android crate on arm64.cargo test --workspace: 682 passed, 2 ignored.assembleFullDebug,assemblePlayDebug,lintFullDebug,testFullDebugUnitTest.--aoa off --adb) still streams.Not yet verified:
docs/windows-testing.md).