[Camera] [Mod] Armani + power button focusing + video recording

aleadam

Senior Member
Feb 8, 2008
422
54
0
Albany, NY
Time for a big update to this post.

The andromeda roms have now a camera that not only uses the power button for taking stills, but also for video recording.

More interestingly, the power button in still images function now as the grey button on the display, i.e., one quick press takes a still as is, while a long press focuses until the key is released, and then takes the still.


The second mod required a change in android.policy.jar to prevent the power button long press to bring the power menu up. Thus, it will only work in the andromeda rom unless other rom developers decide to implement the change also.


You can find the diffs between the original armani camera app and this one attached here. For the actual app, please take a look at the andromeda page for the reason stated above.

I will explain the changes in posts below (20-23) so I don't clutter this one too much.
GlobalActions.smali is part of android.policy.jar, while the other three belong to the camera app.

BTW: This does not belong any more to Q&A. Dear Mods, would you please move the thread to a more suitable forum (apps or dev)?
 

Attachments

Last edited:

PhilipPeake

Member
Jan 1, 2011
41
4
0
If this helps in the search:

I installed dropbox, and noticed that dropbox now shows as one of the upload options. This suggests (to me) that there is a configuration file or database entry somewhere where this was added.

If we can find out where, there is a possibility of just removing the lockbox entry.

I doubt that its built into the app, they would want to sell this to different providers, and each will have (or not) its own version of the AT&T lockbox.

I did spend an hour or so this morning perusing databases, but didn't find anything.
 

aleadam

Senior Member
Feb 8, 2008
422
54
0
Albany, NY
If this helps in the search:

I installed dropbox, and noticed that dropbox now shows as one of the upload options. This suggests (to me) that there is a configuration file or database entry somewhere where this was added.

If we can find out where, there is a possibility of just removing the lockbox entry.

I doubt that its built into the app, they would want to sell this to different providers, and each will have (or not) its own version of the AT&T lockbox.

I did spend an hour or so this morning perusing databases, but didn't find anything.
Lol! I almost forgot about this thread already! So many roms now and I always saw that button that I learned to be careful :)

I just decompiled it and this is what I found:
Code:
$:~/android/apk_manager/out$ grep -i -r -n 'locker' *
res/values/strings.xml:271:    <string name="menu_qsend">Send to Online Locker</string>
smali/com/sec/android/app/camera/ReviewImage.smali:2346:.method public onSendToOnlineLocker()V
smali/com/sec/android/app/camera/ReviewImage$9.smali:57:    invoke-virtual {v0}, Lcom/sec/android/app/camera/ReviewImage;->onSendToOnlineLocker()V
$:~/android/apk_manager/out$ grep -i -r -n 'menu_qsend' *
res/values-it/strings.xml:261:    <string name="menu_qsend">Invia a Armadietto online</string>
res/values-de/strings.xml:261:    <string name="menu_qsend">Senden an Online-Schließfach</string>
res/values/public.xml:1563:    <public type="string" name="menu_qsend" id="0x7f07010c" />
res/values/strings.xml:271:    <string name="menu_qsend">Send to Online Locker</string>
res/values-fr/strings.xml:261:    <string name="menu_qsend">Envoyer à Casier en ligne</string>
res/values-es/strings.xml:261:    <string name="menu_qsend">Enviar a Bloqueo en línea</string>
res/values-ko/strings.xml:261:    <string name="menu_qsend">온라인 보관함으로 전송</string>
smali/com/sec/android/app/camera/R$string.smali:506:.field public static final menu_qsend:I = 0x7f07010c
I'll dig a little more into it
 

aleadam

Senior Member
Feb 8, 2008
422
54
0
Albany, NY
If this helps in the search:

I installed dropbox, and noticed that dropbox now shows as one of the upload options. This suggests (to me) that there is a configuration file or database entry somewhere where this was added.

If we can find out where, there is a possibility of just removing the lockbox entry.

I doubt that its built into the app, they would want to sell this to different providers, and each will have (or not) its own version of the AT&T lockbox.

I did spend an hour or so this morning perusing databases, but didn't find anything.
You made me look again into this :)

Check the first post :)
 

aleadam

Senior Member
Feb 8, 2008
422
54
0
Albany, NY
On JPY, the Video says "Camera Failed" and exits the app. Pictures work fine.

EDIT: The stock camera app is doing that too... so it's not a problem with this.
I don't think it's a jpy problem. I just tested on Doc's rom and the video works fine. On glitterballs kernel in case it's important.
 

aleadam

Senior Member
Feb 8, 2008
422
54
0
Albany, NY
So what makes this different from the other modded camera.apk?
I thought it was quite clear from the title :p

When reviewing the images, you don't have to click on more->delete to delete a picture. It's just there. More important, you don't have the option for at&t online locker above delete. Too many times I clicked on that (fat thumbs, maybe?) instead of the delete button.

It is just a minimal mod, for the few of us that hate the online locker. Nothing more.
 

MikeyMike01

Inactive Recognized Developer
Jul 23, 2010
6,494
2,450
0
The Camera app in JPY is (in some stupid way) reliant on the Email.apk, which I had removed.

Got that squared away, and now it's working.
 

vaiol123

Senior Member
Dec 1, 2010
150
2
0
Oh yeah what I meant was I am using an i9000 rom on a cappy and wanted to get rid of ffc references but it would just fc haha. I can live with it though
 

aleadam

Senior Member
Feb 8, 2008
422
54
0
Albany, NY
I'm getting FC's on the stock I-9000 froyo rom with Setiron's kernel after installing through cwm
Sorry I didn't check this thread in a while. With a stock i9000 rom I would try an i9000 camera.apk, like the one in the original thread from fr4gg0r

I can't say much without a logcat to know where is the error.
 

aleadam

Senior Member
Feb 8, 2008
422
54
0
Albany, NY
Diff explanations

Let's start with the camera:

Code:
diff -ru armani_Camera/Camera/smali/com/sec/android/app/camera/Camera.smali new_Camera/Camera/smali/com/sec/android/app/camera/Camera.smali
--- armani_Camera/Camera/smali/com/sec/android/app/camera/Camera.smali	2011-02-09 23:53:00.459447001 -0500
+++ new_Camera/Camera/smali/com/sec/android/app/camera/Camera.smali	2011-02-09 23:52:27.407447002 -0500
Nothing new in this part, just to make it keep working when the battery is very low
Code:
@@ -588,9 +588,6 @@
 
     if-eq v3, v8, :cond_0
 
-    .line 1665
-    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->handleLowBattery()V
-
     .line 1668
     :cond_0
     if-eq v1, v8, :cond_1
This is at the very beginning of the onKeyDown method and is the hack to fix the issue with the home button not responding after pressing the power button. As I said in the other thread, I don't think this is the real solution but it works well enough for now.
Code:
@@ -7641,6 +7638,42 @@
     .prologue
     const/4 v4, 0x1
 
+    const/16 v1, 0x3
+
+    if-ne p1, v1, :cond_0
+
+    new-instance v0, Landroid/content/Intent;
+
+    const-string v1, "android.intent.action.MAIN"
+
+    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
+
+    .local v0, startMain:Landroid/content/Intent;
+    const-string v1, "android.intent.category.HOME"
+
+    invoke-virtual {v0, v1}, Landroid/content/Intent;->addCategory(Ljava/lang/String;)Landroid/content/Intent;
+
+    const/high16 v1, 0x1000
+
+    invoke-virtual {v0, v1}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;
+
+    invoke-virtual {p0, v0}, Lcom/sec/android/app/camera/Camera;->startActivity(Landroid/content/Intent;)V
+
Now we're talking! This little piece here adds a new global setting, named "camera_in_use" that I made it be either 0 (not in use) or 1 (in use). As soon as the power key is pressed, this setting becomes 1. This is the int that will be read by android.policy.jar. We could use this idea to prevent android.policy.jar to respond to the power key altogether to solve the issue above, but I did not look into it yet.
Code:
+    .line 593
+    :cond_0
+    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->getApplicationContext()Landroid/content/Context;
+
+    move-result-object v0
+
+    invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
+
+    move-result-object v0
+
+    .line 594
+    const-string v2, "camera_in_use"
+
+    invoke-static {v0, v2, v4}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
+
     const-string v3, "Camera"
 
     .line 595
I removed all the garbage here, to focus on the switch part. By making it jump to :sswitch_2 instead of _sswitch_0 i force it to evaluate it as a camera button.
Code:
@@ -7930,32 +7963,34 @@
      :sswitch_data_0
     .sparse-switch
         0x4 -> :sswitch_0
         0x17 -> :sswitch_2
         0x18 -> :sswitch_3
         0x19 -> :sswitch_3
-        0x1a -> :sswitch_0
+        0x1a -> :sswitch_2
         0x1b -> :sswitch_2
         0x42 -> :sswitch_2
         0x50 -> :sswitch_1
Beginning of onKeyUp method. Now the power menu cannot longer be called by the power button, so I changed camera_in_use back to 0. I thought it was the safest location to allow android.policy.jar to respond to the button in any other circumstance.
Code:
@@ -7971,6 +8057,20 @@
     .prologue
     const/4 v4, 0x0
 
+    .line 687
+    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->getApplicationContext()Landroid/content/Context;
+
+    move-result-object v0
+
+    invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
+
+    move-result-object v0
+
+    .line 688
+    const-string v2, "camera_in_use"
+
+    invoke-static {v0, v2, v4}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
+
     const/4 v2, 0x1
 
     const-string v3, "Camera"
Actual code to make the power button to take the shot. To be honest, I don't really know how much of all this is required. I will trim it if I have the time.
Code:
@@ -8030,72 +8130,92 @@
     :cond_0
     const/16 v0, 0x1a
 
-    if-ne p1, v0, :cond_1
+    if-ne p1, v0, :cond_2
 
     .line 700
-    invoke-direct {p0}, Lcom/sec/android/app/camera/Camera;->resetFocusDueToZoom()V
+    iget-object v1, p0, Lcom/sec/android/app/camera/Camera;->mCameraEngine:Lcom/sec/android/app/camera/CameraEngine;
 
-    .line 701
-    iget-object v0, p0, Lcom/sec/android/app/camera/Camera;->mCameraBaseIndicators:Lcom/sec/android/app/camera/CameraBaseIndicators;
+    invoke-virtual {v1}, Lcom/sec/android/app/camera/CameraEngine;->isTouchAutoFocusing()Z
 
-    invoke-virtual {v0}, Lcom/sec/android/app/camera/CameraBaseIndicators;->showFocusIndicator()V
+    move-result v1
 
-    .line 702
-    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->getCameraSettings()Lcom/sec/android/app/camera/CameraSettings;
+    if-eqz v1, :cond_1
 
-    move-result-object v0
+    iget-object v1, p0, Lcom/sec/android/app/camera/Camera;->mCameraEngine:Lcom/sec/android/app/camera/CameraEngine;
 
-    invoke-virtual {v0}, Lcom/sec/android/app/camera/CameraSettings;->getLock()Z
+    invoke-virtual {v1}, Lcom/sec/android/app/camera/CameraEngine;->stopTouchAutoFocus()V
 
-    move-result v0
+    :cond_1
+    iget-object v1, p0, Lcom/sec/android/app/camera/Camera;->mCameraEngine:Lcom/sec/android/app/camera/CameraEngine;
 
-    if-eqz v0, :cond_2
+    const/16 v3, 0x190
 
-    .line 703
-    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->getCameraSettings()Lcom/sec/android/app/camera/CameraSettings;
+    const/16 v4, 0xf0
 
-    move-result-object v0
+    const/16 v0, 0x320
 
-    invoke-virtual {v0, v4}, Lcom/sec/android/app/camera/CameraSettings;->setLock(Z)V
+    const/16 v2, 0x1e0
 
-    .line 712
-    :cond_1
-    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->getCameraSettings()Lcom/sec/android/app/camera/CameraSettings;
+    invoke-virtual {v1, v3, v4}, Lcom/sec/android/app/camera/CameraEngine;->setTouchFocusPosition(II)V
 
-    move-result-object v0
+    iget-object v1, p0, Lcom/sec/android/app/camera/Camera;->mCameraEngine:Lcom/sec/android/app/camera/CameraEngine;
 
-    invoke-virtual {v0}, Lcom/sec/android/app/camera/CameraSettings;->getLock()Z
+    invoke-virtual {v1}, Lcom/sec/android/app/camera/CameraEngine;->startTouchAutoFocus()V
 
-    move-result v0
+    iget-object v1, p0, Lcom/sec/android/app/camera/Camera;->mCameraBaseIndicators:Lcom/sec/android/app/camera/CameraBaseIndicators;
 
-    if-eqz v0, :cond_3
+    invoke-virtual {v1}, Lcom/sec/android/app/camera/CameraBaseIndicators;->hideFocusIndicator()V
 
-    move v0, v2
+    iget-object v1, p0, Lcom/sec/android/app/camera/Camera;->mCameraBaseIndicators:Lcom/sec/android/app/camera/CameraBaseIndicators;
+
+    invoke-virtual {v1}, Lcom/sec/android/app/camera/CameraBaseIndicators;->resetTouchFocusRectView()V
+
+    iget-object v1, p0, Lcom/sec/android/app/camera/Camera;->mCameraBaseIndicators:Lcom/sec/android/app/camera/CameraBaseIndicators;
+
+    invoke-virtual {v1, v3, v4, v0, v2}, Lcom/sec/android/app/camera/CameraBaseIndicators;->setTouchFocusRectCenter(IIII)V
+
+    const/4 v1, 0x1
+
+    iput-boolean v1, p0, Lcom/sec/android/app/camera/Camera;->mChkAllowFocusTouch:Z
+
+    iget-object v1, p0, Lcom/sec/android/app/camera/Camera;->mCameraEngine:Lcom/sec/android/app/camera/CameraEngine;
+
+    invoke-direct {p0}, Lcom/sec/android/app/camera/Camera;->handleShutterKey()Z
+
+    invoke-virtual {v1}, Lcom/sec/android/app/camera/CameraEngine;->handleShutterEvent()V
+
+    invoke-virtual {v1}, Lcom/sec/android/app/camera/CameraEngine;->scheduleAutoFocus()V
+
+    invoke-direct {p0}, Lcom/sec/android/app/camera/Camera;->handleShutterKeyReleased()Z
+
+    invoke-virtual {v1}, Lcom/sec/android/app/camera/CameraEngine;->handleShutterReleaseEvent()V
+
+    const/4 v0, 0x1
 
-    .line 713
     goto :goto_0
 
-    .line 705
+    .line 702
+    .line 703
+    .line 712
     :cond_2
     invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->getCameraSettings()Lcom/sec/android/app/camera/CameraSettings;
 
     move-result-object v0
 
-    invoke-virtual {v0, v2}, Lcom/sec/android/app/camera/CameraSettings;->setLock(Z)V
-
-    .line 706
-    :goto_1
-    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->isCaptureEnabled()Z
+    invoke-virtual {v0}, Lcom/sec/android/app/camera/CameraSettings;->getLock()Z
 
     move-result v0
 
-    if-nez v0, :cond_1
+    if-eqz v0, :cond_3
 
-    .line 707
-    invoke-virtual {p0}, Lcom/sec/android/app/camera/Camera;->processBack()V
+    move v0, v2
 
-    goto :goto_1
+    .line 713
+    goto :goto_0
 
+    .line 705
+    .line 706
+    .line 707
     .line 716
     :cond_3
     const-string v0, "Camera"