Wake up Android with use adb or Eclipse (just before debug)? Wake up Android with use adb or Eclipse (just before debug)? android android

Wake up Android with use adb or Eclipse (just before debug)?


adb shell input keyevent KEYCODE_WAKEUP

As described here, this wakes up the device. Behaves somewhat like KEYCODE_POWER but it has no effect if the device is already awake.

To toggle sleep/wake with one command you can issue

adb shell input keyevent KEYCODE_POWER


Just use :

adb shell input keyevent 26


Here's what I came up with:

adb shell dumpsys power | grep "mScreenOn=true" | xargs -0 test -z && adb shell input keyevent 26

This will first check to see if the screen is on. If it isn't, it will emulate the power key, which will turn on the device's screen.