[AT&T Samsung Galaxy S 4 Android Development] jeboo:
This thread is a continuation of many previous ones, mainly the one by untermensch (http://xdaforums.com/showthread.php?t=811532). I kept the mod going for ICS (http://xdaforums.com/showpost.php?p=24218275&postcount=217), and figured 4.2.2 is deserving of a new thread.

The good news is the framework actually simplified the mod, requiring only two files to be updated. This tutorial is based on UCUAMDL.

1. framework-res.apk (this 1st part is unchanged from previous thread)

a) In strings.xml, add:

<string name="epm_recovery">Recovery</string>
<string name="epm_download">Download</string>

b) In public.xml, add (NOTE: these resource IDs will change in the future!!):

<public type="string" name="epm_recovery" id="0x010408e3" />
<public type="string" name="epm_download" id="0x010408e4" />
<public type="drawable" name="ic_lock_recovery" id="0x01080c9d" />
<public type="drawable" name="ic_lock_download" id="0x01080c9e" />

c) Lastly, add your two icons as ic_lock_recovery.png and ic_lock_download.png in drawable-hdpi.

Compile framework-res.apk, upload and reboot phone.

-----------------------------------------------------------------------------------------------

2. android.policy.jar

a) In GlobalActions.smali, add the following variables around line 150:

.field private mRecovery:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

.field private mDownload:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

b) Same file, find:

.line 566

new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$5;

const v1, 0x108097f

const v2, 0x1040199

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

iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

Add this code directly below it (NOTE: this code references the resource IDs above, be sure to correct if they've changed):

new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$18;

const v1, [COLOR="Red"]0x1080c9d[/COLOR]

const v2, [COLOR="red"]0x10408e3[/COLOR]

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

iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRecovery:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$19;

const v1, [COLOR="red"]0x1080c9e[/COLOR]

const v2, [COLOR="red"]0x10408e4[/COLOR]

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

iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mDownload:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

c) About 10 lines below, you will see:

.line 659

const/4 v0, 0x6

Change it to:

const/16 v0, 0x8

d) About 20 lines below that, you will see:

const/4 v1, 0x5

iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mBugReport:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v2, v0, v1

Add this code directly after:

const/4 v1, 0x6

iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRecovery:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v2, v0, v1

const/4 v1, 0x7

iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mDownload:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v2, v0, v1

e) All that's left is to add the 2 smalis to handle when the menu items are selected. This is where the code is now simplified, as we don't need to mess with framework.jar anymore. In short, ShutDownThread.smali in framework has a reboot method that supports a parameter. So we simply call it with the appropriate param (either recovery or download).

Still in policy.jar, copy GlobalActions$5.smali as a template for GlobalActions$18.smali, change all the $5 to $18, and then we are going to replace the onPress method with this:

.method public onPress()V
.registers 6

.prologue
iget-object v1, p0, Lcom/android/internal/policy/impl/GlobalActions[COLOR="Red"]$18[/COLOR];->this$0:Lcom/android/internal/policy/impl/GlobalActions;

# getter for: Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;
invoke-static {v1}, Lcom/android/internal/policy/impl/GlobalActions;->access$000(Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;

move-result-object v1

const-string v2, [COLOR="red"]"recovery"[/COLOR]

const/4 v3, [COLOR="red"]0x1[/COLOR] # CONFIRMATION FLAG

invoke-static {v1, v2, v3}, Lcom/android/server/power/ShutdownThread;->reboot(Landroid/content/Context;Ljava/lang/String;Z)V

return-void
.end method

Repeat this step for GlobalActions$19.smali but change "recovery" to "download", and $18 to $19, in the code fragment above. Also note, you can decide whether you want a confirmation dialog or not by setting v3 to 0x0 (no) or 0x1 (yes).

Compile android.policy.jar, upload and reboot! If all went well, you will see the EPM with your new options :fingers-crossed:

ADDENDUM:

If you're interested in adding Flashlight to the EPM, this is the onPress method:

.method public onPress()V
.registers 6

.prologue
sget-boolean v0, Lcom/android/internal/policy/impl/GlobalActions$20;->mFlashlight:Z

if-nez v0, :cond_6

const/4 v2, 0x1

goto :goto_7

:cond_6
const/4 v2, 0x0

:goto_7
sput-boolean v2, Lcom/android/internal/policy/impl/GlobalActions$20;->mFlashlight:Z

invoke-static {v2}, Lcom/sec/android/hardware/SecHardwareInterface;->setTorchLight(I)V

return-void
.end method