Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
644 views
in Technique[技术] by (71.8m points)

android - ADB Receive broadcast BOOT_COMPLETE

I want to wait until the android mobile phone has started and the MediaScanner is done.

Afterwards I want to perform an action using adb.

adb wait-for-device will finish much before the boot sequence of the cell phone is done.

How to capture e.g. BOOT_COMPLETE Broadcast via ADB? Something like: wait-for-boot-complete. I don know whether this is possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can keep polling for sys.boot_completed or dev.bootcomplete system properties.

As for the code, I do not know what environment and/or scripting language you are using. It's pretty straightforward. First you need to find which property is being set to "1" up on boot completion by your phone's software. Let's say it is dev.bootcomplete. Then the following command would return control back to your script after the phone is booted up

adb wait-for-device shell 'while [[ -z $(getprop dev.bootcomplete) ]] ; do sleep 1; done'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...