[Sprint Samsung Galaxy S III] tdunham:
New Power Menu with Screenshot TW 4.3 MK3/MK5​

Create a Backup First​

For Stock TW 4.3 SPH-L710 MK3/MK5 Builds Only!
​

Do not flash this on a custom ROM, it replaces important framework files​

Notes

:

I know the extended restart menu has been around for quite a while but I really prefer the simplicity and ease of access to the standard Power Menu without that extra keypress.

Features

:

- Reboot to Recovery (instant - no prompt)

- Reboot to Download Mode (instant - no prompt)

- Screenshot

Update

:

Added a second New Power Menu with Airplane Mode toggle removed.

Just flash over the other one if you want to try it.

[Guide How-to] Power Menu

Download the support files located at the bottom of the post.

framework-res.apk edits:

Add the 3 icons (from the support file) to framework-res/res/drawable-xhdpi

Add 3 new lines to framework-res/res/values/strings:

<string name="download">Bootloader</string>
<string name="recovery">Recovery</string>
<string name="global_action_screenshot_txt">Screenshot</string>
</resources>

Compile then De-compile the new framework-res.apk. We will need to view the public.xml file later to get a few values for the next section.

android.policy.jar edits:

Add the 6 new smali files (from the support file) to android.policy/com/android/internal/policy/impl.

(In the same path) edit GlobalActions.smali (or diff the stock and modified GlobalActions.smali included in the support file):

Before:

.field private final mDreamManager:Landroid/service/dreams/IDreamManager;

.field private mHandler:Landroid/os/Handler;

After:

.field private final mDreamManager:Landroid/service/dreams/IDreamManager;

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

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

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

Before:

.field private mRingerModeReceiver:Landroid/content/BroadcastReceiver;

.field private final mShowSilentToggle:Z

After:

.field private mRingerModeReceiver:Landroid/content/BroadcastReceiver;

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

.field mScreenshotConnection:Landroid/content/ServiceConnection;

.field final mScreenshotLock:Ljava/lang/Object;

.field final mScreenshotTimeout:Ljava/lang/Runnable;

[/COLOR].field private final mShowSilentToggle:Z

Before:

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

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;->mDataNetworkState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

iput-boolean v6, p0, Lcom/android/internal/policy/impl/GlobalActions;->mIsWaitingForEcmExit:Z

iput-boolean v5, p0, Lcom/android/internal/policy/impl/GlobalActions;->mDisplayConfirm:Z

const/4 v4, 0x0

After:

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

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;->mDataNetworkState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

[COLOR="Blue"] new-instance v4, Ljava/lang/Object;

invoke-direct {v4}, Ljava/lang/Object;-><init>()V

iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshotLock:Ljava/lang/Object;

const/4 v4, 0x0

iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshotConnection:Landroid/content/ServiceConnection;

new-instance v4, Lcom/android/internal/policy/impl/GlobalActions$29;

invoke-direct {v4, p0}, Lcom/android/internal/policy/impl/GlobalActions$29;-><init>(Lcom/android/internal/policy/impl/GlobalActions;)V

iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshotTimeout:Ljava/lang/Runnable;
[/COLOR]
iput-boolean v6, p0, Lcom/android/internal/policy/impl/GlobalActions;->mIsWaitingForEcmExit:Z

iput-boolean v5, p0, Lcom/android/internal/policy/impl/GlobalActions;->mDisplayConfirm:Z

const/4 v4, 0x0

New method:

Before:

.method static synthetic access$1700(Lcom/android/internal/policy/impl/GlobalActions;)Z
.locals 1

iget-boolean v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mKeyguardShowing:Z

return v0
.end method

.method static synthetic access$1800(Lcom/android/internal/policy/impl/GlobalActions;)Lcom/android/internal/policy/impl/GlobalActions$ConfirmDialogReceiver;
.locals 1

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

return-object v0
.end method

After:

.method static synthetic access$1700(Lcom/android/internal/policy/impl/GlobalActions;)Z
.locals 1

iget-boolean v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mKeyguardShowing:Z

return v0
.end method

[COLOR="Blue"].method static synthetic access$1701(Lcom/android/internal/policy/impl/GlobalActions;)V
.locals 0

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

return-void
.end method
[/COLOR]

.method static synthetic access$1800(Lcom/android/internal/policy/impl/GlobalActions;)Lcom/android/internal/policy/impl/GlobalActions$ConfirmDialogReceiver;
.locals 1

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

return-object v0
.end method

Before:

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

const v1, 0x1080a60

const v2, 0x10401c8

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

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

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

const v1, 0x1080a61

const v2, 0x10401c9

invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$7;-><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;

After:

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

const v1, 0x1080a60

const v2, 0x10401c8

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

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

[COLOR="Blue"] new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$Download;

const v1, 0x1081088

const v2, 0x1040a0b

invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$Download;-><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;

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

const v1, 0x1081089

const v2, 0x1040a0c

invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$Recovery;-><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$28;

const v1, 0x108108a

const v2, 0x1040a0d

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

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

const v1, 0x1080a61

const v2, 0x10401c9

invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$7;-><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;

Edit above section

Before continuing, go back to the new DECOMPILED framework-res.apk and open res/values/public.xml with notepad++.

