automates ADB management in Windows, ensuring ADB listens to all TCP (no USB!) devices, handles configurations, and restarts if killed
pip install adbkonnekt
Tested against Windows / Python 3.11 / Anaconda / BlueStacks / LdPlayer / MeMu
ADB
https://developer.android.com/tools/releases/platform-tools
from konfigleser import write_config_file
import sys
import subprocess
r"""
[DEFAULT]
outputfolder = C:\stdoutstderradblog
adb_path = C:\ProgramData\chocolatey\lib\adb\tools\platform-tools\adb.exe
shell = False
window_style = Maximized
timeout_check_if_proc_running = 30
kill_running_adb = True
is_alive_sleeptime = 0.05
check_if_alive = True
restart_when_killed = True
auto_connect_devices = True
max_port_number = 5555
adb_port = 5037
adb_executables_to_kill = ('hd-adb.exe', 'adb.exe')
sleep_after_connection_attempt = 0.1
sleep_after_starting_the_process = 1
daemon = False
priority = high
listen_on_all_ports = True
min_port = 5550
no_auto_connect = (8080, 8000, 8888, 1433, 1521, 3306, 5000, 5432, 6379, 27017, 27018, 8443, 3389)
ignore_exceptions = True
new_connection_interval = 30
update_shared_devices_info = 30
"""
adbexe = r"C:\ProgramData\chocolatey\lib\adb\tools\platform-tools\adb.exe"
cfgdata = {
"DEFAULT": {
"outputfolder": "C:\\stdoutstderradblog",
"adb_path": adbexe,
"shell": False,
"window_style": "Maximized",
"timeout_check_if_proc_running": 30,
"kill_running_adb": True,
"is_alive_sleeptime": 0.05,
"check_if_alive": True,
"restart_when_killed": True,
"auto_connect_devices": True,
"max_port_number": 5555,
"adb_port": 5037,
"adb_executables_to_kill": ("hd-adb.exe", "adb.exe"),
"sleep_after_connection_attempt": 0.1,
"sleep_after_starting_the_process": 1,
"daemon": False,
"priority": "high",
"listen_on_all_ports": True,
"min_port": 5550,
"no_auto_connect": (
8080,
8000,
8888,
1433,
1521,
3306,
5000,
5432,
6379,
27017,
27018,
8443,
3389,
),
"ignore_exceptions": True,
"new_connection_interval": 30,
"update_shared_devices_info": 30,
}
}
savepath = "c:\\adb_connection_config.ini"
write_config_file(d=cfgdata, filepath=savepath)
p = subprocess.Popen(
[
sys.executable,
r"C:\ProgramData\anaconda3\envs\a0\Lib\site-packages\adbkonnekt\__init__.py",
savepath,
],
)
print(p)