1

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 ?

Mitz
  • 21
  • 1
  • 4

1 Answers1

1

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.

  • 1
    It's nice to know that people still use my answer from 2012 https://stackoverflow.com/a/13095523/1778421 – Alex P. Jan 04 '21 at 17:31
  • Sorry, I didn't find your answer and also you can see that this question differs because it is about when this command should be called, so I cannot simply provide the link. – GreenEkatherine Jan 04 '21 at 17:46