To switch between TCP and USB modes with just one command, you can add this to /init.rc
:
on property:service.adb.tcp.port=*
restart adbd
on property:service.adb.tcp.enable=1
setprop service.adb.tcp.port 5555
on property:service.adb.tcp.enable=0
setprop service.adb.tcp.port -1
And now you can use property service.adb.tcp.enable
to enable or disable listening on port 5555. Run netstat
to check whether it's listening. As you can see it will also trigger if you do wish to change service.adb.tcp.port
manually.