FORUMS
Remove All Ads from XDA

[MOD][REF] Froyo Camera.apk Power Button->Shutter Key; Disable Low Batt

664 posts
Thanks Meter: 288
 
By GizmoDroid, Senior Member on 10th February 2011, 10:31 PM
Post Reply Email Thread
Current Functionality over stock Camera.apk:
  • Optional Geotagging (thanks to Adrynalyne or whoever he got it from)
  • Power Button in Camera mode becomes functionally the same as the touchscreen Shutter Key
  • Power Button in Camcorder mode becomes functionally the same as the touchscreen Shutter Key for starting recording
  • Removed Low Battery restriction
  • Removed In-Call restriction

This camera has been included with Super Clean since v2.2 until v2.9, and is included in some other ROMs as well. If you installed any of these roms, then you do not need to install this camera.
Froyo Camera Mod v2.1 - APK version

Camera.apk - Download @ MediaFire.com



Installation: Since this is a system app, it cannot be installed using the Package Installer. Camera.apk must replace /system/app/Camera.apk. You can accomplish this many different ways. Two common methods are: 1) use ADB to push it ("adb push Camera.apk /system/app/Camera.apk"); or 2) copy Camera.apk to your SD card, then use a program like Root Explorer to move it to "/system/app/". If you are running a Stock Froyo rom, you will want to delete any camera.odex files in /system/app/, clear dalvik cache and reboot. For most deodexed roms, a reboot is only necessary if the camera is not working correctly after installation.
Thanks to s44, there is now a CWM flashable upgrade version:

Froyo Camera Mod v2.1 - ClockworkMod ZIP version

cameramodv2.1-install.zip - Download @ xdaDevelopers.com



Quote:
Originally Posted by s44

The attached Clockwork zip *should* do all the above (delete the odex if it exists, clear the Camera's dalvik cache entry, and install the Camera apk into /system/app)

Installation: Copy zip file to sdcard. Boot into CWM, and select "Install zip from sd card". Select the file, then confirm the flash. When finished, reboot.
Disclaimer: This should work on any of the Froyo roms/kernels, but maybe not your's. Be sure to make a backup of your current Camera.apk for easily switching it back if you have problems.

Feedback: If it doesn't work right, let me know your setup, and what the problem is. If you see an error in my description, or if you know of a better way to do something, let me know. It's my goal to both be as unobtrusive to the original code as possible, while increasing functionality/efficiency. I am *slightly* open to suggestions on future features (I can't promise much since I'm in school and don't have too much time).

Future Features/Fixes:
  • In camcorder mode, Power Button second press->Pause Key
  • Optimize PNG's

User Requested Features/Reported Bugs:
  • On long press of the Power Button, Enable Auto Focus before taking picture (i.e. disable the Power Menu from popping up).
  • Home Key short press does not follow OS setting after using the Power Button to take a picture (happens after every odd # of Power Button presses)

Previous Versions
Camera Mod v1
Camera.apk - Download @ MediaFire.com



Changelog
  • v2.1
    -Added "Unable to start camera while in a call" Alert Disable
    -Added Remap Power Button to Shutter Key for Camcorder (start only)
  • v2
    -Corrupted Upload... Sorry!
  • v1
    -Initial Release


Thanks:
-Adrynalyne for providing the deodexed, froyo Camera.apk with optional geotagging added.
-The author of that forum post I read that pointed me to the "camera.smali" file. I'm sorry, I have no idea who you are.
-Whoever wrote this Dalvik VM cheatsheet
-S44 for putting together the CWM flash file



Process - How I Made It

I extracted the Camera.apk from SuperClean 2.0. From there, I extracted "classes.dex" using 7-zip. Then, I decompiled "classes.dex" using baksmali. I edited the Dalvik bytecode in the Camera.smali and AbstractCameraActivity.smali files using Notepad++. I recompiled "classses.dex" using smali. I overwrote the "classes.dex" in the Camera.apk using 7-zip. Finally, I zipaligned the resulting APK.

I did not mod the camcorder files (v2.1 - I have half of the camcorder part done), but the process would be similar. Also, if you understand the general rules of bytecode, you could adapt this to other versions of the APK fairly quickly.

The commands I used for decompiling and recompiling are as follows:
java -jar baksmali-1.2.1.jar -x classes.dex
java -Xmx512m -jar smali-1.2.1.jar -o classes.dex c:\out

Remap Power Button to Shutter Key for Camera

In com\sec\android\app\camera\Camera.smali, the red lines are the ones I modified:

Code:
    .line 728
    :cond_45
    const/16 v1, 0x1a

    goto :cond_52

    .line 729
    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->isCaptureEnabled()Z
Code:
    .line 736
    :sswitch_data_fc
    .sparse-switch
        0x4 -> :sswitch_61
        0x17 -> :sswitch_69
        0x18 -> :sswitch_b7
        0x19 -> :sswitch_b7
        0x1a -> :sswitch_69
        0x1b -> :sswitch_69
        0x42 -> :sswitch_69
        0x50 -> :sswitch_63
        0x52 -> :sswitch_61
        0x54 -> :sswitch_61
    .end sparse-switch
.end method
Code:
    .line 828
    :cond_3a
    const/16 v0, 0x1a

    goto :cond_57

    .line 830
    invoke-direct {p0}, Lcom/sec/android/app/camera/Camera;->resetFocusDueToZoom()V
Code:
    .line 848
    nop

    :sswitch_data_e8
    .sparse-switch
        0x4 -> :sswitch_83
        0x17 -> :sswitch_b5
        0x18 -> :sswitch_e4
        0x19 -> :sswitch_e4
	0x1a -> :sswitch_b5
        0x1b -> :sswitch_b5
        0x42 -> :sswitch_b5
        0x52 -> :sswitch_b2
        0x54 -> :sswitch_e4
    .end sparse-switch
.end method
There you have it. You only have to modify 4 lines, and now your power button should perfectly emulate the shutter key on the screen.


Low Battery Alert Disable

In com\sec\android\app\camera\AbstractCameraActivity. smali, add the red line:

Code:
    .line 855
    :cond_14
    invoke-virtual {p0}, Lcom/sec/android/app/camera/AbstractCameraActivity;->hideAllDlg()V

    goto :goto_13

    .line 857
    new-instance v0, Landroid/app/AlertDialog$Builder;

"Unable to start camera while in a call" Alert Disable - Added in v2.1

In com\sec\android\app\camera\AbstractCameraActivity. smali, add the red line:

Code:
    .line 613
    const/4 v2, 0x0
	
    goto :goto_1a

    iput-boolean v2, p0, Lcom/sec/android/app/camera/AbstractCameraActivity;->mCheckCalling:Z
The Following 23 Users Say Thank You to GizmoDroid For This Useful Post: [ View ] Gift GizmoDroid Ad-Free
 
 
11th February 2011, 12:28 AM |#2  
Senior Member
Thanks Meter: 191
 
More
Excellent!

I don't suppose you could further edit the camera to disable Geotagging?
11th February 2011, 12:31 AM |#3  
GizmoDroid's Avatar
OP Senior Member
Thanks Meter: 288
 
Donate to Me
More
Quote:
Originally Posted by s44

Excellent!

I don't suppose you could further edit the camera to disable Geotagging?

It's not enabled by default. It's just an option in the menu.
11th February 2011, 12:34 AM |#4  
Senior Member
Thanks Meter: 12
 
More
I really needed this, great work! I hope devs start including this standard in future ROMs.
11th February 2011, 12:58 AM |#5  
GoogleAndroid's Avatar
Senior Member
Thanks Meter: 23
 
More
Amazing job. I've been waiting for something like this.
11th February 2011, 01:25 AM |#6  
Member
Flag north florida
Thanks Meter: 1
 
More
I'm almost. As excited about this as I am froyo.

Sent from my SCH-I500 using XDA App
11th February 2011, 02:35 AM |#7  
tmlhodge's Avatar
Senior Member
Flag Eastern Time Zone
Thanks Meter: 492
 
Donate to Me
More
Wow this is really cool and is flawlessly working.. You da man

Sent from my SCH-I500 using XDA App
11th February 2011, 02:57 AM |#8  
Senior Member
Thanks Meter: 12
 
More
yuuup you the MAN
any chance there's a way to remap the search button to bring up the camera?
I currently use the power remap mod and it's pretty useful but having a quick camera button would be awesome
11th February 2011, 03:36 AM |#9  
thatdudebutch's Avatar
Inactive Recognized Developer
Flag Raleigh, NC
Thanks Meter: 1,855
 
Donate to Me
More
Quote:
Originally Posted by djlim4

yuuup you the MAN
any chance there's a way to remap the search button to bring up the camera?
I currently use the power remap mod and it's pretty useful but having a quick camera button would be awesome

I have done this mod, just search forum
11th February 2011, 03:57 AM |#10  
Junior Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by thatdudebutch

I have done this mod, just search forum

I can't seem to get this to install. Any help would be greatly appreciated.
11th February 2011, 04:08 AM |#11  
exnihilo's Avatar
Member
Thanks Meter: 1
 
More
I don't know what's cooler, the fact that you hacked this up and released it, or that you released a detailed HOW-TO on the process.

Oh wait, it's definitely the HOW-TO. That's going the extra-mile for sure, and helping the community grow.

You're awesome!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes