5,597,762 Members 36,944 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE | TUT | HACK] Remove Android 4.2.x safe volume message

Tip us?
 
elesbb
Old
(Last edited by elesbb; 7th May 2013 at 09:23 PM.)
#1  
elesbb's Avatar
Senior Member - OP
Thanks Meter 3859
Posts: 6,243
Join Date: Jun 2010

 
DONATE TO ME
Default [GUIDE | TUT | HACK] Remove Android 4.2.x safe volume message

Hey XDA community! :)

I received the Android 4.2.1 update for my Asus Transformer TF300T tablet and after using it for awhile i noticed when headphones are plugged into the device, and you increase the volume past (10 for my tablet) you will get a message saying that it is unsafe to use headphones at high volumes. Well I'm sorry. If people really need that message because they do not have the common sense to figure it out, well i have no comment.




So since this message is awfully annoying, i decided to go forth and remove it.

After hours of Google not helping, only finding other people on Nexus 7 devices and the like, seriously annoyed with it as i was. I knew i had to write this guide.

So here we go! :)

Firstly, there are two methods i discovered to remove this. First method, and prolly the easiest for people, is to:

1. Grab your framework-res.apk file from /system/framework/framework-res.apk using either adb or root explorer on your device
2. Using APKTool decompile framework-res.apk
3. Once decompiled directory.
4. Navigate to the file framework-res.apk/res/values/integers.xml YOU MUST USE NOTEPAD++ DO NOT USE MS NOTEPAD (Linux users need not worry)
5. Find the following "<integer name="config_safe_media_volume_index">10</integer>"
6. Change the "10" to a "20"
7. Save the changes to the xml file
8. Recompile the framework-res.apk with APKTool
9. Using adb or a flashable zip, put the framework-res.apk back to your device by:

adb remount

adb push <path to newly compiled apk> /system/framework/framework-res.apk

adb shell chmod 644 /system/framework/framework-res.apk

10. Reboot device and test :)






The second method is a little more tricky as it deals with smali code. Some people have no idea what smali code is but for those who do, this is the mod i personally use.

1. Grab your framework.jar file from /system/framework/framework.jar directory
2. Using either apktool, or baksmali, decompile framework.jar
3. Once decompiled, find the file framework.jar/smali/android/media/AudioService$AudioHandler.smali
4. YOU MUST USE NOTEPAD++ AGAIN! (Linux users again need not worry :) )
5. Once opened, find the following.

Code:
:pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_2
        :pswitch_3
        :pswitch_5
        :pswitch_6
        :pswitch_7
        :pswitch_9
        :pswitch_a
        :pswitch_8
        :pswitch_b
        :pswitch_c
        :pswitch_f
        :pswitch_d
        :pswitch_e
        :pswitch_1
        :pswitch_4
        :pswitch_12
        :pswitch_13
        :pswitch_14
        :pswitch_15
        :pswitch_b
        :pswitch_10
        :pswitch_11
        :pswitch_16
        :pswitch_17
        :pswitch_18
        :pswitch_19
        :pswitch_19
    .end packed-switch

6. at the bottom, you will see
Code:
:pswitch_19
(hoping this is the same for all devices) and comment out
Code:
:pswitch_19
(i have two i dont know why, if you also have two, comment both out)

Should look like this:

Code:
:pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_2
        :pswitch_3
        :pswitch_5
        :pswitch_6
        :pswitch_7
        :pswitch_9
        :pswitch_a
        :pswitch_8
        :pswitch_b
        :pswitch_c
        :pswitch_f
        :pswitch_d
        :pswitch_e
        :pswitch_1
        :pswitch_4
        :pswitch_12
        :pswitch_13
        :pswitch_14
        :pswitch_15
        :pswitch_b
        :pswitch_10
        :pswitch_11
        :pswitch_16
        :pswitch_17
        :pswitch_18
     #   :pswitch_19
     #   :pswitch_19
    .end packed-switch
7. Once edited, save the file.
8. Using APKTool or smali, recompile framework.jar
9. Using adb or a flashable zip, push the file back to your device

adb remount

adb push <path to newly compiled framework.jar file> /system/framework/framework.jar

adb shell chmod 644 /system/framework/framework.

adb reboot recovery

10. Once in recovery, wipe dalvik cache and cache.

11. Reboot and test :)






I have a zip attached for those who wish to use a zip.

Just OPEN the zip using 7zip, you will see two folders (META-INF, system) open system folder, open framework folder, and place your newly compiled file in there. Put the zip to your device, and flash in recovery.


ROM devs, feel free to use this! Just give credit :) Thanks

Guys dont hesitate to hit that thanks button! Can even donate to me as well :) Thanks everyone!
Attached Files
File Type: zip ZipFlasher.zip - [Click for QR Code] (216.9 KB, 155 views)
The Following 19 Users Say Thank You to elesbb For This Useful Post: [ Click to Expand ]
 
hello_world.c
Old
#2  
Member
Thanks Meter 4
Posts: 32
Join Date: Jun 2011
Default First method doesn't work

With the modified framework-res.apk per your instructions, the device hangs at the "X" animation. I push the original, everything works again.

This is how the process looks like:

>apktool d -f framework-res.apk tmp
I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...

Editing the xml file, extremely carefully with a hex editor, only changing the original value 7 to 20, then:

>apktool b tmp/ framework-res.apk
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...

When it didn't boot I compared the original and rebuilt apk, I noticed that the META-INF directory was missing, so I copied it over, into the .apk. Still no luck, device hangs at boot.

Nexus 4 with 4.2.2 stock, rooted, CWM.
 
elesbb
Old
#3  
elesbb's Avatar
Senior Member - OP
Thanks Meter 3859
Posts: 6,243
Join Date: Jun 2010

 
DONATE TO ME
Quote:
Originally Posted by hello_world.c View Post
With the modified framework-res.apk per your instructions, the device hangs at the "X" animation. I push the original, everything works again.

This is how the process looks like:

>apktool d -f framework-res.apk tmp
I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...

Editing the xml file, extremely carefully with a hex editor, only changing the original value 7 to 20, then:

>apktool b tmp/ framework-res.apk
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...

When it didn't boot I compared the original and rebuilt apk, I noticed that the META-INF directory was missing, so I copied it over, into the .apk. Still no luck, device hangs at boot.

Nexus 4 with 4.2.2 stock, rooted, CWM.
I have this problem time to time. Its prolly a compressed resources.arsc file. Do this.

Take newly compiled apk.
Open with 7zip.
Copy the resources.arsc to desktop.
Open ORIGINAL (make a copy so you still have original) delete the resources.arsc file.
Go to your desktop.
Copy resources.arsc file to the ORIGINAL.

Then push to device. Should work.

Sent from my ASUS Transformer Pad TF300T using Tapatalk 2
The Following User Says Thank You to elesbb For This Useful Post: [ Click to Expand ]
 
hello_world.c
Old
#4  
Member
Thanks Meter 4
Posts: 32
Join Date: Jun 2011
Worked this way and the safe levels warning seems to be gone. Thanks!!!
 
dwitherell
Old
#5  
dwitherell's Avatar
Recognized Contributor
Thanks Meter 6094
Posts: 3,445
Join Date: May 2011

 
DONATE TO ME
Howdy - nice work on this

Any way you could share the smali code of what pswitch_19 points to? Might be handy for people trying to figure out what exactly it is that should be removed if things don't appear quite the same here so they comment out the appropriate switch. Thanks!
If you like what I've done... I like sammiches so feel free to buy me one!
 
elesbb
Old
#6  
elesbb's Avatar
Senior Member - OP
Thanks Meter 3859
Posts: 6,243
Join Date: Jun 2010

 
DONATE TO ME
Quote:
Originally Posted by dwitherell View Post
Howdy - nice work on this

Any way you could share the smali code of what pswitch_19 points to? Might be handy for people trying to figure out what exactly it is that should be removed if things don't appear quite the same here so they comment out the appropriate switch. Thanks!
pswitch_19 points to the method that stops the volume from increasing as well as displaying that message. Its an $access1234523 number so its prolly different in each jar file. If people have issues i will be able to help them

They just need to post here
 
dwitherell
Old
#7  
dwitherell's Avatar
Recognized Contributor
Thanks Meter 6094
Posts: 3,445
Join Date: May 2011

 
DONATE TO ME
Quote:
Originally Posted by elesbb View Post
pswitch_19 points to the method that stops the volume from increasing as well as displaying that message. Its an $access1234523 number so its prolly different in each jar file. If people have issues i will be able to help them

They just need to post here
Gotcha - and no worries. Depending on what is used to decompile sometimes those access$### calls have a commented out bit right above them telling you what that static access function is doing/what is being called - but you are right people should just post if they need help. Thanks again for this
If you like what I've done... I like sammiches so feel free to buy me one!
 
cabloomi
Old
#8  
Account currently disabled
Thanks Meter 351
Posts: 220
Join Date: Feb 2012
Location: Iraq
didnt work for me on my S4 with android 4.2.2
 
elesbb
Old
#9  
elesbb's Avatar
Senior Member - OP
Thanks Meter 3859
Posts: 6,243
Join Date: Jun 2010

 
DONATE TO ME
Quote:
Originally Posted by cabloomi View Post
didnt work for me on my S4 with android 4.2.2
that is such a broad statement. if you want help youre gonna have to provide more info like which method you tried, is the ROM deodexed or odexed. etc etc

Sent from my ASUS Transformer Pad TF300T using Tapatalk 2
 
cabloomi
Old
(Last edited by cabloomi; 11th May 2013 at 01:24 PM.)
#10  
Account currently disabled
Thanks Meter 351
Posts: 220
Join Date: Feb 2012
Location: Iraq
---------- Post added at 12:51 PM ---------- Previous post was at 12:49 PM ----------

[/COLOR]
Quote:
Originally Posted by elesbb View Post
that is such a broad statement. if you want help youre gonna have to provide more info like which method you tried, is the ROM deodexed or odexed. etc etc

Sent from my ASUS Transformer Pad TF300T using Tapatalk 2
oh. so sorry. wasn't expecting a reply, im running deodexed and my files came up just like you said. i also had 2 "switch_19" and i put the # as you did
compile with no problem. replaced the the classes.dex files to the original one. so what now..
i still get that annoying message. do you think it in the android policy jar. becouse it can unlock the phone to show the notification
@elesbb

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes