[Galaxy S 4 Themes and Apps] ghoster76:
1st THIS IS NOT MINE TUTORIAL

I just edit, fix and change the code from N9005 to I9500

Credits go to darkera13 (SAMSUNG Developer) from Samsungviet

Link to orginal thread here

2nd WHAT'D WE HAVE AFTER DOING THIS MOD

1. THIS MOD IS ONLY FOR DEODEXED OFFICIAL LOLLIPOP ROM: You'd prepare android.policy.jar and framework-res.apk

2. Decompile the framework-res.apk and open /res/values/arrays.xml with your favorite text editor

Search for:

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

Add like 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 /res/values/strings.xml

Add to the end of file(EOF):

[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

Copy all PNG files in framework-res GlobalMenu_darkera13_samsungviet.vn.zip to /res/drawable-xhdpi and Compile

We'd get an apk: unsignedframework-res.apk

Now keep this file and decompile it. Then open /res/values/public.xml(in modified project unsignedframework-res.apk not framework-res.apk)

Note these lines to use in next big step

// This is what I got from recompiled [B]framework-res.apk[/B] might be different with your
// Note these lines to other place [B]not[/B] in public.xml because we just care about the number
<public type="string" name="global_action_screenshot" id="0x[B]01040ba5[/B]" /> -> const v4: [B]1040ba5[/B]
<public type="string" name="global_action_flashlight" id="0x[B]01040ba6[/B]" /> -> const v6: [B]1040ba6[/B]
<public type="string" name="global_actions_flashlight_on_status" id="0x0[B]1040ba7[/B]" /> -> const v7: [B]1040ba7[/B]
<public type="string" name="global_actions_flashlight_off_status" id="0x0[B]1040ba8[/B]" /> -> const v8: [B]1040ba8[/B]
<public type="drawable" name="tw_ic_lock_flashlight_on" id="0x0[B]1080b5c[/B]" /> -> const v4: [B]1080b5c[/B]
<public type="drawable" name="tw_ic_lock_flashlight_off" id="0x0[B]1080b5b[/B]" /> -> const v5: [B]1080b5b[/B]
<public type="drawable" name="tw_ic_lock_screenshot" id="0x0[B]1080b5d[/B]" /> -> const v3: [B]1080b5d[/B]

3. Decompile the android.policy.jar and open /com/android/internal/policy/impl/GlobalActions.smali

Search for:

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

Add like 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 like 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$5000()Ljava/lang/String;[/COLOR]

Add like following:

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

.prologue
.line 161
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 like following * Remember sections in bold the the ids from public.xml you'll get when editing the framework-res.apk:

// This is what I got from recompiled [B]framework-res.apk[/B] might be different with your
// These lines are in other place [B]not[/B] in public.xml
<public type="string" name="global_action_screenshot" id="0x[B]01040ba5[/B]" /> -> const v4: [B]1040ba5[/B]
<public type="string" name="global_action_flashlight" id="0x[B]01040ba6[/B]" /> -> const v6: [B]1040ba6[/B]
<public type="string" name="global_actions_flashlight_on_status" id="0x0[B]1040ba7[/B]" /> -> const v7: [B]1040ba7[/B]
<public type="string" name="global_actions_flashlight_off_status" id="0x0[B]1040ba8[/B]" /> -> const v8: [B]1040ba8[/B]
<public type="drawable" name="tw_ic_lock_flashlight_on" id="0x0[B]1080b5c[/B]" /> -> const v4: [B]1080b5c[/B]
<public type="drawable" name="tw_ic_lock_flashlight_off" id="0x0[B]1080b5b[/B]" /> -> const v5: [B]1080b5b[/B]
<public type="drawable" name="tw_ic_lock_screenshot" id="0x0[B]1080b5d[/B]" /> -> const v3: [B]1080b5d[/B]

[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, [B]0x1080b5c[/B]

const v5, [B]0x1080b5b[/B]

const v6, [B]0x1040ba6[/B]

const v7, [B]0x1040ba7[/B]

const v8, [B]0x1040ba8[/B]

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, [B]0x1080b5d[/B]

const v4, [B]0x1040ba5[/B]

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 like following:

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

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mDataModeToggle: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[/COLOR]

[COLOR="Red"] .line 1229
const/16 v2, 0x20

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mAirplaneModeOn: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

.line 1230
const/16 v2, 0x40

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart: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]

Match 2 results, mark the line with:

:cond_2b6
const-string v2, "emergencymode"

Add like following:

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

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

move-result v2[/COLOR]

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

[COLOR="SeaGreen"].line 1291
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]

[COLOR="Red"]: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="SeaGreen"].line 1292
:cond_2ca
const-string v2, "silent"[/COLOR]

Search for:

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

Add to bottom like following:

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

[COLOR="Red"]invoke-direct {p0}, Lcom/android/internal/policy/impl/GlobalActions;->getTorchStatus()Z

move-result v1

if-eqz v1, :cond_20

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 :cond_21

:cond_20
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 :cond_21

:cond_21[/COLOR]

Search for:

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

Add to above like following:

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

.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 7[/COLOR]

Search for:

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

Add to above like following:

[COLOR="Red"] 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"]const-string v4, "content://com.sec.knox.provider2/KnoxCustomManagerService1"[/COLOR]

Copy all smali files in andorid.policy.jar GlobalMenu_darkera13_samsungviet.vn.zip to /smali/com/android/internal/policy/impl and Compile the android.policy.jar​

4. Now you'd have unsignedframework-res.apk and mod_android.policy.jar. Rename them to framework-res.apk and android.policy.jar. Put it in CWM flashable zip and flash with TWRP or Philz.

Tested on:

LRX22C.I9500XXUHOAA Deodexed: Working

AURORA Lollipop Port Beta 5: Working

InFolder: Mediafire