Activate/Unlock Phone via Adb Shell

Using the adb shell I can input text on the phone. But that does not work, if the phone's display is off. I have to press the home button first and unlock the screen for this to work. How can I automate this with the adb shell without adding additional code on the device?

adb shell input keyevent KEYCODE_HOME

Unfortunately, that does not work at all.

3

2 Answers

Use adb shell input keyevent 26 to wake up the device. (Source) Now do the text input or whatsoever you want to do. And, unlocking can also be done using input command but different locks requires different technique, so you'll have to Google a bit, or provide the info here so that I/others can answer it.

The same command can put the device to sleep as well.

0

You could check the display power state with dumpsys power and then if needed emulate the power key press to wake it up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest