#!/usr/bin/env bash # ADB reconnection helpers. Source this file. # Provides: adb_reconnect_init_hints, adb_reconnect_all, adb_http_status, adb_prepare_device_for_deploy, adb_update_connect_cache DEV_ADB_HTTP_PORT="${DEV_ADB_HTTP_PORT:-5039}" ADB_TCP_PROBE="${ADB_TCP_PROBE:-no}" adb_reconnect_init_hints() { : # Placeholder: load hints from local config if present } adb_http_status() { local ip="$1" local port="${2:-$DEV_ADB_HTTP_PORT}" local url="http://${ip}:${port}/adb.json" local result result="$(curl -sf --max-time 3 "$url" 2>/dev/null || echo "{}")" echo "adb_http_status $ip: $result" } adb_reconnect_all() { local label="${1:-reconnect}" # Try any IPs registered via HTTP discovery if [[ "$ADB_TCP_PROBE" == "yes" ]]; then for ip in $(adb devices | awk 'NR>1 {print $1}' | grep -E '^[0-9]+\.' | cut -d: -f1 | sort -u); do adb connect "$ip:5555" >/dev/null 2>&1 || true done fi # mDNS / default discovery (adb already handles this) true } adb_prepare_device_for_deploy() { local serial="$1" # Disable screen lock prompts, maximize brightness — non-critical adb -s "$serial" shell settings put global package_verifier_enable 0 >/dev/null 2>&1 || true } adb_update_connect_cache() { : # Placeholder: persist known device IPs }