Remove All Ads from XDA
Find Your Device:
Or Continue to Thread: Updated 4-3 Enhanced ICS Camer…
26th March 2012, 05:01 PM |#75  
KCRic's Avatar
OP Senior Member
Flag Overland Park
Thanks Meter: 270
How-To; Modifying the Camera.apk
Since I've learned from others writing how-to posts I feel I should give back to that want to learn. So here goes.

First, you can use Windows however, I had no luck with recompiling so I had to switch over to my Linux install. There are a few programs in Windows that help so I will post them.

By far the most useful program is in Windows. These operations can be done in Linux too, I just haven't set them up yet and don't know what programs can view .class files.

  1. Dex2jar - Unpack the program to your C drive (or somewhere else that's easy). Make a folder in the dex2jar directory and name it whatever you want, this is where you'll put you apk files. Use this command to run it.
    C:\dex2jar-<version>\dex2jar.bat C:\APK\NAMEOFAPK.apk
    C:\dex2jar-\dex2jar.bat C:\APK_folder\NAMEOFAPK.apk
    This will create a .jar file

  2. jd-gui - Just a standalone program. Unpack it anywhere and click on the application icon. Click on the folder icon in the upper left. Navigate to the .jar file you just created and open it. Now navigate to com>> and find the MedaiRecorderProfile.
Now you'll see this:
int[][] arrayOfInt = new int[7][];
int[] arrayOfInt1 = new int[10];
arrayOfInt1[0] = 2;
arrayOfInt1[1] = 17000000;
arrayOfInt1[2] = 15000000;
arrayOfInt1[3] = 13000000;
arrayOfInt1[4] = 30;
arrayOfInt1[5] = 2;
arrayOfInt1[6] = 3;
arrayOfInt1[7] = 128000;
arrayOfInt1[8] = 2;
arrayOfInt1[9] = 48000;
arrayOfInt[0] = arrayOfInt1;
These are basically the settings. At the top of the file you'll see this:
private static final int PROFILE_1280_720 = 1;
private static final int PROFILE_176_144 = 5;
private static final int PROFILE_1920_1080 = 0;
private static final int PROFILE_320_240 = 4;
private static final int PROFILE_640_480 = 3;
private static final int PROFILE_720_480 = 2;
private static final int PROFILE_MMS = 6;
private static final int PROPERTY_AUDIO_BITRATE = 7;
private static final int PROPERTY_AUDIO_ENCORDER = 6;
private static final int PROPERTY_AUDIO_NUM_CHANNELS = 8;
private static final int PROPERTY_AUDIO_SAMPLINGRATE = 9;
private static final int PROPERTY_VIDEO_BITRATE_FINE = 2;
private static final int PROPERTY_VIDEO_BITRATE_NORMAL = 3;
private static final int PROPERTY_VIDEO_BITRATE_SUPERFINE = 1;
private static final int PROPERTY_VIDEO_ENCORDER = 0;
private static final int PROPERTY_VIDEO_FRAME_RATE = 4;
private static final int PROPERTY_VIDEO_OUTPUT_FORMAT = 5;
The private static final int PROFILE are the numbering order of the arrays. These are offset by -1 so array 1 actually corresponds to PROFILE 0. The private static final int PROPERTY is the numbering order of the settings in each array. So for example arrayOfInt1[5] = 2 is the 1080p profile (0) and the property for the video output format (5).

Yes, it does say PROPERTY_VIDEO_ENCORDER. Not sure if the guys at Google screwed up or it's a joke but it's there - live with it. Just know it should say encoder.

Now you know what you're looking at. These .class files can't be edited however. This had led to many of devs being prescribed Prozac and Zoloft. There is hope, keep reading.

  1. Linux 64bit (I use Ubuntu 10.04) or wubi/VM setup in Windows
  2. dsixda's most current kitchen and a 'working' folder setup. See the thread in Chef Central.
  3. A text editor, notepad++ (Windows only), gedit, Kate, ...

1. Place the rom in the original_update folder then in the kitchen menu select 'create working folder'
2. Enter the option numbers 0, 24, 7 and select the camera.apk
3. Navigate to out/com/sec/android/app/camera and find MediaRecorderProfile.smali

At the bottom you'll see the arrays but they will look completely different.
This is the 1080p settings array.
.line 66
.array-data 0x4
0x2t 0x0t 0x0t 0x0t
0x40t 0x66t 0x3t 0x1t
0xc0t 0xe1t 0xe4t 0x0t
0x40t 0x5dt 0xc6t 0x0t
0x1et 0x0t 0x0t 0x0t
0x2t 0x0t 0x0t 0x0t
0x3t 0x0t 0x0t 0x0t
0x0t 0xeet 0x2t 0x0t
0x2t 0x0t 0x0t 0x0t
0x80t 0xbbt 0x0t 0x0t
.end array-data
The line order is still the same as before in the .class file - you just have to manually count (starting with 0). The settings are in hexadecimal little-endian format. That means the least significant bit comes first. For example: 0xbb80 would be 0x80bb. Now some of this is beyond my level of expertise as far as why they all end with a 't' and I can only assume that each 0x--t must equal 8 bits (one byte) that's why even in the case of 0x80bb you will still need 4 spots filled (0x80t 0xbbt 0x0t 0x0t). Certain numbers can even have the '0' dropped like 00 or 01, even 10. They become 0x0t or 0x1t. This is how I explain it to myself since I can't find any documentation on it so I had to figure it out on my own. Is the reasoning wrong? Probably. Does it work? Absolutely.

4. So change what you want then recompile (just press enter in terminal). Congratulations, you've just moded the camera app!

Now lets see what all the numbers mean. At the bottom I've attached a cheat sheet for the hex values and some other stuff. You're free to use it but if you really want to learn, just use it to check your work or not at all (I don't suggest the last one until you really know what you're doing). For some settings you'll have to use it as a reference. Unless of course you have this undying urge to rummage through source code.
Attached Files
File Type: txt Cheat Sheet.txt - [Click for QR Code] (2.2 KB, 41 views)
Last edited by KCRic; 11th February 2013 at 06:01 PM.
The Following User Says Thank You to KCRic For This Useful Post: [ View ] Gift KCRic Ad-Free