[Samsung Epic 4G Touch] tdunham:
This is based off of FL16/GB08 JB 4.1.2.

A touchwiz 4.3 guide has been posted here:

[Guide How-to/MOD] New Power Menu with Screenshot TW 4.3

This will allow you to have Recovery and Bootloader (download mode) right in the Power Menu selections. I grew tired of the extended restart menu so I wrote this.

This is not a flashable mod, it is a guide only.

The attached zip file are support files only that are necessary to create this modification.

Power Menu Guide

[U][B]Framework-res.apk changes[/B]:[/U]

Add these lines to res/values/strings.xml

[CODE] <string name="download">Bootloader</string>
<string name="recovery">Recovery</string>

Add the two png files in the attachment to:

res/drawable-hdpi

Recompile framework-res.apk.

Decompile the new framework-res.apk and open res/values/public.xml.

We need to write down these values because we need them later. Yours will probably be different. Leave off the leading zero:

<public type="drawable" name="tw_ic_download" id="0x0[COLOR="Red"]1080ad6[/COLOR]" />
<public type="drawable" name="tw_ic_recovery" id="0x0[COLOR="Red"]1080ad7[/COLOR]" />
<public type="string" name="download" id="0x0[COLOR="Red"]1040843[/COLOR]" />
<public type="string" name="recovery" id="0x0[COLOR="Red"]1040844[/COLOR]" />

Android.policy.jar changes:

Add the two smali files in the attachment to com\android\internal\policy\impl

Smali edit:

com\android\internal\policy\impl\GlobalActions.smali

New line before:

.field private mDialog:Landroid/app/AlertDialog;

.field private mHandler:Landroid/os/Handler;

After:

.field private mDialog:Landroid/app/AlertDialog;

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

[/COLOR].field private mHandler:Landroid/os/Handler;

New line before:

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

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

After:

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

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

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

Find around line 1075:

.line 372
new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$4;

const v2, 0x10808ee

const v3, 0x1040192

move-object/from16 v0, p0

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

move-object/from16 v0, p0

iput-object v1, v0, Lcom/android/internal/policy/impl/GlobalActions;->mPowerOff:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
.line 399

Add new lines after this section:

***NOTE THE LINES IN BLUE, THESE MUST MATCH THE VALUES WE GOT FROM FRAMEWORK (without the leading zero)***

.line 372
new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$4;

const v2, 0x10808ee

const v3, 0x1040192

move-object/from16 v0, p0

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

move-object/from16 v0, p0

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

.line 399
[COLOR="Red"] new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$Download;

const v2, 0x[COLOR="Blue"]1080ad6[/COLOR]

const v3, 0x[COLOR="Blue"]1040843[/COLOR]

move-object/from16 v0, p0

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

move-object/from16 v0, p0

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

.line 400
new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$Recovery;

const v2, 0x[COLOR="Blue"]1080ad7[/COLOR]

const v3, 0x[COLOR="Blue"]1040844[/COLOR]

move-object/from16 v0, p0

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

move-object/from16 v0, p0

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

.line 401
[/COLOR] new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$5;

Now we are going to expand the existing array to include 2 more entries.

Around line 1138:

Before:

.line 428
const/4 v1, 0x5

After:

.line 428
[COLOR="Red"]const/4 v1, 0x7[/COLOR]

Find around line 1137:

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

aput-object v3, v1, v2

const/4 v2, 0x4

move-object/from16 v0, p0

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

aput-object v3, v1, v2

invoke-static {v1}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;

Replace with:

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

aput-object v3, v1, v2

const/4 v2, 0x4

move-object/from16 v0, p0

[COLOR="Red"] iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mDownload:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v3, v1, v2

const/4 v2, 0x5

move-object/from16 v0, p0

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

aput-object v3, v1, v2

const/4 v2, 0x6

move-object/from16 v0, p0[/COLOR]

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

aput-object v3, v1, v2

invoke-static {v1}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;

How to remove menu items:

Smali edit:

com\android\internal\policy\impl\GlobalActions.smali

We need to reconfigure the array that displays the options.

Before:

.line 428
const/4 v1, 0x7

