最近ADB连接设备经常出问题,于是单独拧出来写一个脚本,其实很简单了
#!/bin/bash
if [[ $# -ne 1 ]] || [[ $1 -lt 19800 ]]; then
echo "输入参数错误"
exit
fi
adb_port=$1
sleep_time=1
adb_state=`adb devices|grep $adb_port`
echo "adb_state: $adb_state"
while [[ ! "$adb_state" = "*.*.*.*:$adb_port device" ]]; do
echo "sleep time is $sleep_time s"
sleep 1s
((sleep_time++))
if [ $sleep_time -gt 30 ]; then
echo "adb connect failed"
exit
fi
adb connect *.*.*.*:$adb_port
adb_state=`adb devices|grep $adb_port`
echo "adb_state: $adb_state"
done
echo "0"