I\'m unsure if the question about injecting events via adb is supposed to be in StackOverflow or Android Enthusiasts, please move it if it doesn\'t belong here.
Anyw
The 1
"in-between /dev/input/event3/ and 116" stands for EV_KEY event type constant:
- EV_KEY: Used to describe state changes of keyboards, buttons, or other key-like devices.
You could have found that on your own if you had run getevent -l /dev/input/event3/
and pressed the power key.
Also to find out the power key input device name I would recommend parsing output of getevent -pl
instead of contents of /proc/bus/input/devices
. The device you are looking for has KEY_POWER
listed in the events section:
add device X: /dev/input/eventX
name: "xxxxxxxxxx"
events:
KEY (0001): KEY_POWER
And the proper long power key press sequence (as in press and hold for 1 second and then release) would be:
sendevent /dev/input/eventX 1 116 1
sendevent /dev/input/eventX 0 0 0
sleep 1
sendevent /dev/input/eventX 1 116 0
sendevent /dev/input/eventX 0 0 0
Note: getevent -pl
is not available for Gingerbread and below.