[MOD/HOW-TO] Remove hard key vibes via android.policy.jar

maledyris

Senior Member
Mar 25, 2011
170
58
0
Burnaby
I thought I'd offer my solution to disabling the hard key vibrations on the Atrix since other people might find this useful. This method differs from the other solutions in that it doesn't tamper with your Silent Mode vibrations (like StreakVibrations does) and it's code based, so it shouldn't tamper with any themes you have installed (like the framework-res.apk method). It is firmware dependent though since it's a code modification.
You'll need an android.policy.jar modified for your firmware.

What I'm doing is I'm modifying the method called performHapticFeedbackLw, and telling it to skip triggering the vibrate pattern for all effects (there are 5) except for keyboard taps. Long press vibe, virtual key vibe, safe mode disabled vibe, and safe mode enabled vibe will no longer trigger... Incidentally, does anyone know what safe mode on this phone refers to?

To use the file, you need to be on Bell, Telstra, GingerBlur, Gladiatrix or stock ATT 1.8.3 firmware, and be deodexed. Can you copy the file to your phone without being deodexed? I don't know. I'm a programmer, but an Android newbie so just to be safe it's best if you're deodexed.

Before you try anything, obviously make sure you are backed up. At least copy your existing android.policy.jar so that you can restore it if necessary.
All you need to do is either:

a) Run the novibes.bat script packaged in the zip. There are a couple prerequisites:

1. Make sure to set your USB connection to "None" on your phone.
2. On your phone, go to Settings > Applications > Development and make sure USB debugging is turned on.
3. Plug your phone into your PC and let it install any necessary drivers.
4. Then you can run novibes.bat.

or

b) Follow the steps outlined below to do it manually:

1. Replace /system/framework/android.policy.jar with the one that I've attached.
2. Make sure the permissions of the file are set to rw-r--r-- (thanks for reminding me, Meloy and for correcting, natboy!). The easiest way is to use Root Explorer, long press the file, choose permissions, and set owner: read/write, group:read, others:read. Otherwise, use Terminal and type "chmod 644 /system/framework/android.policy.jar" without the quotations.
3. Reboot.

For those not on stock Bell, I'd be willing to modify your android.policy.jar and post it here if you provide somewhere for me to download it, and specify what firmware it comes from. It's quite quick to do once you're set up so I don't mind. Alternatively, make the change yourself:

1. Download baksmali and smali (both .jars and scripts, total 4 files).
2. Copy /system/framework/ from your phone to your computer.
3. Copy all the files from step 1 to the framework directory from step 2 on your computer.
4. Unzip android.policy.jar and copy its classes.dex file to the framework directory on your computer.
5. From the command line, navigate to the framework directory and run "./baksmali classes.dex". It will create a directory named "out".
6. Open "out/com/android/internal/policy/impl/PhoneWindowManager.smali" in a text editor.
7. Search for a method called "performHapticFeedbackLw". Go to near the bottom of that method, and you will see the Dalvik bytecode representation of a switch statement:

Code:
    .sparse-switch
        0x0 -> :sswitch_27			#This is for long press vibe
        0x1 -> :sswitch_35			#This is for virtual key vibe
        0x3 -> :sswitch_38			#This is for keyboard tap vibe
        0x2710 -> :sswitch_3b		#This is for safemode disabled vibe
        0x2711 -> :sswitch_3e		#This is for safemode enabled vibe
    .end sparse-switch
8. Here's an example of how you might want it to change. Basically you want to replace the original goto labels with one that causes the method to step out without triggering a vibe, and that notifies the calling method there was no vibe by returning false. The label to use is called ":cond_1d":
Code:
    .sparse-switch
        0x0 -> :cond_1d			#This is for long press vibe
        0x1 -> :cond_1d			#This is for virtual key vibe
        0x3 -> :sswitch_38			#This is for keyboard tap vibe
        0x2710 -> :cond_1d		#This is for safemode disabled vibe
        0x2711 -> :cond_1d		#This is for safemode enabled vibe
    .end sparse-switch
9. From the command line in the framework directory, run "./smali -o classes.dex out". You now have a new classes.dex that has your modification.
10. Zip up the classes.dex with the META-INF directory from your original android.policy.jar. Rename the zip to android.policy.jar.
11. Copy the new file to your phone and reboot.
12. At this point you should be done.
 

Attachments

Last edited:

bearsfan172

Senior Member
Mar 6, 2011
135
40
0

n1ckr0th

Senior Member
Jun 16, 2010
218
87
0
Atlanta

maledyris

Senior Member
Mar 25, 2011
170
58
0
Burnaby
thank you, but i wonder if this specific method is possible on the atrix as to retain themes and such.
interesting that its in general, development may be a better home for it.
Yes, this would work perfectly fine on ATT. You can either follow the instructions I provided, or if you like you can post /system/framework/android.policy.jar from your phone somewhere and pm me the link so I can download it and I'll do it for you. Also mention what firmware you're on. I just don't want to download hundreds of MB of firmwares which is why I didn't set one up for all the ATT firmwares.

That other method requires editing a file that is guaranteed to change with any theme you install. That means anytime you change themes you'll need to edit that .apk yourself, or wait for someone to bring the change over. android.policy.jar is unlikely to change for themes.
 
Last edited:
  • Like
Reactions: n1ckr0th

maledyris

Senior Member
Mar 25, 2011
170
58
0
Burnaby
Ok, I've posted a version for ATT 1.8.3 that was given to me by n1ckr0th.
n1ckr0th, let me know whether it works fine or not. There should be no problem, it looked just like the other 2 versions I modified.
Incidentally, he's using GingerBlur 3.5 so anyone on stock be careful (ie. copy your original file to somewhere else on your phone). It shouldn't matter at all because from what I see, there aren't any resources to modify in android.policy.jar so GingerBlur's should be the same as stock. At any rate, it won't brick your phone if you put the wrong one on. I put Telstra's on my phone by accident and it just messed up the the graphics on screen (maybe because the addresses were all wrong for my phone). You can still use adb, or sshdroid to copy and replace with your original android.policy.jar.
 

maledyris

Senior Member
Mar 25, 2011
170
58
0
Burnaby
Don't use this on AT&T 1.83!

After the replace and reboot my phone was really laggy and some applications doesn't start anymore (camera, contacs for example). After i have replaced it with the original file i have still the same problem.

My phone config:
- SBF 1.83
- rooted (GingerBreak 1.20)
- sideloading enabled (GladEnabler)
- GladiAtrix 3 b0.2 ROM
- LauncherPRO
- GingerBread Theme only
What? That can't be right, if you still have the same problem after copying the original file, that means that you must have done something wrong. It's a single file change, provided you returned the file to the original, it will be back to the way it was. How did you copy the file? And also, are you deodexed? As mentioned in the original post, you have to be deodexed, because I don't know the results of using it on a non-deodexed system. Your posted config makes it sound like you might not be.
 

meloy

Member
Mar 6, 2011
38
1
0
Sorry, my mistake. It is deodexed, I have just forgot to set the permissions to rw-r-r, you should maybe mention this in your start post. It's all working fine now. Thanks for the good work. :D

By the way, your mod (android.policy.att_1.8.3.zip) has added an "reboot" function to my phone, it is working well too.
 

maledyris

Senior Member
Mar 25, 2011
170
58
0
Burnaby
Sorry, my mistake. It is deodexed, I have just forgot to set the permissions to rw-r-r, you should maybe mention this in your start post. It's all working fine now. Thanks for the good work. :D

By the way, your mod (android.policy.att_1.8.3.zip) has added an "reboot" function to my phone, it is working well too.
Haha, that's good. Had me scared for a moment, I didn't want to break anyone's phone! ;)
Thanks for the tip, I'll mention that in the original post. Oh, and what do you mean by the reboot function...? Where did you access that? I certainly didn't add it, so it might be a mod added to GingerBlur?
 

meloy

Member
Mar 6, 2011
38
1
0
Oh, and what do you mean by the reboot function...? Where did you access that? I certainly didn't add it, so it might be a mod added to GingerBlur?
When i go to the phone options i have now these selection:
- Silent Mode
- Airplane Mode
- Power off
- Reboot

Yes, i think it is a GingerBlur mod. But it doesn't bother me, it is a good feature.
 

maledyris

Senior Member
Mar 25, 2011
170
58
0
Burnaby
When i go to the phone options i have now these selection:
- Silent Mode
- Airplane Mode
- Power off
- Reboot

Yes, i think it is a GingerBlur mod. But it doesn't bother me, it is a good feature.
Interesting, that never occurred to me. I usually go into terminal and type in reboot to reboot my phone. I think I'll add that to my phone too...
 

n1ckr0th

Senior Member
Jun 16, 2010
218
87
0
Atlanta
Haha, that's good. Had me scared for a moment, I didn't want to break anyone's phone! ;)
Thanks for the tip, I'll mention that in the original post. Oh, and what do you mean by the reboot function...? Where did you access that? I certainly didn't add it, so it might be a mod added to GingerBlur?
the reboot function is cooked into GingerBlur. for some reason my phone wouldnt boot after i replaced the file? i used root explorer and set the permissions to whats specified.
 

maledyris

Senior Member
Mar 25, 2011
170
58
0
Burnaby
the reboot function is cooked into GingerBlur. for some reason my phone wouldnt boot after i replaced the file? i used root explorer and set the permissions to whats specified.
Hmm, how far does it get? Do you at least get to the boot animation? I notice that it may sit at the boot animation for a really long time after changing a file sometimes. Probably updating the cache or something. It's odd that it wouldn't work for you considering it's your file and it worked for meloy. How did you copy the file over?
If you try again, delete the original file, so you can be sure it's no longer there, then try the copy again.
 

lurchbyrep

Senior Member
Mar 5, 2011
266
46
0
Pocatello, ID
I'm on AT&T 1.8.3. I followed instructions just as in OP (yes, including the proper setting of permissions), but I soon found a significant problem. Everytime I held down my power button in order to invoke the power options menu, instead of the menu popping up, my phone just freaked out (the screen quickly FADED to black and the phone rebooted). I did this about four times, and each time it happened exactly the same. So I brought back the original framework file, and now everything works fine.

Any ideas?
 

n1ckr0th

Senior Member
Jun 16, 2010
218
87
0
Atlanta
It gave me a red light on boot, stuck at Motorola logo for infinity. I booted into recovery and reflashed gb 3.5 to fix it. Ill try your idea of deleting it then moving the new one.

Sent from my MB860 using XDA App

EDIT: still didnt boot, had to flash again..
 
Last edited:

natboy

Senior Member
Mar 7, 2011
208
28
28
Anchorage, AK
I'm getting the flashing red light and rebooting as well. I can't get into CWM though, going to have to flash a SBF. Only think I can think of is maybe the Dalvik cache needs to be wiped before rebooting?

Edit: I'm on an AT&T phone and used GB to deodex as well.. maybe it's not catching all the files..
 

maledyris

Senior Member
Mar 25, 2011
170
58
0
Burnaby
I'm on AT&T 1.8.3. I followed instructions just as in OP (yes, including the proper setting of permissions), but I soon found a significant problem. Everytime I held down my power button in order to invoke the power options menu, instead of the menu popping up, my phone just freaked out (the screen quickly FADED to black and the phone rebooted). I did this about four times, and each time it happened exactly the same. So I brought back the original framework file, and now everything works fine.

Any ideas?
Are you on stock 1.83? Now that we know that android.policy.jar has some mods built into it for Gingerblur pseudo rom, the att 1.83 file I posted probably isn't ideal for stock users.
If you're on stock, maybe you could post your android.policy.jar somewhere and pm me the link to download. Then I could put together a pure stock att one when I get home.


Sent from my MB860 using XDA App