[Samsung Galaxy S II Plus] panda00:
POWER BUTTON AS CAMERA SHUTTER

Difficulty level: [EASY]

Special thanks to @klurosu

His guide

Decompile SamsungCamera.apk

Navigate to \smali\com\sec\android\app\camera and open Camera.smali

As you can see, codes go under specific "methods", like categories, wrapped around .method and .end method tags... So the "category" we'll be going for is:

.method public onKeyDown(ILandroid/view/KeyEvent;)Z

Scroll down ( a lot, but not too much, just before the .end method of the method we went to) to the following code portion:

.line 1884
:sswitch_data_0
.sparse-switch
0x4 -> :sswitch_1
0x17 -> :sswitch_4
0x18 -> :sswitch_5
0x19 -> :sswitch_5
[B][COLOR=Blue]0x1a -> :sswitch_1[/COLOR][/B]
0x1b -> :sswitch_4
0x42 -> :sswitch_4
0x45 -> :sswitch_5
0x46 -> :sswitch_5
0x50 -> :sswitch_3
0x52 -> :sswitch_0
0x55 -> :sswitch_2
0x59 -> :sswitch_2
0x5a -> :sswitch_2
0x9c -> :sswitch_5
0x9d -> :sswitch_5
.end sparse-switch

A few things need to be noted here. First, the switch name (sswitch_x) is not always the same as you might have, but the id (0x##) is always the same. Here 0x17 is the shutter key on the screen, and 0x1a is the power button... we need to reroute the power button's switch to the shutter key's switch. So we'll be focusing on the blue line.

Change the code to the following if you haven't already figured it out.

.line 1884
:sswitch_data_0
.sparse-switch
0x4 -> :sswitch_1
0x17 -> :sswitch_4
0x18 -> :sswitch_5
0x19 -> :sswitch_5
[B][COLOR=Red]0x1a -> :sswitch_4[/COLOR][/B]
0x1b -> :sswitch_4
0x42 -> :sswitch_4
0x45 -> :sswitch_5
0x46 -> :sswitch_5
0x50 -> :sswitch_3
0x52 -> :sswitch_0
0x55 -> :sswitch_2
0x59 -> :sswitch_2
0x5a -> :sswitch_2
0x9c -> :sswitch_5
0x9d -> :sswitch_5
.end sparse-switch

No we're not done yet lazy! The next method is just under the .end method of the previous one, which we were already at, but if you saved and closed the smali out of sheer excitement, reopen it and go to this method:

.method public onKeyUp(ILandroid/view/KeyEvent;)Z

Now scroll down (a lot, but not too much, right before the .end method tag) to the following code portion:

:sswitch_data_0
.sparse-switch
0x3 -> :sswitch_5
0x4 -> :sswitch_0
0x17 -> :sswitch_2
0x18 -> :sswitch_3
0x19 -> :sswitch_3
[B][COLOR=Blue]0x1a -> :sswitch_3[/COLOR][/B]
0x1b -> :sswitch_2
0x42 -> :sswitch_2
0x50 -> :sswitch_4
0x52 -> :sswitch_1
.end sparse-switch

Again the switch names might not be the same and we'll focus on the 0x1a switch (blue line), as the previous step, and reroute it to 0x17.

Again, if you haven't figured it out yourself, edit the code to the following:

:sswitch_data_0
.sparse-switch
0x3 -> :sswitch_5
0x4 -> :sswitch_0
0x17 -> :sswitch_2
0x18 -> :sswitch_3
0x19 -> :sswitch_3
[COLOR=Blue] [COLOR=Red][B]0x1a -> :sswitch_2[/B][/COLOR][/COLOR]
0x1b -> :sswitch_2
0x42 -> :sswitch_2
0x50 -> :sswitch_4
0x52 -> :sswitch_1
.end sparse-switch

Save the file and recompile the APK :)

CRT-OFF EFFECT

Difficulty level: [EASY]

@Special thanks to [MENTION=3892104]klurosu[/MENTION] and [MENTION=369057]majdinj[/MENTION]

klurosu's guide

NEW TOOL MUST BE DOWNLOADED: Classes.dex compiler/decompiler

Download the tool and extract it to a location of your liking and let's begin.

Take services.jar from framework folder and open it with 7zip.

Copy classes.dex from services.jar (opened with 7zip) to the input folder in the folder of the tool we extracted initially.

Run Script.bat and choose "decompile classes.dex"

Navigate to the decompiled folder in the tool folder and go to \com\android\server and openPowerManagerService$ScreenBrightnessAnimator.smali file

Look for the following portion of code:

.line 3064
.end local v0 #delta:I
:cond_60
:goto_60
iget-object v7, p0, Lcom/android/server/PowerManagerService$ScreenBrightnessAnimator;->this$0:Lcom/android/server/PowerManagerService;

#getter for: Lcom/android/server/PowerManagerService;->mScreenBrightnessHandler:Landroid/os/Handler;
invoke-static {v7}, Lcom/android/server/PowerManagerService;->access$7200(Lcom/android/server/PowerManagerService;)Landroid/os/Handler;

move-result-object v7

const/16 v9, 0xa

invoke-virtual {v7, v9}, Landroid/os/Handler;->removeMessages(I)V

Change it to this: ( add the red lines )

.line 3064
.end local v0 #delta:I
:cond_60
:goto_60
iget-object v7, p0, Lcom/android/server/PowerManagerService$ScreenBrightnessAnimator;->this$0:Lcom/android/server/PowerManagerService;

#getter for: Lcom/android/server/PowerManagerService;->mScreenBrightnessHandler:Landroid/os/Handler;
invoke-static {v7}, Lcom/android/server/PowerManagerService;->access$7200(Lcom/android/server/PowerManagerService;)Landroid/os/Handler;

move-result-object v7

[B][COLOR=Red]if-eqz p2, :cond_maj

const/16 v9, 0xb

const/4 v10, 0x0

const v2, 0x10

invoke-virtual {v7, v9, v2, v10}, Landroid/os/Handler;->obtainMessage(III)Landroid/os/Message;

move-result-object v9

invoke-virtual {v9}, Landroid/os/Message;->sendToTarget()V

:cond_maj[/COLOR][/B]
const/16 v9, 0xa

invoke-virtual {v7, v9}, Landroid/os/Handler;->removeMessages(I)V