[Galaxy S 5 Themes and Apps] ambasadii:
Hi xda!

This is not mine tutorial ,credits go to darkera13 (SAMSUNG Developer) from Samsungviet

Link to orginal thread here

I decided to translate it made some changes in code to work with G900F

This works only with deodex system files!

So lets start modding:

Decompile android.policy.jar and go to /com/android/internal/policy/impl/GlobalActions.smali

Search for:

[COLOR="SeaGreen"].field private mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR]

Add something like the following:

[COLOR="SeaGreen"].field private mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR]

[COLOR="Red"].field private mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

.field private mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

.field private mScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR]

Search for:

[COLOR="SeaGreen"]iput-object v3, p0, Lcom/android/internal/policy/impl/GlobalActions;->mAirplaneState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

sget-object v3, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->Off:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;[/COLOR]

Add something like the following:

[COLOR="SeaGreen"]iput-object v3, p0, Lcom/android/internal/policy/impl/GlobalActions;->mAirplaneState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

sget-object v3, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->Off:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;[/COLOR]

[COLOR="Red"]iput-object v3, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

sget-object v3, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->Off:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;[/COLOR]

Search for:

[COLOR="SeaGreen"].method static synthetic access$4700()Ljava/lang/String;[/COLOR]

Add to the below like this:

[COLOR="SeaGreen"].method static synthetic access$4700()Ljava/lang/String;
.registers 1

.prologue
.line 158
sget-object v0, Lcom/android/internal/policy/impl/GlobalActions;->mScafe:Ljava/lang/String;

return-object v0
.end method[/COLOR]

[COLOR="Red"]
.method static synthetic access$500(Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;
.registers 2

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;

return-object v0
.end method

.method static synthetic access$5000(Lcom/android/internal/policy/impl/GlobalActions;)Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;
.registers 2

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

return-object v0
.end method

.method static synthetic access$5001(Lcom/android/internal/policy/impl/GlobalActions;)Z
.registers 2

invoke-direct {p0}, Lcom/android/internal/policy/impl/GlobalActions;->getTorchStatus()Z

move-result v0

return v0
.end method[/COLOR]

Search for:

[COLOR="SeaGreen"] iput-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR]

Add something like the following (* Note this paragraph have the id, id have to create the corresponding public.xml then replaced in right here, guiding the bottom):

[COLOR="SeaGreen"] iput-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR]

[COLOR="Red"]new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$Flashlight;

const v4, 0x1080b74

const v5, 0x1080b75

const v6, 0x1040ba4

const v7, 0x1040ba6

const v8, 0x1040ba7

move-object/from16 v3, p0

invoke-direct/range {v2 .. v8}, Lcom/android/internal/policy/impl/GlobalActions$Flashlight;-><init>(Lcom/android/internal/policy/impl/GlobalActions;IIIII)V

move-object/from16 v0, p0

iput-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$Screenshot;

const v3, 0x1080b76

const v4, 0x1040ba3

move-object/from16 v0, p0

invoke-direct {v2, v0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$Screenshot;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

move-object/from16 v0, p0

iput-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR]

Search for:

[COLOR="SeaGreen"] const/16 v2, 0x100[/COLOR]

Add the following:

[COLOR="SeaGreen"]
const/16 v2, 0x100

invoke-direct/range {p0 .. p0}, Lcom/android/internal/policy/impl/GlobalActions;->getBugReportAction()Lcom/android/internal/policy/impl/GlobalActions$Action;

move-result-object v3

move-object/from16 v0, p0

iget-object v4, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

const/4 v5, 0x1

move-object/from16 v0, p0

invoke-direct {v0, v2, v3, v4, v5}, Lcom/android/internal/policy/impl/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/internal/policy/impl/GlobalActions$Action;Ljava/util/ArrayList;Z)Z[/COLOR]

[COLOR="Red"]const/16 v2, 0x200

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

move-object/from16 v0, p0

iget-object v4, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

const/4 v5, 0x1

move-object/from16 v0, p0

invoke-direct {v0, v2, v3, v4, v5}, Lcom/android/internal/policy/impl/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/internal/policy/impl/GlobalActions$Action;Ljava/util/ArrayList;Z)Z

const/16 v2, 0x400

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

move-object/from16 v0, p0

iget-object v4, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

const/4 v5, 0x1

move-object/from16 v0, p0

invoke-direct {v0, v2, v3, v4, v5}, Lcom/android/internal/policy/impl/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/internal/policy/impl/GlobalActions$Action;Ljava/util/ArrayList;Z)Z[/COLOR]

Search for:

[COLOR="SeaGreen"]const-string v2, "emergencymode"[/COLOR]

change this value like this:

[COLOR="Red"] if-eqz v2, :cond_315[/COLOR]

Add to the above as follows::

[COLOR="SeaGreen"] const-string v2, "emergencymode"

invoke-virtual {v2, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v2

[COLOR="Red"] if-eqz v2, :cond_315[/COLOR]

.line 1255
move-object/from16 v0, p0

iget-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mEmergency:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

invoke-virtual {v2, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

goto :goto_24b

[COLOR="Red"]	.line 1255
:cond_315
const-string v2, "flashlight"

invoke-virtual {v2, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v2

if-eqz v2, :cond_32a

move-object/from16 v0, p0

iget-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

invoke-virtual {v2, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

goto :goto_24b

:cond_32a
const-string v2, "screenshot"

invoke-virtual {v2, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v2

if-eqz v2, :cond_2ca

move-object/from16 v0, p0

iget-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

invoke-virtual {v2, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

goto :goto_24b[/COLOR]
[/COLOR]

Search for:

[COLOR="SeaGreen"].method private prepareDialog()V
.registers 8[/COLOR]

Add to the below as follows:

[COLOR="SeaGreen"].method private prepareDialog()V
.registers 8[/COLOR]

[COLOR="Red"]	.prologue
.line 1820

invoke-direct {p0}, Lcom/android/internal/policy/impl/GlobalActions;->getTorchStatus()Z

move-result v1

if-eqz v1, :cond_b

sget-object v4, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->On:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

goto :goto_10

:cond_b
sget-object v4, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->Off:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

goto :goto_10[/COLOR]

search for:

[COLOR="SeaGreen"].method private handleShow()V
.registers 5[/COLOR]

Add to the above as follows:

[COLOR="Red"].method private getTorchStatus()Z
.registers 5

.prologue
const/4 v0, 0x0

iget-object v1, p0, Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;

invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v1

const-string v2, "torch_light"

const/4 v3, -0x2

invoke-static {v1, v2, v0, v3}, Landroid/provider/Settings$System;->getIntForUser(Landroid/content/ContentResolver;Ljava/lang/String;II)I

move-result v1

if-eqz v1, :cond_11

const/4 v0, 0x1

:cond_11
return v0
.end method[/COLOR]

[COLOR="SeaGreen"].method private handleShow()V
.registers 5[/COLOR]

Search for:

[COLOR="SeaGreen"] const-string v4, "content://com.sec.knox.provider2/KnoxCustomManagerService1"[/COLOR]

Add to the above like this:

[COLOR="Red"]	.line 1840
iget-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

iget-object v5, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

invoke-virtual {v4, v5}, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->updateState(Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;)V[/COLOR]

[COLOR="SeaGreen"] .line 1842
const-string v4, "content://com.sec.knox.provider2/KnoxCustomManagerService1"[/COLOR]

Save and unzip attachments GlobalMenu_darkera13_samsungviet.vn.zip copy the entire file in andorid.policy in / com / android / internal / policy / impl /

Decompile framework-res.apk and go to /res/values/arrays.xml

Search for:

[COLOR="SeaGreen"] <string-array name="config_globalActionsList">[/COLOR]

Add the following:

[COLOR="SeaGreen"]<string-array name="config_globalActionsList">
<item>power</item>
<item>datamode</item>
<item>airplane</item>
<item>restart</item>
<item>lockdown</item>
<item>bugreport</item>
<item>users</item>
<item>emergencymode</item>[/COLOR]
[COLOR="Red"]<item>flashlight</item>
<item>screenshot</item>[/COLOR]
[COLOR="SeaGreen"]</string-array>[/COLOR]

Save and open files /res/values/strings.xml

Add to the end of the file is as follows:

[COLOR="Red"] <string name="global_action_screenshot">Take Screenshot</string>
<string name="global_action_flashlight">Flashlight</string>
<string name="global_actions_flashlight_on_status">On</string>
<string name="global_actions_flashlight_off_status">Off</string>[/COLOR]
[COLOR="SeaGreen"] </resources>[/COLOR]

Save and open files /res/values/public.xml

Add to the end of the file is as follows:

[COLOR="Red"] <public type="string" name="global_action_screenshot" id="0x01040ba3" />
<public type="string" name="global_action_flashlight" id="0x01040ba4" />
<public type="string" name="global_actions_flashlight_on_status" id="0x01040ba5" />
<public type="string" name="global_actions_flashlight_off_status" id="0x01040ba6" />
<public type="drawable" name="tw_ic_lock_flashlight_on" id="0x01080b74" />
<public type="drawable" name="tw_ic_lock_flashlight_off" id="0x01080b75" />
<public type="drawable" name="tw_ic_lock_screenshot" id="0x01080b76" />[/COLOR]

The id of public.xml may vary depending on the change of the file before public.xml so id have to figure out the right to revise section above id.

The principle of the id is constantly and have the right type, each type will have its own code (eg look at the section on the string is found 0x0104, 0x0108 will be drawable)

So to know the correct id id must be the biggest find in each type, try before going straight string,

here we see this guy 0x0104xxxx code is wrong we try to thousands and hundreds, tens and units ie instead of to find us every turn from 0x01040 -> 0x01049 guy, the guy does not have before it the biggest guy,

for example 0x01045 guy does not have the biggest guy thousands of it is 0x01044, so look down to the hundreds, tens and units. Note small as it used id hexadecimal should turn from small to large 0 -> 9, a, b, c, d, e, f

After finding the largest id translational then 1 unit and instead turn to the id in public.xml similar.

Afterward, they must determine the correct id id in the code Smail (noted above) with the correct id (Note that in the smali code id dropping 1 to 0 on, eg 0x01040ba3 going into 0x1040ba3)

something like this:

<public type="drawable" name="tw_ic_lock_flashlight_off" id="0x01080b84" /> ->	0x1080b84 -> const v5
<public type="drawable" name="tw_ic_lock_flashlight_on"	id="0x01080b85" /> ->	0x1080b85 -> const v4
<public type="drawable" name="tw_ic_lock_screenshot" id="0x01080b86" /> -> 0x1080b86	-> const v3

<public type="string" name="global_action_screenshot" id="0x01040b85" /> -> 0x1040b85 -> const v4
<public type="string" name="global_actions_flashlight_on_status" id="0x01040b87" /> -> 0x1040b87 -> const v7
<public type="string" name="global_actions_flashlight_off_status" id="0x01040b88" />	-> 0x1040b88	-> const v8
<public type="string" name="global_action_flashlight"	id="0x01040b86" /> -> 0x1040b86 -> const v6

Next copy the image file in framework-res attachments / *. Png into the framework-res / res / drawable-xhdpi

Recompile and done!

Download smali and framework-res files from here

Power Menu Mod with screenshot and flashlight button + 5 way reboot menu (G900FXXU1BNL9)

download

Credits:

[MENTION=4696762]darkera13[/MENTION]