Repository navigation
fix: recognize wireless-debugging devices adb connects to over mDNS - #43
Merged
Jeomon merged 1 commit intoNov 6, 2026
Merged
Conversation
A phone paired for wireless debugging is connected by adb itself over mDNS, and adb names it after its service rather than host:port: "adb-RF8M12345-AbC9Zz._adb-tls-connect._tcp". Two things went wrong: - pick_device told Wi-Fi from USB by a colon in the serial, so with --connection wifi such a phone was not found, and --connection usb took it as a USB device, even ahead of a phone plugged in by cable. It now also counts a serial naming "adb-tls-connect" as a network device, the rule scrcpy adopted for the same problem (Genymobile/scrcpy#6248). - adb appends " (2)" when an mDNS name repeats, so the serial can contain a space. list_devices split the line on whitespace, which cut the serial short and read "(2)..." as the state, so a ready phone was listed as "unknown" under a serial adb does not know. It now finds the one-word state instead of assuming it is the second field, and keeps the old split for states that are not one word, such as "no permissions (...)". Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014TonJ1geSd97oAtSBZofUK
Member
|
Thanks |
Jeomon
pushed a commit
that referenced
this pull request
Nov 22, 2026
A phone paired for wireless debugging is connected by adb itself over mDNS and listed under its service name, e.g. "adb-RF8M12345-AbC9Zz._adb-tls-connect._tcp". #43 taught pick_device that such a serial is a network device, but the explicit Wi-Fi path did not know it: with --connection wifi --device <that serial>, ANDROID_MCP_CONNECTION=wifi + ANDROID_MCP_DEVICE, or --wifi <serial>, normalize_wifi_address appended ":5555" and connect_wifi ran `adb connect adb-…_tcp:5555`, which fails to resolve the name as a host. Even past that, the ":5555" serial no longer matched the device adb lists, so the attached, ready phone could never be selected. normalize_wifi_address now leaves an mDNS serial as it is, and connect_wifi selects it without `adb connect`, since adb already holds the connection. Host and host:port addresses are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014TonJ1geSd97oAtSBZofUK
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.
Problem
When a phone is paired for wireless debugging, adb connects to it automatically over mDNS. adb then names the device after its mDNS service instead of
host:port:(This line is from Genymobile/scrcpy#6248. scrcpy hit the same two problems.)
1. USB vs Wi-Fi selection.
pick_devicedecides by whether the serial contains a colon. As a result:--connection wifireports "No ready device over wifi".--connection usbpicks the wireless phone, even when a phone plugged in by cable is also attached but listed after it.2. Serials with a space. When an mDNS name repeats, adb appends
(2), e.g.adb-AEORQMSAOWNQ-N7Ger8 (2)._adb-tls-connect._tcp(also from that scrcpy issue).list_devicessplits the line on whitespace. That cuts the serial toadb-AEORQMSAOWNQ-N7Ger8and reads(2)._adb-tls-connect._tcpas the state. A ready phone is therefore listed asunknown, under a serial adb doesn't recognize.Change
mobile/service.py: add_is_network(). A device counts as a network device when its serial contains:oradb-tls-connect. This is the rule scrcpy adopted insc_adb_device_get_type().pick_deviceuses it for bothwifiandusb.autois unchanged.adb/core.py:list_devicesnow finds the one-word state with a regex built fromDeviceState, instead of assuming the state is the second field. The serial is everything before the state. Lines that don't match keep the old split, e.g.no permissions (...), whose state isn't one word, so that case still reads asUNKNOWN.Testing
uv run pytest: 583 passed, 21 skipped.ruff checkandruff format --checkare clean.TestListDevices: an mDNS serial, a serial with a space next to a USB phone, andno permissions (...)stayingUNKNOWN.TestPickDevice:wifitakes an mDNS device, andusbskips it.masterand pass with this change. The other two cover behavior that already worked and must stay that way.adb-… (2)._adb-tls-connect._tcp device …unknowndevice--connection wifi--connection usb--connection usbI don't have a wireless-debugging setup here. The
adb devices -llines come from real reports in the scrcpy issue above.