Skip to content

Classify devices by transport so Go Wireless and Handoff apply to USB phones only - #52

Open
ba6ul wants to merge 1 commit into
mainfrom
fix/28-transport-classification
Open

ba6ul wants to merge 1 commit into
mainfrom
fix/28-transport-classification

Conversation

@ba6ul

@ba6ul ba6ul commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Refs #28

What

One classification of how adb reaches a device (USB, ip:port, wireless debugging, emulator), used by the daemon and the UI, so Go Wireless and Handoff are offered only for a phone on USB.

Why

isNetwork was "serial contains :". A wireless-debugging serial (adb-<serial>-<suffix>._adb-tls-connect._tcp) and an emulator serial (emulator-5554) have no colon, so both were treated as USB: logged "connected via USB", listed with Go Wireless and Handoff in the UI, and accepted by the daemon. Reproduced against a real emulator before the change: Go Wireless for emulator-5554 was accepted, restarted the emulator's adbd, then tried adb connect to the host's LAN gateway (192.168.1.1:5555) and to 10.0.2.16:5555.

How

Verified by

Physical phone (Pixel 10a) and a real emulator, both tested live. All with an isolated daemon config and autoLaunch off.

  • Emulator, booted headless from a temporary AVD (Android 35 google_apis_playstore x86_64) on a separate adb server on port 5038, never the owner's server on 5037. The AVD, emulator and server were removed afterwards; nothing else was changed.
    • Serial emulator-5554; ro.kernel.qemu=1; ro.serialno EMULATOR36X4X9X0 (differs from the serial).
    • The branch's daemon reports transport: emulator and logs "connected via emulator". Go Wireless, Handoff and USB-only for it are refused with a reason. The emulator was untouched: same adb transport id before and after, no TCP port opened.
    • Before this change on the same emulator: accepted as USB, adbd restarted, connects to the LAN gateway.
    • Also observed: after adb tcpip and adb connect 127.0.0.1:5555 adb lists the same emulator twice (emulator-5554 and 127.0.0.1:5555, same ro.serialno). That is Same physical phone gets multiple concurrent scrcpy instances across USB/wireless serials (confirmed, with zombie process accumulation) #4, not changed here.
  • Physical phone on wireless debugging, read-only (the daemon only lists it and reads its model, as it always did): reports transport: mdns, logs "connected via wireless debugging", Go Wireless and Handoff refused with a reason, phone untouched (same transport id, no TCP port). No tcpip, usb or disconnect was run against it.
  • Not tested live: the phone's plain USB serial (the cable was not connected; the form is evidenced by the daemon's own cache written when it was on USB, and ro.serialno equals the serial embedded in the mDNS name), ip:port for this phone (tcpip is off), and how adb answers tcpip / usb: / disconnect on an mDNS transport.
  • Tests: core 39 (+12: real serials, lookalikes, hardware serial, device getters); daemon 102 (+5 process-level tests against the fake adb with one device of each kind: transports reported, how each is logged, refusals with nothing sent to adb (tcpipRequests stays 0), a USB phone still accepted, USB-only refused for emulator and mDNS); ui 57 (+25: the fallback on the same serial list as core, JSON with/without/unknown transport, which buttons each row shows). ipc 26. dart analyze and flutter analyze clean.
  • With the daemon's gate disabled the refusal test fails; with the UI's gate disabled two widget tests fail.
  • CI results are in the checks below.

Risk / follow-ups

…or USB

An emulator and a wireless-debugging phone have no colon in their serial, so
the 'contains :' rule called both USB: logged as USB, shown with Go Wireless
and Handoff, and accepted by the daemon (an emulator's adbd was restarted and
the host's LAN gateway probed). AdbTransport now tells usb, network, mdns and
emulator apart; the daemon sends it with every device, refuses Go Wireless,
Handoff and USB-only where they do not apply, and the UI follows the same
rules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant