Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,743,029 Members 42,402 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE][CAM] How To Hack SONY Xperia Camera (Bring Higher Bitrate & More Options)

Tip us?
 
Rizal Lovins
Old
(Last edited by Rizal Lovins; 15th April 2014 at 06:00 AM.)
#1  
Rizal Lovins's Avatar
Recognized Developer / Recognized Themer / Recognized Contributor - OP
Thanks Meter 14547
Posts: 1,441
Join Date: May 2012
Location: Bandung - Sauron The Great Eye
Default [GUIDE][CAM] How To Hack SONY Xperia Camera (Bring Higher Bitrate & More Options)

Hello Xperia friends....

from the beginning until now SONY give us bad software camera compared to others OEM


I want to show you how to hack All Xperia Camera

Requirement :

Knowladge in decompile/recompile apps


Hacking Audio Bitrate Video Recording
INFO for smali code

Value 0
Name: LowRate
Type: REG_DWORD
Data: 0x1f400 (SONY use this low bitrate so find this code to replace in the next step)

Value 1
Name: MediumRate
Type: REG_DWORD
Data: 0x2ee00

Value 2
Name: MediumHighRate
Type: REG_DWORD
Data: 0x3e800 (i'm use this code)

Value 3
Name: HighRate
Type: REG_DWORD
Data: 0x4e200
1. Decompile SemcCameraUI.apk
2. Go to smali/com/sonyericsson/android/camera

open Constants.smali using text editor/notepad++ then find this line
Code:
Select Code
.field public static final VIDEO_AUDIO_BIT_RATE:I = 0x1f400
change RED Color code to code from INFO CODE, example :
Code:
Select Code
.field public static final VIDEO_AUDIO_BIT_RATE:I = 0x3e800
save it!!!!

3. Go to smali/com/sonyericsson/android/camera/configuration/parameters

open VideoSize$VideoProfile$Builder.smali ( if there smali available, i mean different Xperia have diffierent parameters like older Xperia 2011)

search this code
Code:
Select Code
0x1f400
then change to
Code:
Select Code
0x3e800
save it!!!

4. Go to smali/com/sonyericsson/android/camera/configuration/parameters

open VideoSize.smali

search all this code
Code:
Select Code
0x1f400
then change all code to
Code:
Select Code
0x3e800
save it!!! Done


LAG ON VIDEO RECORDING ON XPERIA 2011 & XPERIA 2012 (Snapdragon S3/Novathor)???

Here is solution change FORMAT H264 to MPEG4!!!
INFO H264 VS MPEG4
http://www.y-cam.com/blog/mpeg4-vs-h-264-45/

Smali code

H263 is
Code:
Select Code
0x1
H264 is
Code:
Select Code
0x2
MPEG4 is
Code:
Select Code
0x3
1. Go to smali/com/sonyericsson/android/camera/configuration/parameters

open VideoSize.smali using text editor/notepad++ then find this line

(Note the Local maybe different)
Code:
Select Code
.local v7, "videoFrameRate":I
const/4 v6, 0x2
change to

Code:
Select Code
.local v7, "videoFrameRate":I
const/4 v6, 0x3
Save it!!! Done

Ash nazg durbatulūk, ash nazg gimbatul, ash nazg thrakatulūk agh burzum-ishi krimpatul.
One ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them.

Closer to me? everything about me and my work!!!
DON'T PM me for any question regarding my work, please post in specific thread, anyone can help you, I WON'T respond
Lead Developer of LOVINS DEV : The 2 Brothers - Rizal Lovins & ibanez7
The Following 59 Users Say Thank You to Rizal Lovins For This Useful Post: [ Click to Expand ]
 
Rizal Lovins
Old
(Last edited by Rizal Lovins; 15th April 2014 at 05:59 AM.)
#2  
Rizal Lovins's Avatar
Recognized Developer / Recognized Themer / Recognized Contributor - OP
Thanks Meter 14547
Posts: 1,441
Join Date: May 2012
Location: Bandung - Sauron The Great Eye
Hacking Video Recording Bitrate

INFO for smali code
Value 1
Name: MediumRate
Data: 0xb71b00

Value 2
Name: MediumHighRate
Data: 0x10b0760

Value 3
Name: HighRate
Data: 0x1c9c380

1. Go to smali/com/sonyericsson/android/camera

open Constants.smali using text editor/notepad++ then find this line

For HD 720p
Code:
Select Code
.field public static final VIDEO_BIT_RATE_EX_HIGH_12M:I = 0xb71b00
change to
Code:
Select Code
.field public static final VIDEO_BIT_RATE_EX_HIGH_12M:I = 0x10b0760
For FULL HD 1080p
Code:
Select Code
.field public static final VIDEO_BIT_RATE_EX_HIGH_17_5M:I = 0x10b0760
change to
Code:
Select Code
.field public static final VIDEO_BIT_RATE_EX_HIGH_17_5M:I = 0x1c9c380
save it!!!

2. Go to smali/com/sonyericsson/android/camera/configuration/parameters

open VideoSize.smali the find this line

For HD 720p
Code:
Select Code
0xb71b00
change to
Code:
Select Code
0x10b0760
For FULL HD 1080p
Code:
Select Code
0x10b0760
change that all code to
Code:
Select Code
0x1c9c380
save it!!! Done

NOW AFTER EDITING VIDEO AUDIO BITRATE & VIDEO BITRATE YOU NEED TO EDIT media_profile.xml

open media_profile.xml using text editor/notepad++ thenfind this line

FIX 100% Image Quality
Code:
Select Code
<!ATTLIST ImageEncoding quality (90|80|70|60|50|40) #REQUIRED>
change to
Code:
Select Code
<!ATTLIST ImageEncoding quality (100|90|80|70|60|50) #REQUIRED>
There is 2 lines code for back camera & front camera

Code:
Select Code
<ImageEncoding quality="95" />
<ImageEncoding quality="80" />
<ImageEncoding quality="70" />
change all code to
Code:
Select Code
<ImageEncoding quality="100" />
<ImageEncoding quality="90" />
<ImageEncoding quality="80" />

Adjust the value of smali Video & Audio Video bitrate with media-profile.xml (as you modified it)

There is many lines code for Video you need to change them all, example

Code:
Select Code
        <EncoderProfile quality="1080p" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="17500000"
                   width="1920"
                   height="1080"
                   frameRate="30" />

            <Audio codec="aac"
                   bitRate="156000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>

        <EncoderProfile quality="720p" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="12000000"
                   width="1280"
                   height="720"
                   frameRate="30" />

            <Audio codec="aac"
                   bitRate="156000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>
change to

Code:
Select Code
        <EncoderProfile quality="1080p" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="20000000"
                   width="1920"
                   height="1080"
                   frameRate="30" />

            <Audio codec="aac"
                   bitRate="256000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>

        <EncoderProfile quality="720p" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="1750000"
                   width="1280"
                   height="720"
                   frameRate="30" />

            <Audio codec="aac"
                   bitRate="256000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>
Code:
Select Code
    <VideoEncoderCap name="h264" enabled="true"
        minBitRate="64000" maxBitRate="20000000"
        minFrameWidth="176" maxFrameWidth="1920"
        minFrameHeight="144" maxFrameHeight="1080"
        minFrameRate="15" maxFrameRate="30" />
Code:
Select Code
    <AudioEncoderCap name="aac" enabled="true"
        minBitRate="8000" maxBitRate="256000"
        minSampleRate="8000" maxSampleRate="48000"
        minChannels="1" maxChannels="2" />
Note maxChannels Number in RED Color, can be 6 or 2

Ash nazg durbatulūk, ash nazg gimbatul, ash nazg thrakatulūk agh burzum-ishi krimpatul.
One ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them.

Closer to me? everything about me and my work!!!
DON'T PM me for any question regarding my work, please post in specific thread, anyone can help you, I WON'T respond
Lead Developer of LOVINS DEV : The 2 Brothers - Rizal Lovins & ibanez7
The Following 27 Users Say Thank You to Rizal Lovins For This Useful Post: [ Click to Expand ]
 
Rizal Lovins
Old
(Last edited by Rizal Lovins; 15th April 2014 at 05:20 AM.)
#3  
Rizal Lovins's Avatar
Recognized Developer / Recognized Themer / Recognized Contributor - OP
Thanks Meter 14547
Posts: 1,441
Join Date: May 2012
Location: Bandung - Sauron The Great Eye
EXperimental hacking, Change format RGB_565 to ARGB8888

I use ONLY on Xperia 2011

1. Go to smali/com/sonyericsson/android/camera

open CameraActivity.smali using text editor/notepad++ then find this line

Code:
Select Code
sget-object v12, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;
Code:
Select Code
sget-object v0, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;
Change RED Color code to

Code:
Select Code
ARGB_8888
2. Go to smali/com/sonyericsson/android/camera

open ImageManager.smali then search for RGB example :
Code:
Select Code
sget-object v0, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;
change all code to
Code:
Select Code
sget-object v0, Landroid/graphics/Bitmap$Config;->ARGB_8888:Landroid/graphics/Bitmap$Config;
3. Go to smali/com/sonyericsson/android/camera/device

open CameraExtensionValues.smali then search for RGB example :
Code:
Select Code
.field public static final POSTVIEW_FORMAT_RGB565:Ljava/lang/String; = "rgb565"
change to

Code:
Select Code
.field public static final POSTVIEW_FORMAT_RGB565:Ljava/lang/String; = "argb8888"
save it!!!

Enable inPreferQualityOverSpeed (I Use ONLY on Xperia 2011)

1. Go to smali/com/sonyericsson/android/camera

open CameraActivity.smali

Code:
Select Code
.local v11, opt:Landroid/graphics/BitmapFactory$Options;
sget-object v15, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;

iput-boolean v6, v11, Landroid/graphics/BitmapFactory$Options;->inPreferQualityOverSpeed:Z

iput-object v15, v11, Landroid/graphics/BitmapFactory$Options;->inPreferredConfig:Landroid/graphics/Bitmap$Config;
Look for RED Color it's should be like this
Code:
Select Code

.local v11, opt:Landroid/graphics/BitmapFactory$Options;
const/4 v6, 0x1
iput-boolean v6, v11, Landroid/graphics/BitmapFactory$Options;->inPreferQualityOverSpeed:Z

iput-boolean v6, v11, Landroid/graphics/BitmapFactory$Options;->inDither:Z

sget-object v15, Landroid/graphics/Bitmap$Config;->ARGB_8888:Landroid/graphics/Bitmap$Config;

iput-object v15, v11, Landroid/graphics/BitmapFactory$Options;->inPreferredConfig:Landroid/graphics/Bitmap$Config;

Ash nazg durbatulūk, ash nazg gimbatul, ash nazg thrakatulūk agh burzum-ishi krimpatul.
One ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them.

Closer to me? everything about me and my work!!!
DON'T PM me for any question regarding my work, please post in specific thread, anyone can help you, I WON'T respond
Lead Developer of LOVINS DEV : The 2 Brothers - Rizal Lovins & ibanez7
The Following 24 Users Say Thank You to Rizal Lovins For This Useful Post: [ Click to Expand ]
 
Rizal Lovins
Old
(Last edited by Rizal Lovins; 15th April 2014 at 04:35 AM.)
#4  
Rizal Lovins's Avatar
Recognized Developer / Recognized Themer / Recognized Contributor - OP
Thanks Meter 14547
Posts: 1,441
Join Date: May 2012
Location: Bandung - Sauron The Great Eye
Hacking Camera Resolution/MP (More Options)

More Options for Photo (Only work for Xperia 2011 & 2012 Snapdragon S3/Novathor)

For Xperia 2012 Snapdragon S4 and 2013/2014 doesn't work, need to be removing some code in smali, i'm still looking for it

1. Go to res/value

open arrays.xml using text editor/notepad++ then find this line

For 12MP Camera
Code:
Select Code
<string-array name="ux_recommended_resolution_array_main_12m">
     <item>TWELVE_MP</item>
     <item>NINE_MP</item>
     <item>TWO_MP</item>
     <item>TWO_MP_WIDE</item>
add others line
Code:
Select Code
<string-array name="ux_recommended_resolution_array_main_12m">
        <item>TWELVE_MP</item>
        <item>NINE_MP</item>
	<item>EIGHT_MP</item>
	<item>FIVE_MP</item>
	<item>THREE_MP_WIDE</item>
        <item>TWO_MP</item>
        <item>TWO_MP_WIDE</item>
For 8MP Camera
Code:
Select Code
<string-array name="ux_recommended_resolution_array_main_8m">
     <item>EIGHT_MP</item>
     <item>SIX_MP</item>
     <item>TWO_MP</item>
     <item>TWO_MP_WIDE</item>
add others line
Code:
Select Code
<string-array name="ux_recommended_resolution_array_main_8m">
     <item>EIGHT_MP</item>
     <item>SIX_MP</item>
     <item>FIVE_MP</item>
     <item>THREE_MP</item>
     <item>TWO_MP</item>
     <item>TWO_MP_WIDE</item>

More Options for Video (Work for all Xperia)

1. Go to res/value

open arrays.xml using text editor/notepad++ then find this line

For 20MP Camera
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_20m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>MMS</item>
add others line
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_20m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 13MP Camera
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_13m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>MMS</item>
add others line
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_13m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 12MP Camera
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_12m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>MMS</item>
add others line
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_12m">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 8MP Camera FULL HD 1080p
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_8m_full_hd">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>MMS</item>
add others line
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_8m_full_hd">
     <item>FULL_HD</item>
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 8MP Camera HD 720p
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_8m_hd">
     <item>HD</item>
     <item>FWVGA</item>
     <item>QVGA</item>
     <item>MMS</item>
add others line
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_8m_hd">
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
For 5MP Camera HD 720p
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_5m_fwvga">
     <item>HD</item>
     <item>FWVGA</item>
     <item>QVGA</item>
     <item>MMS</item>
add others line
Code:
Select Code
<string-array name="ux_recommended_video_size_array_main_5m_fwvga">
     <item>HD</item>
     <item>FWVGA</item>
     <item>VGA</item>
     <item>QVGA</item>
     <item>MMS</item>
Save it!!!

Ash nazg durbatulūk, ash nazg gimbatul, ash nazg thrakatulūk agh burzum-ishi krimpatul.
One ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them.

Closer to me? everything about me and my work!!!
DON'T PM me for any question regarding my work, please post in specific thread, anyone can help you, I WON'T respond
Lead Developer of LOVINS DEV : The 2 Brothers - Rizal Lovins & ibanez7
The Following 27 Users Say Thank You to Rizal Lovins For This Useful Post: [ Click to Expand ]
 
Rizal Lovins
Old
(Last edited by Rizal Lovins; 15th April 2014 at 04:52 AM.)
#5  
Rizal Lovins's Avatar
Recognized Developer / Recognized Themer / Recognized Contributor - OP
Thanks Meter 14547
Posts: 1,441
Join Date: May 2012
Location: Bandung - Sauron The Great Eye
Enable 12MP Superior Auto on Jelly Bean 4.3

How to Install :

- Download the file in attachment
- Copy to system with root explorer etc
- Set permissions to 644 (rw-r--r--)
- Move the file to system>vendor>overlay
- Reboot
- After boot go to settings>apps>all
- Clear data Camera & try open camera app


NOTE : for some device need to rename the apk to android-res.apk and replace the original if is there

Enjoy


Credits :
Thanks to SONY Mobile that made all this possible
Thanks to my old friend @Xperia-Ray for helping me from beginning
Attached Files
File Type: apk com.sonyericsson.android.camera-res.apk - [Click for QR Code] (3.2 KB, 192 views)

Ash nazg durbatulūk, ash nazg gimbatul, ash nazg thrakatulūk agh burzum-ishi krimpatul.
One ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them.

Closer to me? everything about me and my work!!!
DON'T PM me for any question regarding my work, please post in specific thread, anyone can help you, I WON'T respond
Lead Developer of LOVINS DEV : The 2 Brothers - Rizal Lovins & ibanez7
The Following 21 Users Say Thank You to Rizal Lovins For This Useful Post: [ Click to Expand ]
 
poria1999
Old
#6  
poria1999's Avatar
Senior Member
Thanks Meter 427
Posts: 338
Join Date: Feb 2013
Location: Tehran
Nice guide man!
Will try it

Sent from my LT18i using Tapatalk 2
Experience The Awesomeness


The Following 2 Users Say Thank You to poria1999 For This Useful Post: [ Click to Expand ]
 
devilmaycry2020
Old
#7  
devilmaycry2020's Avatar
Senior Member
Thanks Meter 121
Posts: 756
Join Date: Apr 2013
Thanks,this guide change audio bitrate only,how about video bitrate?
Click the "Thanks" button if I've helped you
 
cuatzstress
Old
#8  
cuatzstress's Avatar
Senior Member
Thanks Meter 73
Posts: 148
Join Date: Sep 2012
Location: you tell me
Nuhun kang, I'll try ur guide, anyway how to change the photo quality? Is it same method?

Sent from my C1905 using XDA Premium 4 mobile app
 
xperiaz2
Old
#9  
xperiaz2's Avatar
Senior Member
Thanks Meter 3375
Posts: 402
Join Date: Oct 2013
Default wow

awesome guide bro very nice
The Following User Says Thank You to xperiaz2 For This Useful Post: [ Click to Expand ]
 
ramkrsn
Old
#10  
Senior Member
Thanks Meter 75
Posts: 216
Join Date: Oct 2010
Location: Mumbai
Thumbs up It WOKS..... :)

thank you it does work for decompile and recompile of the apk iused this tool


http://forum.xda-developers.com/show....php?t=2326604

awesome....

The Following User Says Thank You to ramkrsn For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes