I own an android device in a remote location that I use to run various tests and operations. I need to be able to send ADB commands while also connect the phone to a wired internet connection. For various reasons, I cannot connect the device to WiFi, nor can I root the device. Due to USB Enumeration structure, if I connect a USB hub to the phone with an Ethernet port and a USB connection to a PC, the options are either Phone in Host + Internet but no ADB, or phone in Peripheral mode with ADB but no ethernet connection.
What I have tried:
adb tcpip 5555to enable ADB over a network connection (TCP mode). This means connecting the phone through USB, setting
adb tcpip 5555to enable ADB over network, and then disconnecting the USB and replacing the connection with the Ethernet dongle in host mode. This works fine until the phone is rebooted and then manual intervention is needed.
- Various USB dongle/hub set ups.
- LADB workaround where the phone connects to itself through wireless ADB, then sets the adbd to TCP mode, etc. For this, I need a WiFi network so it does not meet the requirements. It's also very flaky.
What I want to do: I'm wondering if I can purchase a Raspberry Pi or some other microcontroller, and implement a solution using Session Request Protocol (SRP) and/or Host negotiation Protocol (HNP) described in On-The-Go (OTG) as follows:
- Connect Android device using USB-C (as OTG cable) to companion device.
- Connect companion device to internet through ethernet port
- Setup states
- Software in Android/external code detects when adbd is in USB mode, and renegotiates the connection to Android being in device mode. Companion uses USB connection to send
adb tcpip 5555.
- Once adbd is set to TCP mode, software (using
getprop) checks that phone accepts ADB over network, and renegotiates the usb connection such that the Android is now Host, and accepts the companion device as an Ethernet dongle, and internet flows to the device.
This way, the network connection to the device (including sending ADB commands) remains stable even after device reset. There are also power considerations, but they are secondary.