androidinputandroid-sourcewakeup

What is the modern proper way to modify an android keylayout to wake the system from sleep with a key?


There are plenty of search results explaining that you can modify your android phone to wake up due to a volume key press by modify the keylayout file. You are to simply add WAKE or WAKE_DROPPED to the key in question.

An example to allow the volume up key to wake android:

# /vendor/usr/keylayouts/MyKeyboard.kl
key 115 VOLUME_UP WAKE

This doesn't seem to be applicable any longer. The WAKE flag seems to be ignored. In addition, if I use the validatekeymaps tool with WAKE_DROPPED, you can see it is not even recognized as a valid option any longer.

> validatekeymaps MyKeyboard.kl
Expected key flag label, got 'WAKE_DROPPED'.

If on the other hand, I change the key to be sent to be the POWER key, the system will wake up.

# /vendor/usr/keylayouts/MyKeyboard.kl
key 115 POWER

The system wakes up with or without the WAKE flag is it seems the POWER key has some other attribute set to tell the system to wake up. This of course breaks the volume up functionality and is undesirable.

So my question is, what is the new proper way to set the WAKE attribute on a key? What about WAKE_DROPPED?


Solution

  • You can not set the WAKE attribute on a key now. The wake flags was removed. The wake key is defined by KeyEvent.isWakeKey