#!/usr/bin/env bash
# USB 插线后一键开启无线 ADB（5555）并重连
set -euo pipefail
TARGET="${1:-192.168.110.80:5555}"
HOST="${TARGET%%:*}"
echo "等待 USB 设备授权..."
adb wait-for-device
serial="$(adb devices | awk '/\tdevice$/{print $1; exit}')"
echo "USB 设备: $serial"
adb -s "$serial" tcpip 5555
sleep 2
adb connect "$TARGET"
adb -s "$TARGET" get-state
echo "完成。可拔线；auto_recover 会自动 oneclick。"
