[Captivate Q&A, Help & Troubleshooting] aleadam:
Diff explanations

Let's start with the camera:

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

@@ -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.

@@ -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.

+ .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.

@@ -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.

@@ -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.

@@ -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"