Answers:
好了,等待设备,因为您已经意识到,只能等待直到adb守护程序正确启动。这已经是初始化时间了。为了检查启动是否完整,您可以向脚本添加广告,例如:
伪:
这应该工作。
像这样:
#!/bin/bash
adb wait-for-device
A=$(adb shell getprop sys.boot_completed | tr -d '\r')
while [ "$A" != "1" ]; do
sleep 2
A=$(adb shell getprop sys.boot_completed | tr -d '\r')
done
adb shell input keyevent 82
这未经测试,所以要注意潜在的错误
getprop
在回车后返回了一个回车符,因此将adb
命令更改为$(adb shell getprop sys.boot_completed | tr -d '\r')
成功。这只是修剪回车符。
这是我想出的:
adb wait-for-device shell <<ENDSCRIPT
echo -n "Waiting for device to boot "
echo "" > /data/local/tmp/zero
getprop dev.bootcomplete > /data/local/tmp/bootcomplete
while cmp /data/local/tmp/zero /data/local/tmp/bootcomplete; do
{
echo -n "."
sleep 1
getprop dev.bootcomplete > /data/local/tmp/bootcomplete
}; done
echo "Booted."
exit
ENDSCRIPT
echo "Waiting 30 secs for us to be really booted"
sleep 30
echo "Unlocking screen"
adb shell "input keyevent 82"