Search This Blog

something

[Mod] Change the number of volume steps in Android

The pic on the right is our target
Well, this article has took more time to get ready to be published than any of the 100 odd articles I have written. Let me present to you the easiest ever guide to change the number of volume steps. Why would one want to change the number of volume steps? Just for the sake of modification, one may say. Or as I heard from someone else, to get more control on the amount of Sound quantity you want to flow out of your phone. For example, in case your headphones are pretty loud in the indoors even at the lowest possible volume, say 1 out of the 15 available steps, then increasing the number of steps to 30 and then decreasing the volume to 1 out of 30 will give you half as louder sound as you previously got. This trick can't increase the loudness of your phone by any means.
P.S. Let me explain the last statmenet in a more elaborate way! Minimum loudness = (Minimum Possible Volume)/(Maximum Possible Volume) If we change our volume steps from, say 10 to 20 (for the sake of easy calculations). Old Minimum Loudness = 1/10 = 0.10 New Minimum Loudness = 1/20 = 0.05 Similarly Old Maximum Loudness = 10/10 = 1 New Maximum Loudness = 20/20= 1 I guess now you won't ask me why it doesn't increase the maximum loudness.
Click to Zoom.
For even better
 quality,
download pictorial
 guide from the
 pre- requisites
 section.
  This guide holds a quite special place:
  • As many as 25 snapshots are used in this guide, to give you a more easier approach and to add the sense that you're going good!
  • For the first time, I'm sharing a C program I myself wrote, with the world!
  • It took me more than 6 hours to complete this guide, uff, am I tired?

Prerequisites:

Hardware Stuff that's required:

  • A rooted Android mobile/Tablet
  • A windows computer
  • USB Cable for file transfer (or any other means to transfer files to and from your Android mobile)
Software Stuff that has to be downloaded:

Guide to change number of volume steps:

  • Download and extract the BaksmaliManager in any folder.
  • Run the baksmali manager.bat file. (As in pic #1)
  • Ignore any errors that appear in the command prompt that opens. (Pic #2) The error basically occurs because it couldn't detect adb on your PC. As we are not going to need it, so we don't have bother about this error.
  • Now, using Root Explorer or any other file manager with root access, browse to the folder at /system/framework and copy the file named framework.jar from there (pic #3). Copy that file to the baksmalimanager folder (pic #4).
  • In the command prompt windows you opened in step 2, press 4to select the option named "Select file to work" as shown in pic #5.
  • Now all the .jar files present in the baksmalimanager folder will be listed (except smali.jar and baksmali.jar). As we have a single .jar file at that location, select the option adjacent to that file. Enter 2 to select framework.jar (pic #6), and then press 1 to baksmali that jar file (pic #7,8). Don't close the command window after the process completes, we are going to need it again.
  • When the process completes, a new folder named "framework" will be created in the baksmalimanager folder. (pic #9)
  • Open that folder and browse to /framework/android/media (pic #10) and you will find large number of files waiting for you. Find the file named AudioService.smali and open it using any text editor, I used Notepad++, the link for which is already shared in the prerequisites section.
  • In the text editor window, press Ctrl+F to open the find window, and search for 0x7t or 0xft. (Either will work, you just need to find the bunch of lines with something like "0x*t" (where * may be anything) as in pic no. 11)
  • Look carefully at the numbers which are surrounded by the black rectangle in pic #12. It hold a the tricks. Every line is responsible for the number of volume steps for a particular type of sound, which is shown in ,again, pic #12.
  • In the numbers 0x5t,0x7t and so on, we have to edit the part that's just after the 0x part and just before the ending. For example, in the number 0x5t, we have to change 5 and in the number 0x 7t, we have to change 7.
  • Now, the question is, what value do we have to change them to? The numbers are in hexadecimal format, and unless you are an engineering student, chances are you don't know how to convert a number from decimal (the number system we use in day to day life) to hexadecimal. To help you with that, I developed a small program to convert the values for you. Download that program from the prerequisites section and follow instructions to convert any desired number. (pic 14)
  • Say you want to have 25 volume steps in Media volume. To do this, convert 25 to hexadecimal using the c program I linked above, which equates it to 19 in hexadecimal (pic #14). So, we change the value in line 4, which is responsible for media volume, to 0x19t from the previous 0xft which meant 15 steps (pic #15). Similarly, you can change the steps for other types of volumes.
  • Save the file from the text editor you are using.
  • In the baksmalimanager command window, press 1 to smali the framework folder (pic #16). In case you had closed the command window after using baksmali, run it again, and press 4 and 2 to select the file again and finally press 1 to smali the folder.
  • When the smali process finishes (pic #17), a file called classes.dex will be created in the baksmalimanager folder. (pic #18)
  • Open the framework.jar file using "Open Archive with" option in 7-Zip when you right click on the file. Refer pic no. 18 to get more clear on this.
  • Drag and drop the classes.dex file from the baksmalimanagerfolder to the zip you have opened using 7-Zip, and close the 7-Zip window. (pic #19)
  • Copy the new framework.jar file to your mobile's sdcard  (pic#20) and finally to /system/framework (pic #21). A warning might appear asking whether you want to overwrite exisiting file. Select yes. (pic #22)
  • Long click on the file and select the option "Permissions" (pic #23) and set them as rw-r--r--, as shown in pic no. 24. Reboot your device.
  • Take a few deep breaths, you have done it successfully.
This mod can be equally useful for users as well as ROM Developers. Were you able to go through all this. I hope the pictorial guide made it easier for you. Waiting for feedback from you guys! Leave your comments below. Share it with your geeky friends, and don't forget to follow me to grab the latest updates at the earliest.