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

Search This thread

GizmoDroid

Senior Member
May 14, 2010
664
286
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.

[Size=+1]Froyo Camera Mod v2.1 - APK version[/Size]

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:

[Size=+1]Froyo Camera Mod v2.1 - ClockworkMod ZIP version[/Size]

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



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
[Size=-1]Camera Mod v1
Camera.apk - Download @ MediaFire.com

[/size]

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



[SIZE=+1]Process - How I Made It[/SIZE]

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

    [COLOR="red"]goto :cond_52[/COLOR]

    .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
       [COLOR="red"] 0x1a -> :sswitch_69[/COLOR]
        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

    [COLOR="red"]goto :cond_57[/COLOR]

    .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
	[COLOR="red"]0x1a -> :sswitch_b5[/COLOR]
        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

    [COLOR="Red"]goto :goto_13[/COLOR]

    .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
	
    [COLOR="Red"]goto :goto_1a[/COLOR]

    iput-boolean v2, p0, Lcom/sec/android/app/camera/AbstractCameraActivity;->mCheckCalling:Z
 
Last edited:

s44

Senior Member
Sep 25, 2010
1,142
191
Excellent!

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

renf

Senior Member
Dec 27, 2010
134
12
I really needed this, great work! I hope devs start including this standard in future ROMs.
 
Last edited:

djlim4

Senior Member
Jan 13, 2011
143
12
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
 

exnihilo

Senior Member
Oct 7, 2010
64
1
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!
 

jvincent08

Senior Member
Nov 9, 2010
86
4
Doesn't install for me. I select the apk, says it's a system app and do I want to replace, click yes, install, then it says "Installing.." for a few seconds before jumping to "Application not installed." No other errors. Any ideas?
 
Last edited:

s44

Senior Member
Sep 25, 2010
1,142
191
You don't install system apps, you drop them into /system/app with adb or Root Explorer. Don't forget to delete Camera.odex if you're running stock, and clear Dalvik after no matter what.

edit -- 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)

edit2 -- attached zip now has v2 of the mod
edit2.1 -- attached zip now has uncorrupted v2.1 of the mod
 

Attachments

  • cameramodv2.1-install.zip
    1.9 MB · Views: 5,022
Last edited:

ChrisDDD

Senior Member
Sep 26, 2010
493
147
Wow, nice job!

I would be *very* interested if you could point me in any direction that might help understand how you knew what lines to change, and what to change them to.

I'm trying to modify a few apks, and I've been digging through all the smali files, but I can't seem to find anything that makes any sense. I see a lot of things that might be what I need to change, but it's not obvious enough to know for sure if, or how, to change it.
 

jvincent08

Senior Member
Nov 9, 2010
86
4
You don't install system apps, you drop them into /system/app with adb or Root Explorer. Don't forget to delete Camera.odex if you're running stock, and clear Dalvik after no matter what.

edit -- 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)

Thanks. Putting it in /system/app worked.
 

Joshuaboyzn

Senior Member
Dec 27, 2010
101
15
I'm getting FC with v2

Edit: I tried both the .zip and manually replacing the apk

Sent from my SCH-I500 using XDA App
 

GizmoDroid

Senior Member
May 14, 2010
664
286
Will you try installing s44's zip file through CWM?

-deleted because my v2 upload was corrupted-
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 23
    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.

    [Size=+1]Froyo Camera Mod v2.1 - APK version[/Size]

    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:

    [Size=+1]Froyo Camera Mod v2.1 - ClockworkMod ZIP version[/Size]

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



    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
    [Size=-1]Camera Mod v1
    Camera.apk - Download @ MediaFire.com

    [/size]

    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



    [SIZE=+1]Process - How I Made It[/SIZE]

    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
    
        [COLOR="red"]goto :cond_52[/COLOR]
    
        .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
           [COLOR="red"] 0x1a -> :sswitch_69[/COLOR]
            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
    
        [COLOR="red"]goto :cond_57[/COLOR]
    
        .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
    	[COLOR="red"]0x1a -> :sswitch_b5[/COLOR]
            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
    
        [COLOR="Red"]goto :goto_13[/COLOR]
    
        .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
    	
        [COLOR="Red"]goto :goto_1a[/COLOR]
    
        iput-boolean v2, p0, Lcom/sec/android/app/camera/AbstractCameraActivity;->mCheckCalling:Z
    1
    Thanks for this hacked camera! I was looking for the ability to disable geotagging. One question, though. Where is the icon for the app located? I can't seem to find it within the apk and I want to switch it out for something else.

    The icon is found at:
    Camera.apk\res\drawable-hdpi\tw30_icon_camera.png