suggestion to extend pure-python-adb to add track-devices capability
I have found it useful to implement:
- the host:track-devices to provide a continues socket feed of device connections
-extend Device so that host:devices can pass back the device status, rather than just the serialno (two separate suggestions, the device status (2nd tuple of the "adb devices" parse) to let me know if a connection is: device, offline, no (permissions), ... Then I can know if I could make a connection to the device.
The implementation of host:track-devices is essentially a change in the command string from the existing shell implementation, moved into init.py in adb/command/host. It opens the socket with "host:track-devices" command and provides a socket to listen to messages when a the transport list changes (device connection is made). It would be nice to have a message one when the device goes offline, but that does not seem to be the adbd service implementation on either my Mint or Pi implementations. There is nothing that pure-python-adb can do about that.
The format of the message(s) appears to be: ####serialno\tstatus\n
where:
- the #### is the count (hex) of the following device status line (or 0000 if the line will be empty)
- if #### is non-zero, it has is essentially the line as provided by "adb devices"
- if the device goes offline you will have to catch it through the device's existing connections, since it does not appear to push out, but will still be present in the buffer later when some device does come online
So with this added facility you can find out when devices come online, and will find out devices that have gone offline (when something new comes online).