new-array v1, v1, [Lcom/android/internal/policy/impl/GlobalActions$Action;

const/4 v2, 0x0

move-object/from16 v0, p0

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

aput-object v3, v1, v2

const/4 v2, 0x1

move-object/from16 v0, p0

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

aput-object v3, v1, v2

const/4 v2, 0x2

move-object/from16 v0, p0

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

aput-object v3, v1, v2

const/4 v2, 0x3

move-object/from16 v0, p0

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

aput-object v3, v1, v2

const/4 v2, 0x4

move-object/from16 v0, p0

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

aput-object v3, v1, v2

const/4 v2, 0x5

move-object/from16 v0, p0

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

aput-object v3, v1, v2

const/4 v2, 0x6

move-object/from16 v0, p0

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

aput-object v3, v1, v2

invoke-static {v1}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;

move-result-object v1

move-object/from16 v0, p0

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

We need to split up the array so that we can easily see the different sections.

It will make it easier to modify the line you want to remove.

.line 428
const/4 v1, 0x7

new-array v1, v1, [Lcom/android/internal/policy/impl/GlobalActions$Action;

#

const/4 v2, 0x0

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

const/4 v2, 0x1

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

const/4 v2, 0x2

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

const/4 v2, 0x3

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

const/4 v2, 0x4

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

const/4 v2, 0x5

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

const/4 v2, 0x6

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

invoke-static {v1}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;

move-result-object v1

move-object/from16 v0, p0

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

Now we will remove the Data Network Mode and Airplane Mode choices from the menu. We need to shrink the array by 2 and also renumber the remaining options. Please note the changes in red.

.line 428
[COLOR="Red"] const/4 v1, 0x5[/COLOR]

new-array v1, v1, [Lcom/android/internal/policy/impl/GlobalActions$Action;

#

const/4 v2, 0x0

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

const/4 v2, 0x1

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

[COLOR="Red"] # const/4 v2, 0x2

# move-object/from16 v0, p0

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

# aput-object v3, v1, v2
[/COLOR]
#

[COLOR="Red"] # const/4 v2, 0x3

# move-object/from16 v0, p0

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

# aput-object v3, v1, v2[/COLOR]

#

[COLOR="Red"] const/4 v2, 0x2[/COLOR]

move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

[COLOR="Red"] const/4 v2, 0x3
[/COLOR]
move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

[COLOR="Red"] const/4 v2, 0x4
[/COLOR]
move-object/from16 v0, p0

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

aput-object v3, v1, v2

#

invoke-static {v1}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;

move-result-object v1

move-object/from16 v0, p0

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

Note: Use of the # symbol is not necessary. I use it simply for clarification and to separate out the sections for easier viewing while editing. Additionally, any lines edited with the # symbol will be ignored when recompiling.

Addendum - Adding Screenshot to Power Menu

(This is an addon to the original Power Menu Guide posted above).

Framework-res.apk changes:

Add these lines to res/values/strings.xml

<string name="global_action_screenshot_txt">Screenshot</string>

Add png file in the screenshot attachment to:

res/drawable-hdpi

Recompile framework-res.apk.

Decompile the new framework-res.apk and open res/values/public.xml.

We need to write down these values because we need them later. Yours will probably be different. Leave off the leading zero:

<public type="string" name="global_action_screenshot_txt" id="0x01040845" />
<public type="drawable" name="tw_ic_screenshot" id="0x01080ad8" />

Android.policy.jar changes:

Add the two smali files in the attachment to com\android\internal\policy\impl

Smali edit:

com\android\internal\policy\impl\GlobalActions.smali

New line before:

.field private mRingerModeReceiver:Landroid/content/BroadcastReceiver;

.field private mSilentModeAction:Lcom/android/internal/policy/impl/GlobalActions$SilentModeAction;

After:

.field private mRingerModeReceiver:Landroid/content/BroadcastReceiver;

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

.field private mSilentModeAction:Lcom/android/internal/policy/impl/GlobalActions$SilentModeAction;

New Section Before:

.line 372
new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$4;

const v2, 0x10808ee

const v3, 0x1040192

move-object/from16 v0, p0

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

move-object/from16 v0, p0

iput-object v1, v0, Lcom/android/internal/policy/impl/GlobalActions;->mPowerOff:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
.line 399
new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$Download;

const v2, 0x1080ad6

const v3, 0x1040843

move-object/from16 v0, p0

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

move-object/from16 v0, p0

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

After:

***NOTE THE LINES IN BLUE, THESE MUST MATCH THE VALUES WE GOT FROM FRAMEWORK (without the leading zero)***

.line 372
new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$4;

const v2, 0x10808ee

const v3, 0x1040192

move-object/from16 v0, p0

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

move-object/from16 v0, p0

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

[COLOR="Red"] .line 388
new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$16;

const v2, 0x[COLOR="Blue"]1080ad8[/COLOR]

const v3, 0x[COLOR="Blue"]1040845[/COLOR]

move-object/from16 v0, p0

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

move-object/from16 v0, p0

iput-object v1, v0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenCapture:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
[/COLOR]
.line 399
new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$Download;

const v2, 0x1080ad6

const v3, 0x1040843

move-object/from16 v0, p0

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

move-object/from16 v0, p0

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

Now to edit the array and add ScreenShot

NOTE: FYI, here we are removing replacing DataToggle with Airplane Mode to keep menu from overlapping the screen.

Find around line 1180:

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

aput-object v3, v1, v2

const/4 v2, 0x3

move-object/from16 v0, p0

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

aput-object v3, v1, v2

const/4 v2, 0x4

move-object/from16 v0, p0

Replace with:

[COLOR="Red"] iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mAirplaneModeOn:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;[/COLOR]
aput-object v3, v1, v2

const/4 v2, 0x3

move-object/from16 v0, p0

[COLOR="Red"]iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenCapture:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR]

aput-object v3, v1, v2

const/4 v2, 0x4

move-object/from16 v0, p0

If porting this to another phone

Important update info for Screenshot mod:

You may have to possibly change this value in GlobalActions$16$1.smali which is one of the addon files to match your code.

invoke-static {v2}, Lcom/android/internal/policy/impl/GlobalActions;->[COLOR="Red"]access$200[/COLOR](Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;

Here is my access$200 in GlobalActions.smali, just search for the line in red. If it is different access$xxx in your smali, also change access$xxx to match in GlobalActions$16$1.smali:

.method static synthetic access$200(Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;
.registers 2
.parameter "x0"

.prologue
.line 88
[COLOR="Red"]iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;[/COLOR]

return-object v0
.end method

Credits to Mirko DDD for the ScreenShot method!!!