I'm trying to use adb through direct connection, i.e. through port 5037 with telnet, basic commands like "host:devices" return same answer than the equivalent adb command:
C:\adb>adb devices
List of devices attached
4d009c06c8459000 device
C:\adb>telnet localhost 5037
Connecting to localhost...
Sent: 000Chost:devices
Received: OKAY00184d009c06c8459000 device
But when a I try a "device" command like "shell" I get an error:
C:\adb>adb shell ls
acct
cache
charger
config
...
...
C:\adb>telnet localhost 5037
Connecting to localhost...
Sent: 0008shell:ls
Received: FAIL0012device offline (x)
what's wrong?
Your understanding of how adb
protocol works is wrong. Either read the specs or just see what exchange is really happening when you run any adb shell
commands:
C:\>set ADB_TRACE=1
C:\>adb shell date
system/core/adb/adb.c::main():Handling commandline()
system/core/adb/commandline.c::adb_commandline():interactive shell loop. buff=shell:date
system/core/adb/adb_client.c::_adb_connect():_adb_connect: host:version
system/core/adb/sysdeps_win32.c::socket_loopback_client():socket_loopback_client: port 5037 type tcp => fd 100
system/core/adb/transport.c::writex():writex: fd=100 len=4: 30303063 000c
system/core/adb/transport.c::writex():writex: fd=100 len=12: 686f73743a76657273696f6e host:version
system/core/adb/transport.c::readx():readx: fd=100 wanted=4
system/core/adb/transport.c::readx():readx: fd=100 wanted=4 got=4
4f4b4159 OKAY
system/core/adb/adb_client.c::_adb_connect():_adb_connect: return fd 100
system/core/adb/adb_client.c::adb_connect():adb_connect: service shell:date
system/core/adb/transport.c::readx():readx: fd=100 wanted=4
system/core/adb/transport.c::readx():readx: fd=100 wanted=4 got=4
30303034 0004
system/core/adb/transport.c::readx():readx: fd=100 wanted=4
system/core/adb/transport.c::readx():readx: fd=100 wanted=4 got=4
30303230 0020
system/core/adb/sysdeps_win32.c::adb_close():adb_close: 100(lo-client:5037)
system/core/adb/adb_client.c::_adb_connect():_adb_connect: shell:date
system/core/adb/sysdeps_win32.c::socket_loopback_client():socket_loopback_client: port 5037 type tcp => fd 101
system/core/adb/transport.c::writex():writex: fd=101 len=4: 30303132 0012
system/core/adb/transport.c::writex():writex: fd=101 len=18: 686f73743a7472616e73706f72742d61 host:transport-a
system/core/adb/adb_client.c::switch_socket_transport():Switch transport in progress
system/core/adb/transport.c::readx():readx: fd=101 wanted=4
system/core/adb/transport.c::readx():readx: fd=101 wanted=4 got=4
4f4b4159 OKAY
system/core/adb/adb_client.c::switch_socket_transport():Switch transport success
system/core/adb/transport.c::writex():writex: fd=101 len=4: 30303061 000a
system/core/adb/transport.c::writex():writex: fd=101 len=10: 7368656c6c3a64617465 shell:date
system/core/adb/transport.c::readx():readx: fd=101 wanted=4
system/core/adb/transport.c::readx():readx: fd=101 wanted=4 got=4
4f4b4159 OKAY
system/core/adb/adb_client.c::_adb_connect():_adb_connect: return fd 101
system/core/adb/adb_client.c::adb_connect():adb_connect: return fd 101
system/core/adb/commandline.c::adb_commandline():about to read_and_dump(fd=101)
system/core/adb/commandline.c::read_and_dump():read_and_dump(): pre adb_read(fd=101)
system/core/adb/commandline.c::read_and_dump():read_and_dump(): post adb_read(fd=101): len=30
Thu Mar 26 06:51:49 GMT 1970
system/core/adb/commandline.c::read_and_dump():read_and_dump(): pre adb_read(fd=101)
system/core/adb/commandline.c::read_and_dump():read_and_dump(): post adb_read(fd=101): len=0
system/core/adb/commandline.c::adb_commandline():read_and_dump() done.
system/core/adb/sysdeps_win32.c::adb_close():adb_close: 101(lo-client:5037)
system/core/adb/commandline.c::adb_commandline():interactive shell loop. return r=0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With