fix(adb): redial the port that actually worked, not always 5555 - #7
Open
X-Ryl669 wants to merge 1 commit into
Open
fix(adb): redial the port that actually worked, not always 5555#7X-Ryl669 wants to merge 1 commit into
X-Ryl669 wants to merge 1 commit into
Conversation
`redial` hardcoded 5555, which is where `adb tcpip` always lands — but
Android 11+ *Wireless debugging* picks a RANDOM port and keeps it while
the toggle stays on. That matters beyond tidiness: Wireless debugging is
the only way to run adb with **USB debugging off**, and plenty of
banking/DRM apps refuse to start while `Settings.Global.adb_enabled` is
1. So the configuration a user needs in order to keep those apps working
is exactly the one where redial could never reconnect: after a Wi-Fi
roam, a suspend or an `adb kill-server`, `scan_transports` finds nothing,
the redial knocks on a port nobody is listening on, and Universal Control
arms with no cursor ever reaching the phone — silent on both screens.
`scan_transports` now notes the port of whatever network transport is
attached (`rsplit(':')`, so the bracketed IPv6 form works too) and
persists it to ~/.cache/vortex/last_adb_port, mirroring how lan.rs caches
the peer IP — the phone keeps that port across our own restarts, so
memory alone would forget it exactly when it is needed.
Redial then tries the remembered port first and 5555 second, so:
- a Wireless-debugging port is reconnected without a cable;
- a stale entry (phone re-paired, or moved back to `adb tcpip`) still
recovers on the same pass rather than needing a manual reconnect;
- and a success on either port becomes the next first guess, so the
cache self-corrects.
The 5555 fallback is skipped when it IS the remembered port — each miss
costs about a second of `adb connect` blocking.
Verified end-to-end by planting a bogus port and dropping the transport:
tried :39999, fell back to :5555, reconnected, and rewrote the cache.
`redial_port_order` is split out as the pure half so the ordering is
covered by a unit test without a global or the filesystem in the way.
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.
When using Universal control feature, the current status is to enable adb USB debugging (then WIFI debugging). However, leaving USB debugging enabled usually stops DRM and banking app from running.
Here's the attempt from Claude to fix it:
redialhardcoded 5555, which is whereadb tcpipalways lands — but Android 11+ Wireless debugging picks a RANDOM port and keeps it while the toggle stays on. That matters beyond tidiness: Wireless debugging is the only way to run adb with USB debugging off, and plenty of banking/DRM apps refuse to start whileSettings.Global.adb_enabledisadb kill-server,scan_transportsfinds nothing, the redial knocks on a port nobody is listening on, and Universal Control arms with no cursor ever reaching the phone — silent on both screens.scan_transportsnow notes the port of whatever network transport is attached (rsplit(':'), so the bracketed IPv6 form works too) and persists it to ~/.cache/vortex/last_adb_port, mirroring how lan.rs caches the peer IP — the phone keeps that port across our own restarts, so memory alone would forget it exactly when it is needed.Redial then tries the remembered port first and 5555 second, so:
adb tcpip) still recovers on the same pass rather than needing a manual reconnect;adb connectblocking.Verified end-to-end by planting a bogus port and dropping the transport: tried :39999, fell back to :5555, reconnected, and rewrote the cache.
redial_port_orderis split out as the pure half so the ordering is covered by a unit test without a global or the filesystem in the way.