INNER CODE UNIT · Python
list_connected_devices
cvet/fonline · BuildTools/android_device.py:146
def list_connected_devices(adb_path: str) -> list[tuple[str, str]]:
output = run_capture([adb_path, 'devices'], check=False)
devices: list[tuple[str, str]] = []
for line in output.splitlines():
line = line.strip()
if not line or line.startswith('List of devices attached'):
continue
parts = line.split()
if len(parts) < 2:
continue
devices.append((parts[0], parts[1]))
return devices
def is_connected_device(adb_path: str, endpoint: str) -> bool:
for serial, state in list_connected_devices(adb_path):
if serial == endpoint and state in CONNECTED_DEVICE_STATES:
return True