Skip to content

feat(android): add ADB over TCP/IP support for remote debugging#258

Open
mogilevich wants to merge 2 commits intoshamanec:developfrom
mogilevich:feature/android-adb-remote
Open

feat(android): add ADB over TCP/IP support for remote debugging#258
mogilevich wants to merge 2 commits intoshamanec:developfrom
mogilevich:feature/android-adb-remote

Conversation

@mogilevich
Copy link
Copy Markdown
Contributor

Summary

Allow users to connect to Android devices directly via ADB over Wi-Fi while GADS manages the USB connection.

Flow: take device → enable ADB TCP/IP → get adb connect IP:5555 command → work remotely → release device → provider auto-restores USB mode.

Changes

  • POST /device/:udid/adb-tcpip/enable — enables TCP/IP mode on port 5555, returns device IP and connect command
  • POST /device/:udid/adb-tcpip/disable — restores USB-only mode
  • Re-establishes ADB port forwards (stream, IME, remote server) after daemon restart caused by adb tcpip / adb usb
  • AdbTcpIpTransitioning flag on device prevents false device resets while ADB daemon is intentionally restarting
  • WebRTC H264 stream reconnects transparently without closing the browser peer connection (reconnectStream in writeFrames)
  • Hub proxy: enable is gated — only works when device is actively in use by the requesting user
  • Hub proxy: disable is gated — only the session owner can disable (or anyone when device is free)
  • Hub: auto-disables ADB TCP/IP when the device control WebSocket session ends

@gifflet
Copy link
Copy Markdown
Collaborator

gifflet commented Mar 5, 2026

@mogilevich, why do you need a temporary ADB over LAN connection only when using a device? What’s the use case?

@mogilevich
Copy link
Copy Markdown
Contributor Author

@gifflet The use case is remote developers who need to connect a device to their local ADB and debug applications via Android Studio without physical access to the device. ADB over TCP/IP allows them to attach the remote device as if it were plugged in locally, enabling full debugging capabilities (breakpoints, logcat, profiler, etc.) through their IDE.

@shamanec
Copy link
Copy Markdown
Owner

shamanec commented Mar 6, 2026

Sounds reasonable, I haven't checked the code yet though. @mogilevich what are your expectations on the UI side for this? Also I assume (without having checked the code) that this would work only on a local network? @gifflet we could check this out and merge it for a new version after v5.0 release, what do you think?

DisableAdbTcpIp was unconditionally running `adb usb` which restarts
the ADB daemon and kills the H.264 stream. Hub calls this endpoint on
every WebSocket disconnect, causing a loop: stream dies → WS closes →
disable called → daemon restarts → stream dies again.

Now checks `adb get-serialno` first — if the serial doesn't contain
":" (ip:port format), the device is already on USB and we skip.
@mogilevich
Copy link
Copy Markdown
Contributor Author

@shamanec

UI: Current implementation is API-only — POST /device/:udid/adb-tcpip/enable and POST /device/:udid/adb-tcpip/disable. A toggle button on the device control page would be a natural addition.

Network: Correct, works within the same network or over VPN. ADB TCP/IP listens on port 5555 on the device IP.

@gifflet
Copy link
Copy Markdown
Collaborator

gifflet commented Mar 10, 2026

I have tested and validated that remote debugging is working fine. At the beginning of the tests, I encountered an error when trying to connect to the device (connection reset error), but it is not happening anymore.

@shamanec, since we have some open PRs that might be worth merging before releasing v5, such as #261, #263, and shamanec/GADS-hub-ui#25, what do you think about merging these, releasing v5, and then continuing work on this PR and the UI side?

@shamanec
Copy link
Copy Markdown
Owner

Yep, that makes sense 👌 We might even think about proper remote adb communication sharing over websocket through the hub for example, this would require another client CLI option for GADS but it could work outside local networks as well, we have to check it out :)

@shamanec
Copy link
Copy Markdown
Owner

shamanec commented Apr 1, 2026

@mogilevich I did some experimenting for this with a separate GADS client cli that authenticates and goes through the hub and it seems to be working fine, I will do a bit more testing and let you know when its ready for testing :D

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.

3 participants