INNER CODE UNIT · Python

resolve_endpoint

cvet/fonline · BuildTools/android_device.py:247

def resolve_endpoint(adb_path: str, workspace_root: Path, explicit_endpoint: str | None) -> str:
	if explicit_endpoint:
		endpoint = normalize_endpoint(explicit_endpoint)
		if not is_connected_device(adb_path, endpoint) and not try_connect(adb_path, endpoint):
			raise SystemExit(f'Unable to connect to Android device {endpoint}')
		write_saved_endpoint(workspace_root, endpoint)
		return endpoint

	saved_endpoint = read_saved_endpoint(workspace_root)
	if saved_endpoint:
		saved_endpoint = normalize_endpoint(saved_endpoint)
		if is_connected_device(adb_path, saved_endpoint) or try_connect(adb_path, saved_endpoint):
			write_saved_endpoint(workspace_root, saved_endpoint)
			return saved_endpoint

	connected_network_devices = [
		serial for serial, state in list_connected_devices(adb_path)
		if ':' in serial and state in CONNECTED_DEVICE_STATES

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…