Interpretation of the result of “cat /proc/bus/input/devices” and adb shell commands

前端 未结 1 746
难免孤独
难免孤独 2021-01-17 03:07

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

1条回答
  •  悲哀的现实
    2021-01-17 03:33

    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.

    0 讨论(0)
提交回复
热议问题