Skip to content
when connected devices changed, do sth :)
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ConnectionTracer
.gitattributes
.gitignore
LICENSE
README.md
demo.py
setup.py

README.md

ConnectionTracer

PyPI version

when connected devices changed, do sth :)

How it works?

Use a socket to connect adb server. Nothing about subprocess or os.system.

View socket2adb for detail.

Installation

pip install ConnectionTracer 

How to use?

import ConnectionTracer
import time


# also, you can custom port and host
ConnectionTracer.config.PORT = 5037


# bind hook function
def hook_function(devices: set):
    print(devices)


ConnectionTracer.start(hook_function)
# also you can directly run:
# ConnectionTracer.start(hook_function, port=8080)

print('tracer already started :)')

# get connection status
print('now status: ', ConnectionTracer.get_status())

# do something else you want
time.sleep(30)

# stop it
ConnectionTracer.stop()
print('tracer stopped')

When connected devices changed, hook_function would be called.

More?

Code is quite simple, you can view 100-lines-ver for detail.

You can’t perform that action at this time.