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

Search This thread

stvmac11

Senior Member
Jan 3, 2011
118
17
Delay

Nice MOD, OP!

Any chance of having a version that allows for wake after holding the volume key for X seconds?

In case of accidental key presses in a pocket?
 
Last edited:

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
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.

Okay, I've reposted the file in the OP with the correction. I wanted to use the file you had attached, but unfortunately that's a 16-bit executable meaning it doesn't work for 64-bit systems. In the interest of keeping everyone using the same files and keeping the least amount of test cases I went and found a 32-bit version. Now that I know about this XP issue, next time I do a script I'll use "set /p" instead :rolleyes:
 

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
Nice MOD, OP!

Any chance of having a version that allows for wake after holding the volume key for X seconds?

In case of accidental key presses in a pocket?

Hmm, I actually don't anticipate having that problem because I find the buttons on my Atrix are firm enough and small enough that I don't think they'd ever click in my pocket. I sometimes use a case and I find it's especially difficult then. If I do notice that this is an issue, then I might look into that.
 

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
Why not just make *.apk leave pc step out..

Sent from my MB860 using Tapatalk

Nah, an .apk would not be practical in this situation. This is much easier for me to maintain. I cannot compile Dalvik byte code on the phone itself. That means that if I add in another mod I'd be packaging dozens of precompiled android.policy.jars for every possible choice the user could make, multiplied by the number of different ROMS... That's a lot of .jars!
 

scoob8000

Senior Member
Sep 15, 2009
190
13
Very nice, I've been hunting for an app to do this.

Can anyone confirm if being deodex'd is required for sure?
 

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
Very nice, I've been hunting for an app to do this.

Can anyone confirm if being deodex'd is required for sure?

I've been doing a little reading up on it, and since I recently went to the France sbf, I was able to compare what the original files looked like. You wouldn't need to be completely deodexed but you would need to remove the odex file for android.policy.jar that sits in /system/framework/ on a stock system, and then you would also have to clean up the dalvik cache for files related to that file... really, with all that trouble you might as well just deodex the whole thing ;)

Sent from my MB860 using XDA Premium App
 

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
Since I've gotten some private messages on this I thought I should let everyone know that I've diff'ed the files for gingerblur 4 and 4.5 and there is no difference between android.policy.jar on those two roms. That means this mod is usable on both systems without any change :)

Sent from my MB860 using XDA Premium App
 

maledyris

Senior Member
Mar 25, 2011
170
58
Burnaby
i get a "permission denied" after "Compiling classes.dex..."

Hey, sorry, was kind of busy and didn't notice this message. Anyway, keep an eye on your phone's screen when the script is running. Super User was probably asking for access. When you don't press accept or cancel after 5-10 seconds, it just cancels automatically.
 

n1ckr0th

Senior Member
Jun 16, 2010
218
87
Atlanta

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.