Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,729,384 Members 43,204 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
maledyris
Old
(Last edited by maledyris; 7th August 2011 at 10:51 AM.)
#1  
Senior Member - OP
Thanks Meter 58
Posts: 170
Join Date: Mar 2011
Location: Burnaby

 
DONATE TO ME
Default [MOD] Wake on Volume Keys via android.policy.jar

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!
Attached Files
File Type: zip wakeonvolume_v1.1.zip - [Click for QR Code] (5.56 MB, 2366 views)
The Following 28 Users Say Thank You to maledyris For This Useful Post: [ Click to Expand ]
 
xredjokerx
Old
#2  
Senior Member
Thanks Meter 157
Posts: 951
Join Date: Nov 2009
I appreciate you and your work in the development of the atrix
Currently running: Galaxy Note II

If you don't have drop box, please help me out and use my referral link http://db.tt/XJuRP3T
 
maledyris
Old
#3  
Senior Member - OP
Thanks Meter 58
Posts: 170
Join Date: Mar 2011
Location: Burnaby

 
DONATE TO ME
Quote:
Originally Posted by xredjokerx View Post
I appreciate you and your work in the development of the atrix
I'm happy to help out my fellow Atrix users
 
franciscojavierleon
Old
#4  
Senior Member
Thanks Meter 38
Posts: 430
Join Date: Jul 2010
Location: 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
Old
#5  
Senior Member
Thanks Meter 38
Posts: 430
Join Date: Jul 2010
Location: Maracaibo
Quote:
Originally Posted by maledyris View Post
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
Old
#6  
Senior Member
Thanks Meter 39
Posts: 458
Join Date: Jan 2008
No error msgs, phone rebooted but mod doesn't seem to work, phone doesn't wake up.
 
n1ckr0th
Old
#7  
n1ckr0th's Avatar
Senior Member
Thanks Meter 89
Posts: 214
Join Date: Jun 2010
Location: Atlanta
booting up my virtual machine as we speak
i'll report results soon.
Current Phone: Nexus 5
KitKat 4.4.2
Cataclysm

Follow me on Twitter!

Want (Almost) Sense on your Atrix? look no further!

Privacy concerns on your Atrix?

My Past Phone Timeline..
Alcatel prototype -> Sony Ericsson W810i -> Sony Ericsson W510i -> HTC G1 -> Apple iPhone 3G -> Nokia E71x -> Apple iPhone 3GS -> Nokia E75 -> RIM Blackberry Curve 8900 -> Motorola Atrix -> Apple iPhone 5 -> AT&T Moto X -> Nexus 5
 
n1ckr0th
Old
#8  
n1ckr0th's Avatar
Senior Member
Thanks Meter 89
Posts: 214
Join Date: Jun 2010
Location: 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.
Current Phone: Nexus 5
KitKat 4.4.2
Cataclysm

Follow me on Twitter!

Want (Almost) Sense on your Atrix? look no further!

Privacy concerns on your Atrix?

My Past Phone Timeline..
Alcatel prototype -> Sony Ericsson W810i -> Sony Ericsson W510i -> HTC G1 -> Apple iPhone 3G -> Nokia E71x -> Apple iPhone 3GS -> Nokia E75 -> RIM Blackberry Curve 8900 -> Motorola Atrix -> Apple iPhone 5 -> AT&T Moto X -> Nexus 5
 
stevendeb25
Old
#9  
Senior Member
Thanks Meter 1013
Posts: 1,320
Join Date: May 2010
Location: england

 
DONATE TO ME
Quote:
Originally Posted by n1ckr0th View Post
-----------------------------------------
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
Founder of the international Unlocked Bootloader for Atrix

My Ported Roms:
CM7/MIUI ATRIX
JoyOS ATRIX
MokeeOS ATRIX

If you like my work feel free to donate me some beers or sign up at Point2shop

http://www.points2shop.com?ref=stevendeb25
 
dincodee
Old
#10  
Senior Member
Thanks Meter 2
Posts: 153
Join Date: May 2010
Quote:
Originally Posted by stevendeb25 View Post
same here, no errors, but no choices
Worked for me, just make sure you run batch as admin and put it on the root of the C drive.

Tags
volume keys, wake
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes