[MOD] Volume Wake

Search This thread

tombriden

Inactive Recognized Developer
I got so used to using the volume rocker to wake my DHD and show the lockscreen instead of the power button that i decided to try and add the same functionality to the OneX. The only caveat with this is that sometimes the volume slider shows up when it wakes, but i can live with that :)

Hopefully, in time, the ROM devs will add this in by default or as an option. Until then it'll require these manual mods...


Don't try the following if you're unsure what you're doing as you could potentially break the ROM if not done correctly. I recommend backing up first in Clockwork Recovery in case things go wrong.
I accept no responsibility for any issues encountered making these changes!




Requirements
Rooted phone
Android-SDK
baksmali/smali from here

Step 1 - Update android.policy.jar

1. Do the following to get the android.policy.jar from your phone and disassemble it
Code:
adb pull /system/framework/android.policy.jar .
baksmali -x android.policy.jar -o classout
2. Open the following file in a text editor
Code:
classout/com/android/internal/policy/impl/KeyguardViewMediator.smali
3. Find the method "isWakeKeyWhenKeyguardShowing(IZ)Z"
4. At the bottom of the method, there's a switch statement. Remove the following 2 lines from it:
Code:
        0x18 -> :sswitch_5
        0x19 -> :sswitch_5
5. Save the file and close it.
6. Run the following commmand to re-assemble classes.dex
Code:
smali classout -o classes.dex
7. Drag the classes.dex into the android.policy.jar file to update the file in there.
8. Push the updated android.policy.jar back to the phone
Code:
adb push android.policy.jar /sdcard/
adb shell
su
sysrw
cp /sdcard/android.policy.jar /system/framework/
chmod 644 /system/framework/android.policy.jar


Step 2 - Update Generic.kl

1. Pull the file from your phone
Code:
adb pull /system/usr/keylayout/Generic.kl
2. Open it in a text editor and change the lines
Code:
key 114   VOLUME_DOWN
key 115   VOLUME_UP
to
Code:
key 114   VOLUME_DOWN	WAKE_DROPPED
key 115   VOLUME_UP	WAKE_DROPPED
3. Push the file back to your phone
Code:
adb push Generic.kl /sdcard/
adb shell
su
sysrw
cp /sdcard/Generic.kl /system/usr/keylayout/
chmod 644 /system/usr/keylayout/Generic.kl

(of course, you could also make those changes to the file directly using a root file explorer app and text editor.)


Step 3
Reboot the phone.

Note: The first time it boots after changing android.policy.jar, there'll be an 'Android is upgrading' dialog. This is normal and it won't happen on subsequent reboots.
 

tombriden

Inactive Recognized Developer
thanks much. I need this feature much.

One question, is this change use up volume or down volume or both will work?

Yep, it'll work for both.


Am I correct that this mod will work only on deodexed android.policy.jar ?

Yep, the above steps are for de-odexed ROMs, but you may still be able to disassemble if you pull the jar and odex and run baksmali on android.policy.odex. If you get errors trying that then pull everything from the /system/framework folder and try it again


Annoyingly, i've just noticed that once the phone goes into a 'deep sleep', the volume buttons don't always wake it. Sometimes they'll work after a double press sometimes it needs to be the power button :-\
 
  • Like
Reactions: Rushing and ckpv5

mgmCube

Senior Member
Dec 21, 2010
632
104
Would it in theory be possible to use the home button to wake the phone or is that impossible because the buttons don't work when the screen is off?
I have wake on TP on my Desire now.
 

ckpv5

Inactive Recognized Contributor
Feb 11, 2008
14,354
18,301
Kuala Lumpur
Would it in theory be possible to use the home button to wake the phone or is that impossible because the buttons don't work when the screen is off?
I have wake on TP on my Desire now.

Not possible as the buttons don't work when the screen is off.

And when the phone goes to deep sleep mode, volume button to wake it not really works (tried both on odex and deodex ROMs).
 
  • Like
Reactions: mgmCube

mgmCube

Senior Member
Dec 21, 2010
632
104
Not possible as the buttons don't work when the screen is off.

And when the phone goes to deep sleep mode, volume button to wake it not really works (tried both on odex and deodex ROMs).


Ok so this volume unlock doesn't really work when in deep sleep?
This isn't mentioned in the first post.

So what if I use this volume unlock and disable the power button, then I have a problem after deep sleep?
 

ckpv5

Inactive Recognized Contributor
Feb 11, 2008
14,354
18,301
Kuala Lumpur
Ok so this volume unlock doesn't really work when in deep sleep?
This isn't mentioned in the first post.

So what if I use this volume unlock and disable the power button, then I have a problem after deep sleep?

Yeah... most of the time it doesn't work when in deep spleep. OP mentioned this on post #6 too.

With volume to wake (not unlock, you still need the swipe up to unlock), and disable the power button, you will have problem to wake and unlock when it goes deep sleep. When you have this problem, the only way to wake it is to plug-in a usb cable or charger as it will wake the phone, then you can unlock.
 

MasK

Senior Member
May 15, 2005
1,268
133
Singapore
www.imraneo.com
Well then.. I think its better to disable it as it does messes up my volume levels even if it doesnt wake up the device..

Any chance of a full feature here? Coz the phone is expected to go into deep sleep most of the time..

Sent from my HTC One X using XDA
 

elesbb

Senior Member
Jun 20, 2010
7,883
5,324
Jumping in here real quick, i dont (unfortunately) have an amazing all powerful OneX but i do have an HD2 :p

Anyhow, im posting in regards to the isWakeKeyWhenKeyguardShowing(I)Z method in the KeyguardViewMediator.smali file found in android.policy.jar. I already have the volume wake keys set via cyanogen mod, my question is this:

How can i ADD keys to this file to prevent the device from waking?

I tried converting the hex values from that file but they dont correspond with any key values (ex, volume down is 115) but 0x18 is 24, decimal value, so im not sure exactly what numbers must be added to correspond to the correct key.

Thanks all for your efforts and time spent reading!
 

Kammii

Member
Aug 23, 2009
6
13
Thank you for the guide. I don't have Generic.kl on my Motorola XT530, so I think I might need to fiddle round with the .kl files to see if I can get this mod working.

I had to modify my process slightly, so I'll explain what I did in case it may be of help to anyone else.

1. To copy android.policy.jar to my PC, I used Android Commander. It's nice and simple. Make sure you make a back up of android.policy.jar before you modify it in case you need/want to restore it.

2. Use Command Prompt and navigate to the folder in which android.policy.jar is located. For example:
Code:
cd C:\Android\temp

3. Disassemble classes.dex using the following command:
Code:
java -jar baksmali-1.3.2.jar -x android.policy.jar -o classout

4. Edit and save KeyguardViewMediator.smali as per the original post.

5. Reassemble classes.dex using the following command:
Code:
java -jar smali-1.3.2.jar classout -o classes.dex

6. Open android.policy.jar with 7-Zip (any archive manager should work) and replace classes.dex with the modified one.

7. Use Android Commander to replace android.policy.jar on phone.

8. Edit Generic.kl as per original post. I don't have Generic.kl on my phone, so I just left-out this step. I figured I could poke around the .kl files later if need be. I haven't done so yet.

9. Reboot.

Note: The filenames for baksmali-1.3.2.jar and smali-1.3.2.jar may be different if you have a different version. Simply adjust the commands above accordingly.
 
Last edited:
  • Like
Reactions: gbn11

simster007

Member
Aug 26, 2010
14
3
HTC Ones S --Works

Was looking for this on the HOS forums but found this close enough instead. Prob everyone knows this, but I did this same setup on my one s (t-mo-us) version, and it stuck. So thanks for this nice little tweak. Good to know dev's have our backs in everything.
 

andybones

Retired Forum Moderator / Inactive RD
May 18, 2010
15,092
15,480
Google Pixel 5
this was much appreciated for my inc2!
we got a new kernel and messed up it working in the tweaks app, so this really saved me, I didn't realize the Generic.kl needed to be updated.
thanks again!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 34
    I got so used to using the volume rocker to wake my DHD and show the lockscreen instead of the power button that i decided to try and add the same functionality to the OneX. The only caveat with this is that sometimes the volume slider shows up when it wakes, but i can live with that :)

    Hopefully, in time, the ROM devs will add this in by default or as an option. Until then it'll require these manual mods...


    Don't try the following if you're unsure what you're doing as you could potentially break the ROM if not done correctly. I recommend backing up first in Clockwork Recovery in case things go wrong.
    I accept no responsibility for any issues encountered making these changes!




    Requirements
    Rooted phone
    Android-SDK
    baksmali/smali from here

    Step 1 - Update android.policy.jar

    1. Do the following to get the android.policy.jar from your phone and disassemble it
    Code:
    adb pull /system/framework/android.policy.jar .
    baksmali -x android.policy.jar -o classout
    2. Open the following file in a text editor
    Code:
    classout/com/android/internal/policy/impl/KeyguardViewMediator.smali
    3. Find the method "isWakeKeyWhenKeyguardShowing(IZ)Z"
    4. At the bottom of the method, there's a switch statement. Remove the following 2 lines from it:
    Code:
            0x18 -> :sswitch_5
            0x19 -> :sswitch_5
    5. Save the file and close it.
    6. Run the following commmand to re-assemble classes.dex
    Code:
    smali classout -o classes.dex
    7. Drag the classes.dex into the android.policy.jar file to update the file in there.
    8. Push the updated android.policy.jar back to the phone
    Code:
    adb push android.policy.jar /sdcard/
    adb shell
    su
    sysrw
    cp /sdcard/android.policy.jar /system/framework/
    chmod 644 /system/framework/android.policy.jar


    Step 2 - Update Generic.kl

    1. Pull the file from your phone
    Code:
    adb pull /system/usr/keylayout/Generic.kl
    2. Open it in a text editor and change the lines
    Code:
    key 114   VOLUME_DOWN
    key 115   VOLUME_UP
    to
    Code:
    key 114   VOLUME_DOWN	WAKE_DROPPED
    key 115   VOLUME_UP	WAKE_DROPPED
    3. Push the file back to your phone
    Code:
    adb push Generic.kl /sdcard/
    adb shell
    su
    sysrw
    cp /sdcard/Generic.kl /system/usr/keylayout/
    chmod 644 /system/usr/keylayout/Generic.kl

    (of course, you could also make those changes to the file directly using a root file explorer app and text editor.)


    Step 3
    Reboot the phone.

    Note: The first time it boots after changing android.policy.jar, there'll be an 'Android is upgrading' dialog. This is normal and it won't happen on subsequent reboots.
    2
    thanks much. I need this feature much.

    One question, is this change use up volume or down volume or both will work?

    Yep, it'll work for both.


    Am I correct that this mod will work only on deodexed android.policy.jar ?

    Yep, the above steps are for de-odexed ROMs, but you may still be able to disassemble if you pull the jar and odex and run baksmali on android.policy.odex. If you get errors trying that then pull everything from the /system/framework folder and try it again


    Annoyingly, i've just noticed that once the phone goes into a 'deep sleep', the volume buttons don't always wake it. Sometimes they'll work after a double press sometimes it needs to be the power button :-\
    2
    "/sys/keyboard/vol_wakeup to 1 instead of 0" doesn't work...

    thats an old thread..look here:

    http://xdaforums.com/showthread.php?t=2084522

    this one works
    1
    How if I play music in off screen mode adjusting the volume?

    It'll still work, but the screen will wake too.
    1
    Would it in theory be possible to use the home button to wake the phone or is that impossible because the buttons don't work when the screen is off?
    I have wake on TP on my Desire now.

    Not possible as the buttons don't work when the screen is off.

    And when the phone goes to deep sleep mode, volume button to wake it not really works (tried both on odex and deodex ROMs).