I am trying to wake a device up using the following adb command
adb input keyevent 26
This correctly emulates the power button keypress if the screen is on, but will not turn the screen on if it was off and locked.
Can anyone suggest why?
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.
Sign up to join this communityI am trying to wake a device up using the following adb command
adb input keyevent 26
This correctly emulates the power button keypress if the screen is on, but will not turn the screen on if it was off and locked.
Can anyone suggest why?
This is an old post, but this command should wake up any device.
adb shell input keyevent KEYCODE_WAKEUP
My phone does this, too. I wish I knew why.
I seem to have had some success with the sendevent
command (adb shell sendevent
). (Not much documentation on sendevent
, unfortunately.)
First, I had to locate the Power Key device via getevent -i
. In my case, I found /dev/input/event4
had a name like pmic8xxx_pwrkey
, and used this for my sendevent
call.
# sendevent --help
use: sendevent device type code value
To use sendevent
, I also had to find the type and code. In the getevent
device, it listed events, and I used event "KEY" (which corresponded to a value of 1
) for the type
parameter, and then used the first value which followed that event type as the code
parameter, 0074
(this is a hex value, 0074
represents the decimal value 116) in my case. For the value
parameter, I used 1
and 0
for on/down and off/up.
Constructing the command, I sent this to emulate a power button press:
sendevent /dev/input/event4 1 116 1
sleep 1 # you may want to include this line, especially if you use this code in a script
sendevent /dev/input/event4 1 116 0
I had to wait about five seconds before my screen turned on, but eventually it did wake.
After further use, this seems to work only when my device is not charging.
I found that on my Moto MB865 (Atrix 2) sending menu key event turns the screen back on:
adb shell input keyevent 82
did you try keyevent for power button ?
adb shell input keyevent KEYCODE_POWER