Use Volume button to wake up Nexus 5

nexus5Seem like power button on my Nexus 5 will be broken soon. When I pressed it, the screen turn off and on. I have to press it twice to make it work.

There are many custom ROMs/kernels out there that allow you to:

  • Double tap the screen to wake it up but it cost 2% of battery/hour
  • Use Volume Rocker to wake the screen

I don’t want to install custom ROMs because some of them are not open sources.

The cleanest way to remap button would be:

  1. clone AOSP
  2. modify /system/usr/keylayout/xxx.kl to remap the button
  3. build my own ROM, and flash it

Remap Volume button with temporary recovery ROM

I found a way to avoid permanently root my phone, or flash a custom ROM.  But you still need to unlock your bootloader which will WIPE ALL DATA ON YOUR PHONE!

I temporary boot into a custom recovery ROM via fastboot, modify the keymap file, and eureka!

  1. Get adb and fastboot from Android SDK
  2. Download openrecovery-twrp-2.8.5.2-hammerhead.img (a custom recovery for Nexus 5)
  3. Unlock the bootloader with following command:
    WARNING: THIS WILL WIPE ALL DATA ON YOUR PHONE!!!

    adb reboot bootloader         # reboot to bootloader
    fastboot oem unlock           # unlock the bootloader
  4. Temporary boot into a custom recovery ROM (without flashing it)
    adb reboot bootloader
    fastboot boot openrecovery-twrp-2.8.5.2-hammerhead.img
  5. Press Mount and select System to mount /systemrecovery
  6. On your PC, run:
    adb shell
    vi /system/usr/keylayout/gpio-keys.kl
  7. Modify the content of file from:
    key 115   VOLUME_UP
    key 114   VOLUME_DOWN

    to

    key 115   POWER
    key 114   VOLUME_DOWN
  8. Save [ESC] then :wq[ENTER], then unmount the /system by select System again on your phone
  9. Press back (bottom right of the screen) and Reboot -> System
  10. Choose NOT to install Super SU (DON’T swipe!)

When the phone reboots, you may use Volume Up button to wake the screen now. Unfortunately, the button will not turn up the volume anymore.

Note

I tried modifying the keymap to allow the volume button to acts as both VOLUME UP and button to wake the screen:

key 115   VOLUME_UP    WAKE      # THIS WONT WORK
key 114   VOLUME_DOWN

This does not work because the behaviour of Wake Key was controlled by  PhoneWindowManager.interceptKeyBeforeQueueing which you can read more from the doc and PhoneWindowManager source code. Seem like we can turn up the volume while listening to music without waking up the phone (That might be the feature that prevent this to work).

9 ความเห็นบน “Use Volume button to wake up Nexus 5

  1. What about this? https://play.google.com/store/apps/details?id=com.teliapp.powervolume&hl=en

    My friend is an end-user who encountered the same problem, and it ended up that I suggest this app to him.

    I was curious that, aside from the ability to use the volume button to ‘lock’ (which the app can’t, or maybe it’s designed to let user use the volume button while the screen is on), is there any remarkable difference, like the battery usage?

    By the way, button remapping is a very good solution. Cheers! 😀

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out /  เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out /  เปลี่ยนแปลง )

Connecting to %s