Search for <public type="drawable" name="tw_ic_download"

- All 3 of our new public drawable values for the png images will be listed together.

Search for <public type="string" name="download"

- All 3 of our new public string values will be listed together.

Now, using these we will edit the 3 new sections above for the these new public values. Instead of jumping back and forth in the public.xml, I do the drawables (V1 values) all at once and then go to the strings section and do the strings (V2 values) next.

<public type="drawable" name="tw_ic_download" id="0x01081088" />
<public type="drawable" name="tw_ic_recovery" id="0x01081089" />
<public type="drawable" name="tw_ic_screenshot" id="0x0108108a" />

<public type="string" name="download" id="0x01040a0b" />
<public type="string" name="recovery" id="0x01040a0c" />
<public type="string" name="global_action_screenshot_txt" id="0x01040a0d" />

For instance, we are editing these values:

Download:

const v1, 0x1081088 (V1 = DRAWABLE)

const v2, 0x1040a0b (V2 = STRING)

Important Note:

Please note that the leading zero is not used from the public value.

Next, search for const/16 v0, 0x8

Replace this entire section:

Before:

[COLOR="Red"] const/16 v0, 0x8

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

const/4 v1, 0x0

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

aput-object v2, v0, v1

const/4 v1, 0x1

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

aput-object v2, v0, v1

const/4 v1, 0x2

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

aput-object v2, v0, v1

const/4 v1, 0x3

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

aput-object v2, v0, v1

const/4 v1, 0x4

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

aput-object v2, v0, v1

const/4 v1, 0x5

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

aput-object v2, v0, v1

const/4 v1, 0x6

iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mBugReport: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;->mLonglife:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

aput-object v2, v0, v1
[/COLOR]

After:

[COLOR="Blue"] const/16 v0, 0x8

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

const/4 v1, 0x0

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

aput-object v2, v0, v1

const/4 v1, 0x1

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

aput-object v2, v0, v1

const/4 v1, 0x2

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

aput-object v2, v0, v1

const/4 v1, 0x3

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

aput-object v2, v0, v1

const/4 v1, 0x4

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

aput-object v2, v0, v1

const/4 v1, 0x5

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

aput-object v2, v0, v1

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;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v2, v0, v1
[/COLOR]

New method. Search for # virtual methods and insert this method BEFORE that line:

[COLOR="Blue"].method private takeScreenshot()V
.locals 8

iget-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshotLock:Ljava/lang/Object;

monitor-enter v4

:try_start_0
iget-object v3, p0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshotConnection:Landroid/content/ServiceConnection;

if-eqz v3, :cond_0

monitor-exit v4

:goto_0
return-void

:cond_0
new-instance v0, Landroid/content/ComponentName;

const-string v3, "com.android.systemui"

const-string v5, "com.android.systemui.screenshot.TakeScreenshotService"

invoke-direct {v0, v3, v5}, Landroid/content/ComponentName;-><init>(Ljava/lang/String;Ljava/lang/String;)V

new-instance v2, Landroid/content/Intent;

invoke-direct {v2}, Landroid/content/Intent;-><init>()V

invoke-virtual {v2, v0}, Landroid/content/Intent;->setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;

new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$30;

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

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

const/4 v5, 0x1

sget-object v6, Landroid/os/UserHandle;->CURRENT:Landroid/os/UserHandle;

invoke-virtual {v3, v2, v1, v5, v6}, Landroid/content/Context;->bindServiceAsUser(Landroid/content/Intent;Landroid/content/ServiceConnection;ILandroid/os/UserHandle;)Z

move-result v3

if-eqz v3, :cond_1

iput-object v1, p0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshotConnection:Landroid/content/ServiceConnection;

iget-object v3, p0, Lcom/android/internal/policy/impl/GlobalActions;->mHandler:Landroid/os/Handler;

iget-object v5, p0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshotTimeout:Ljava/lang/Runnable;

const-wide/16 v6, 0x2710

invoke-virtual {v3, v5, v6, v7}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

:cond_1
monitor-exit v4

goto :goto_0

:catchall_0
move-exception v3

monitor-exit v4
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0

throw v3
.end method
[/COLOR]

[Guide How-to] Remove a Menu Item

Search for const/16 v0, 0x8

Each menu item of this array is only 3 lines. We will remove the Airplane Mode toggle. Delete or comment out these 3 lines.

const/4 v1, 0x3

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

aput-object v2, v0, v1

Since we have removed a menu item, the array constructor const/16 v0, 0x8

needs to be changed to const/16 v0, 0x7 (one less item 8-1=7 ;)).

Also, all the construct lines after the item you have just deleted need to be renumbered so they remain sequential. Here is the code changed after the item has been removed.

const/4 v1, 0x[COLOR="Red"]3[/COLOR]

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

aput-object v2, v0, v1

const/4 v1, 0x[COLOR="Red"]4[/COLOR]

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

aput-object v2, v0, v1

const/4 v1, 0x[COLOR="Red"]5[/COLOR]

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, 0x[COLOR="Red"]6[/COLOR]

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

aput-object v2, v0, v1

Credits: Huge credits to [MENTION=1167171]rompnit[/MENTION] for the use of the Screenshot method for this mod.