简体   繁体   中英

When to use the adb shell getprop sys.boot_completed

I am calling a sequence of adb commands as below

"adb root"
adbd is already running as root
"adb wait-for-device"
"adb shell getprop sys.boot_completed"
1
boot_completed successful
"adb remount"
remount succeeded
"adb uninstall ..."
Success
"adb shell rm -rf ..."
"adb push ..."
9366 KB/s (46299481 bytes in 4.827s)
"adb push ..."
14 files pushed. 0 files skipped.
9701 KB/s (26658580 bytes in 2.683s)
"adb push ..."
14 files pushed. 0 files skipped.
9544 KB/s (33592272 bytes in 3.437s)
"adb reboot"
"adb wait-for-device"
"adb root"
error: protocol fault (no status)
error: protocol fault (no status)
Sleeping 2 sec. before retrying
increasing timeout by 180.0 seconds
"adb root"
error: device not found
error: device not found
Sleeping 2 sec. before retrying
increasing timeout by 270.0 seconds
"adb root"
error: device not found
error: device not found
Sleeping 2 sec. before retrying
increasing timeout by 405.0 seconds
"adb root"
error: device not found
error: device not found

But as you can see the android device starts throwing error of 'device not found' at last. I have come to know that "adb reboot" might be the culprit here as reboot might not have finished booting completely before next commands starts executing. To check this I have used "adb wait-for-device". But it seems that it is not able to detect device state correctly.
I also have found the use of "adb shell getprop sys.boot_completed" to rectify this error. Detect when Android emulator is fully booted

I am not sure though when to use "adb shell getprop sys.boot_completed". Is it to be used on every reboot of the device or can I use it after every "adb wait-for-device" command?

You should call getprop sys.boot_completed after boot or reboot and together with adb wait-for-device like this:

adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82' 

When you call just single adb wait-for-device it doesn't guarantee that boot is completed since it only check that daemon has started properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM