[MOD] Wake on Volume Keys via android.policy.jar

Search This thread

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
This has been bothering me for awhile now. I set the phone on the table and browse or read on it. The screen goes off and now I have to pick the phone up to wake it back up. Very irritating! I'd rather be able to press the volume keys and use the pattern lock than use the fingerprint reader, when I'm not holding the phone.

I decided I'd look into this tonight and actually it turns out it's very easy. The script took longer than figuring the mod itself. Surprise, surprise, the solution is in android.policy.jar again.
This mod will make pressing the volume keys wake the phone first, then subsequent presses will change volume as usual. I won't bother with a detailed how-to this time since I put some time into a fairly complete script, but for people who are curious, here are the details:

File: KeyguardViewMediator.smali
Method: private isWakeKeyWhenKeyguardShowing(I)Z
How: Delete cases 0x18 and 0x19 in the switch statement at the bottom of the method. These tell it to return true for volume up and down keys. Careful about changing the others. Some refer to non-existent buttons on the Atrix, but others (as I found out) affect your headset mic button and other events. For a detailed how-to on taking apart and putting together the android.policy.jar, please see this thread

The script is now universal, for all ROMs. OS X, Linux, Windows.

How does it do that? Like this:

1. It takes android.policy.jar directly from your phone.
2. Decompiles the jar.
3. Patches it.
4. Recompiles it.
5. Pushes the jar back onto your phone.
6. Cleans up and reboots the phone.


Some prerequisites before you run the script:

1. Obviously make sure you're backed up. You can't hard brick with this, but there is a possibility of soft brick if there's a bug. It should be safe because it checks for errors at nearly every command, but nevertheless have CWM ready. I have tested this on OS X and Windows. Linux users, you will need to test this yourself. It should be fine though, because you use the same script as OS X, but with a different adb. Just verify that the script and adb have the correct executable permissions, or chmod as necessary.

2. You must have java installed on your computer because it needs that to compile the android.policy.jar file. To check, you can type, "java" in a command line window. If you get a "no java command" type message, then java isn't installed correctly on your machine, or you need to add the path to java.exe to your path environment variable.

3. You must be deodexed.

4. Make sure to set your USB connection to "None" on your phone.

5. On your phone, go to Settings > Applications > Development and make sure USB debugging is turned on.

6. Plug your phone into your PC and let it install any necessary drivers. (OS X users ignore this, Linux users... You're on your own ;))

7. Then you can run wakeonvolume.sh for OS X/Linux and wakeonvolume.bat for windows.

* Thanks to natboy for solving the script issue for XP users!
 

Attachments

  • wakeonvolume_v1.1.zip
    5.6 MB · Views: 2,588
Last edited:

franciscojavierleon

Senior Member
Jul 16, 2010
441
39
Maracaibo
nice work, although you could have just installed nolock from the market and be done with it :) don't need root and a a risky mod for it

I hate the sliding finger lock screen.. it's worthless... Yet if you disable the screen lock it doesn't go away. i consider that a bug.
 

franciscojavierleon

Senior Member
Jul 16, 2010
441
39
Maracaibo
2. You must have java installed on your computer because it needs that to compile the android.policy.jar file. To check, you can type, "java" in a command line window. If you get a "no java command" type message, then java isn't installed correctly on your machine, or you need to add the path to java.exe to your path environment variable.

You need a java compiler (javac) or just the java virtual machine (java) ?
If you need a compiler then you need the java sdk not just the j2se
 

Jonous

Senior Member
Jan 12, 2008
581
62
No error msgs, phone rebooted but mod doesn't seem to work, phone doesn't wake up.
 

n1ckr0th

Senior Member
Jun 16, 2010
218
87
Atlanta
-----------------------------------------
Pick your ROM:

1) Bell
2) Stock ATT 1.83
3) GingerBlur v4
4) Gladiatrix
-----------------------------------------
'choice' is not recognized as an internal or external command,
operable program or batch file.

Copying system files...
135 File(s) copied

-----------------------------------------
Do you want the "No Hardkey Vibrations" mod?
'choice' is not recognized as an internal or external command,
operable program or batch file.

-----------------------------------------
Do you want the "Volume Keys Wake" mod?
'choice' is not recognized as an internal or external command,
operable program or batch file.

-----------------------------------------
Compiling classes.dex...

-----------------------------------------
Packaging android.policy.jar...

7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive .\android.policy.jar

Compressing classes.dex
Compressing META-INF\MANIFEST.MF

Everything is Ok

-----------------------------------------
Cleaning up work directory...


now i believe i have the standard services.jar, because hard key vibes are back.
 

stevendeb25

Senior Member
May 27, 2010
2,515
2,099
england
pnht.org
-----------------------------------------
Pick your ROM:

1) Bell
2) Stock ATT 1.83
3) GingerBlur v4
4) Gladiatrix
-----------------------------------------
'choice' is not recognized as an internal or external command,
operable program or batch file.

Copying system files...
135 File(s) copied

-----------------------------------------
Do you want the "No Hardkey Vibrations" mod?
'choice' is not recognized as an internal or external command,
operable program or batch file.

-----------------------------------------
Do you want the "Volume Keys Wake" mod?
'choice' is not recognized as an internal or external command,
operable program or batch file.

-----------------------------------------
Compiling classes.dex...

-----------------------------------------
Packaging android.policy.jar...

7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive .\android.policy.jar

Compressing classes.dex
Compressing META-INF\MANIFEST.MF

Everything is Ok

-----------------------------------------
Cleaning up work directory...


now i believe i have the standard services.jar, because hard key vibes are back.

same here, no errors, but no choices
 

natboy

Senior Member
Mar 7, 2011
208
28
Anchorage, AK
Looks like for one thing the script is using CHOICE which isn't available in Windows XP/NT. It was in MS-DOS and in Vista/Win 7.

I'm supplying the CHOICE.COM that came with the MSDOS supplement disks. You can google it and download it straight from Microsoft, so there shouldn't be any problems here. Unzip it and put it in the same directory the batch file is in. Also modify the batch file on the 12th line instead of choice /c 1234 put:

choice /C:1234

Edit: I haven't actually tried this yet, but that should get it going. Will try in a few..

Edit 2: This should only be needed if you're running WinXP/NT. I'm assuming it works under Win7 already.

Edit 3: It works! Once I added the choice.com file and modified the script as stated above, it worked on my XP box. Thanks for the mods OP! FYI, I'm on Gladiatrix v3.

Edit 4: Sorry for keep editing this post :) I must be bored at work today. With this latest edit, I'm uploading a zip for XP that has the choice.com file in it and the script modified to work with it. I'd think it'd work in Win7 also, but someone should test it to try it out.
 

Attachments

  • CHOICE.zip
    1.1 KB · Views: 69
Last edited:
  • Like
Reactions: thacvu and n1ckr0th

n1ckr0th

Senior Member
Jun 16, 2010
218
87
Atlanta
Looks like for one thing the script is using CHOICE which isn't available in Windows XP/NT. It was in MS-DOS and in Vista/Win 7.

I'm supplying the CHOICE.COM that came with the MSDOS supplement disks. You can google it and download it straight from Microsoft, so there shouldn't be any problems here. Unzip it and put it in the same directory the batch file is in. Also modify the batch file on the 12th line instead of choice /c 1234 put:

choice /C:1234

Edit: I haven't actually tried this yet, but that should get it going. Will try in a few..

Edit 2: This should only be needed if you're running WinXP/NT. I'm assuming it works under Win7 already.

Edit 3: It works! Once I added the choice.com file and modified the script as stated above, it worked on my XP box. Thanks for the mods OP! FYI, I'm on Gladiatrix v3.

Edit 4: Sorry for keep editing this post :) I must be bored at work today. With this latest edit, I'm uploading a zip for XP that has the choice.com file in it and the script modified to work with it. I'd think it'd work in Win7 also, but someone should test it to try it out.

thank you so much natboy!
worked for me!
maleydris i love your mods, if i had a way of donating i would.
 
Last edited:

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
Looks like for one thing the script is using CHOICE which isn't available in Windows XP/NT. It was in MS-DOS and in Vista/Win 7.

I'm supplying the CHOICE.COM that came with the MSDOS supplement disks. You can google it and download it straight from Microsoft, so there shouldn't be any problems here. Unzip it and put it in the same directory the batch file is in. Also modify the batch file on the 12th line instead of choice /c 1234 put:

choice /C:1234

Edit: I haven't actually tried this yet, but that should get it going. Will try in a few..

Edit 2: This should only be needed if you're running WinXP/NT. I'm assuming it works under Win7 already.

Edit 3: It works! Once I added the choice.com file and modified the script as stated above, it worked on my XP box. Thanks for the mods OP! FYI, I'm on Gladiatrix v3.

Edit 4: Sorry for keep editing this post :) I must be bored at work today. With this latest edit, I'm uploading a zip for XP that has the choice.com file in it and the script modified to work with it. I'd think it'd work in Win7 also, but someone should test it to try it out.

Ah, sorry guys! I didn't realize that wasn't part of XP!

And thank you natboy! :) I'll update the OP when i'm home from work

Sent from my MB860 using XDA Premium App
 
  • Like
Reactions: n1ckr0th

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
nice work, although you could have just installed nolock from the market and be done with it :) don't need root and a a risky mod for it

I hate the sliding finger lock screen.. it's worthless... Yet if you disable the screen lock it doesn't go away. i consider that a bug.

Nah, why would I want to completely get rid of lock? It's useful to me. I also like the fingerprint reader. I just want to be able to wake the phone's screen without resorting to the recessed power button. I'm generally satisfied with the locking mechanism as it is.

Granted, the script is risky as we've found ;) the mod itself though is very clean and it's very clear cut what the code is doing there.

Sent from my MB860 using XDA Premium App
 
Last edited:
  • Like
Reactions: stevendeb25

natboy

Senior Member
Mar 7, 2011
208
28
Anchorage, AK
Ah, sorry guys! I didn't realize that wasn't part of XP!

And thank you natboy! :) I'll update the OP when i'm home from work

Sent from my MB860 using XDA Premium App

Glad to help, thanks for the mod. I find it easier to unlock the phone now, by pushing the volume key with my thumb and swiping with my finger. Pushing the back button with the finger and sliding seemed to herky jerky to me.
 
  • Like
Reactions: stevendeb25

madquack

Senior Member
May 12, 2010
704
383
You guys should try out no lock. It gets rid of the lock screen and allows you to wake up the phone with the volume keys.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 29
    This has been bothering me for awhile now. I set the phone on the table and browse or read on it. The screen goes off and now I have to pick the phone up to wake it back up. Very irritating! I'd rather be able to press the volume keys and use the pattern lock than use the fingerprint reader, when I'm not holding the phone.

    I decided I'd look into this tonight and actually it turns out it's very easy. The script took longer than figuring the mod itself. Surprise, surprise, the solution is in android.policy.jar again.
    This mod will make pressing the volume keys wake the phone first, then subsequent presses will change volume as usual. I won't bother with a detailed how-to this time since I put some time into a fairly complete script, but for people who are curious, here are the details:

    File: KeyguardViewMediator.smali
    Method: private isWakeKeyWhenKeyguardShowing(I)Z
    How: Delete cases 0x18 and 0x19 in the switch statement at the bottom of the method. These tell it to return true for volume up and down keys. Careful about changing the others. Some refer to non-existent buttons on the Atrix, but others (as I found out) affect your headset mic button and other events. For a detailed how-to on taking apart and putting together the android.policy.jar, please see this thread

    The script is now universal, for all ROMs. OS X, Linux, Windows.

    How does it do that? Like this:

    1. It takes android.policy.jar directly from your phone.
    2. Decompiles the jar.
    3. Patches it.
    4. Recompiles it.
    5. Pushes the jar back onto your phone.
    6. Cleans up and reboots the phone.


    Some prerequisites before you run the script:

    1. Obviously make sure you're backed up. You can't hard brick with this, but there is a possibility of soft brick if there's a bug. It should be safe because it checks for errors at nearly every command, but nevertheless have CWM ready. I have tested this on OS X and Windows. Linux users, you will need to test this yourself. It should be fine though, because you use the same script as OS X, but with a different adb. Just verify that the script and adb have the correct executable permissions, or chmod as necessary.

    2. You must have java installed on your computer because it needs that to compile the android.policy.jar file. To check, you can type, "java" in a command line window. If you get a "no java command" type message, then java isn't installed correctly on your machine, or you need to add the path to java.exe to your path environment variable.

    3. You must be deodexed.

    4. Make sure to set your USB connection to "None" on your phone.

    5. On your phone, go to Settings > Applications > Development and make sure USB debugging is turned on.

    6. Plug your phone into your PC and let it install any necessary drivers. (OS X users ignore this, Linux users... You're on your own ;))

    7. Then you can run wakeonvolume.sh for OS X/Linux and wakeonvolume.bat for windows.

    * Thanks to natboy for solving the script issue for XP users!
    2
    Looks like for one thing the script is using CHOICE which isn't available in Windows XP/NT. It was in MS-DOS and in Vista/Win 7.

    I'm supplying the CHOICE.COM that came with the MSDOS supplement disks. You can google it and download it straight from Microsoft, so there shouldn't be any problems here. Unzip it and put it in the same directory the batch file is in. Also modify the batch file on the 12th line instead of choice /c 1234 put:

    choice /C:1234

    Edit: I haven't actually tried this yet, but that should get it going. Will try in a few..

    Edit 2: This should only be needed if you're running WinXP/NT. I'm assuming it works under Win7 already.

    Edit 3: It works! Once I added the choice.com file and modified the script as stated above, it worked on my XP box. Thanks for the mods OP! FYI, I'm on Gladiatrix v3.

    Edit 4: Sorry for keep editing this post :) I must be bored at work today. With this latest edit, I'm uploading a zip for XP that has the choice.com file in it and the script modified to work with it. I'd think it'd work in Win7 also, but someone should test it to try it out.
    1
    Looks like for one thing the script is using CHOICE which isn't available in Windows XP/NT. It was in MS-DOS and in Vista/Win 7.

    I'm supplying the CHOICE.COM that came with the MSDOS supplement disks. You can google it and download it straight from Microsoft, so there shouldn't be any problems here. Unzip it and put it in the same directory the batch file is in. Also modify the batch file on the 12th line instead of choice /c 1234 put:

    choice /C:1234

    Edit: I haven't actually tried this yet, but that should get it going. Will try in a few..

    Edit 2: This should only be needed if you're running WinXP/NT. I'm assuming it works under Win7 already.

    Edit 3: It works! Once I added the choice.com file and modified the script as stated above, it worked on my XP box. Thanks for the mods OP! FYI, I'm on Gladiatrix v3.

    Edit 4: Sorry for keep editing this post :) I must be bored at work today. With this latest edit, I'm uploading a zip for XP that has the choice.com file in it and the script modified to work with it. I'd think it'd work in Win7 also, but someone should test it to try it out.

    Ah, sorry guys! I didn't realize that wasn't part of XP!

    And thank you natboy! :) I'll update the OP when i'm home from work

    Sent from my MB860 using XDA Premium App
    1
    nice work, although you could have just installed nolock from the market and be done with it :) don't need root and a a risky mod for it

    I hate the sliding finger lock screen.. it's worthless... Yet if you disable the screen lock it doesn't go away. i consider that a bug.

    Nah, why would I want to completely get rid of lock? It's useful to me. I also like the fingerprint reader. I just want to be able to wake the phone's screen without resorting to the recessed power button. I'm generally satisfied with the locking mechanism as it is.

    Granted, the script is risky as we've found ;) the mod itself though is very clean and it's very clear cut what the code is doing there.

    Sent from my MB860 using XDA Premium App
    1
    Ah, sorry guys! I didn't realize that wasn't part of XP!

    And thank you natboy! :) I'll update the OP when i'm home from work

    Sent from my MB860 using XDA Premium App

    Glad to help, thanks for the mod. I find it easier to unlock the phone now, by pushing the volume key with my thumb and swiping with my finger. Pushing the back button with the finger and sliding seemed to herky jerky to me.