Remove All Ads from XDA

[HOW TO] Extended Power Menu with no header (reboot / download / recovery)

808 posts
Thanks Meter: 963
By sicopat, Senior Member on 15th July 2011, 12:16 AM
Post Reply Email Thread
[HOW TO] Extended Power Menu (reboot / download / recovery) with no header

This HOW TO is rewritten from a French tutorial (HERE) itself rewritten from a XDA tutorial (HERE, and modified using this other one : HERE

Thanks to :


warnings :

- This tutorial is for people who know what they will do, a mistake can fit your phone unusable so ...
- A modification of system files is always a delicate operation, pay attention and do not rush

Prerequisites :


First and foremost, you must master the decompilation / recompilation of APK and JAR using APK_Manager and smali/baksmali.

Mod the power menu :

Here is the way to add the options "Reboot", "Recovery" and "Download" to the Power menu (long press the power button)

For this part, we will work on 2 files:

framework res.apk

You can decompile the first with APK Manager, and the second with baksmali.

1/ framework-res.apk :

Extract it with APK_Manager (extracted in /project folder)

a/ Then, before going any further, you will have to find three new .PNG images to be displayed in the power menu, and name them :

"ic_lock_reboot.png" for reboot menu
"ic_lock_recovery.png" to enter recovery
"ic_lock_download.png" for download Mode

Place these 3 images in the : APK_Manager/project/framework-res.apk/res/drawable-hdpi
where you will find the other pictures already in the menu concerned.
It is easier for beginners to add customised icons (like for power off, silent or plane modes icons )after recompilation, using 7zip for example. .

b/ With NotePad + +, edit the file " res/values/strings.xml "
Go to the end of the file, and add before the last line "</resources>", the three lines:
    <string name="reboot_recovery">Recovery</string>
    <string name="reboot_download">Download</string>
    <string name="reboot">Reboot</string>
This should give you something like this:

c/ Save your file.

d/ Now you can recompile the file "framework-res.apk" with APK Manager.
Remember that this is an APK system and delete the "keep/resources.arsc", since we have modified an XML file.
You will have a your moded apk here : "place-apk-here-for-modding/unsignedframework-res.apk"

Warning: You should not have errors when you re-compil. don't forget to add 3 new icons;

e/ using APK-Manager, decompil "place-apk-here-for-modding/unsignedframework-res.apk".
*Go to res/values/public.xml and edit with Notepad ++
*public.xml is auto-generated from others modifications during APK_MANAGER re-compilation. 6 new lines have been added, with 6 new Hex numbers. You will need these numbers later ...
Look for :
    <public type="string" name="reboot" id="0x01040488" />
    <public type="string" name="reboot_recovery" id="0x01040489" />
    <public type="string" name="reboot_download" id="0x0104048a" />
and for :
    <public type="drawable" name="ic_lock_reboot" id="0x010803d2" />
    <public type="drawable" name="ic_lock_recovery" id="0x010803d3" />
    <public type="drawable" name="ic_lock_download" id="0x010803d4" />
f/ Now you just have to rename "place-apk-here-for-modding/unsignedframework-res.apk" to "framework-res.apk" and voila!

Edit : never sign a system File using APK_Manager.

Here is the first part ended.
A tip, try this file on your phone, if it restarts fine, then the mod is correct, otherwise you can start over
It is important to test step by step, because it lets you know exactly from witch file comes the error.

2/ Now, we attack the second file "android.policy.jar".

Once decompiled with baksmal, edit the "out/com/android/internal/policy/impl/GlobalActions.smali."
Caution: Do not confuse it with the file "GlobalActions$Action.Smali"

a/ Find the line ".method private createDialog()Landroid/app/AlertDialog;"
then a few lines below, replace "const/4 v9, 0x4" with "const/4 v9, 0x7".
This line indicates the number of menu entries of extinction, we move from 4 to 7 (3 mor entries). You should have this after the changes made:

b/ Then find the line "
invoke-static {v0}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;
" and insert just above:

    const/4 v1, 0x4

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

    const v3, 0x10803d2

    const v4, 0x1040488

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

    aput-object v2, v0, v1

    const/4 v1, 0x5

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

    const v3, 0x10803d3

    const v4, 0x1040489

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

    aput-object v2, v0, v1

    const/4 v1, 0x6

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

    const v3, 0x10803d4

    const v4, 0x104048a

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

    aput-object v2, v0, v1

You will notice in the code, the previous hex numbers generated. You have to modify the hex numbers quoted with the hex numbers you found in step 2 after decompilation of unsignedframework-res.apk

Warning in this code, the hex numbers have a 0 in less after the "0x" like : 0x1234567... and not 0x011234567 like in string.xml[/COLOR]...
Please not in the code you just added the GlobalActions$8, GlobalActions$9, GlobalActions$10 : you will add files .smali with same name later. If in your firmware GlobalActions$8 is already existing, then modify the "$X" to follow last used number

To help, here's what you should have:

3/ If you want to remove the header of the extended power menu, not having to scroll,

a/ search for ".method private prepareDialog()",
then look a few lines below, you should find "const v4, 0x104014a"
where This hexadecimal digit corresponds to the entry "<public type="string"name="global_actions" id="0x0104014a" /> in the "public.xml" file, which itself refers to the text of the menu in" string.xml " :

b/ find the corresponding hexadecimal number 0xXXXXX to the entry "<string name="config_tether_apndata" />" in the "string.xml" file. This entry has no text.
Now replace in "const v4, 0x104014a" with "const v4, 0xXXXXX," so it will not show anything in the power menu.

Save the file.

c/ Come on, we're almost there ...

Now copy the "out/com/android/internal/policy/impl/GlobalActions$4.Smali" to "out/com/android/internal/policy/impl/GlobalActions$8.Smali".
We choose #4 because it is one that contains the shutdown of the phone. We will rename it 8 because it's 8 in the next free issue ...
Remember this if ever in a future version of the files they are change.

d/ Now open the new file "out/com/android/internal/policy/impl/GlobalActions$8.Smali" and replace in, all occurrences of "\GlobalActions$4" with "\GlobalActions$8"

Then, Replace :
    const/4 v1, 0x1

    invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V
With :
    const/4 v1, 0x1
    const-string v2, "now"
    invoke-static {v0, v2, v1}, Lcom/android/internal/app/ShutdownThread;->reboot(Landroid/content/Context;Ljava/lang/String;Z)V

e/ Save the file and copy it to "out/com/android/internal/policy/impl/GlobalActions$9.Smali"
Open it and replace in, all occurrences of "\GlobalActions$8" with "\GlobalActions$9
const-string v2, "now" with const-string v2, "recovery"

f/ Save the file and copy it to "out/com/android/internal/policy/impl/GlobalActions$10.Smali"
Open it and replace in, all occurrences of "\GlobalActions$9" with "\GlobalActions$10
const-string v2, "recovery" with const-string v2, "download"

Save the file and then ... compile it all!

The result, you will see that I also forgot to replace an icon:

The Following 111 Users Say Thank You to sicopat For This Useful Post: [ View ] Gift sicopat Ad-Free
15th July 2011, 12:42 AM |#2  
Senior Member
Thanks Meter: 58
Thanks you! finally someone willing to write a tutorial on this.
15th July 2011, 01:20 AM |#3  
smaberg's Avatar
Inactive Recognized Developer
Thanks Meter: 959
Donate to Me
great tutorial.

thanx, we all need help sometimes
The Following User Says Thank You to smaberg For This Useful Post: [ View ] Gift smaberg Ad-Free
15th July 2011, 01:27 AM |#4  
Thanks Meter: 0
Excellent. Now for a tutorial on how to get the mobile data toggle in the notification bar and we can all build custom roms.

Sent from my GT-I9100 using Tapatalk
15th July 2011, 01:31 AM |#5  
D.O.C's Avatar
Inactive Recognized Developer / Retired Senior Moderator
Thanks Meter: 3,778
Donate to Me
Wow, u really went the whole 9 yards explaining this, thanks, as always grateful for ur sharing....
15th July 2011, 03:09 AM |#6  
NitroOnTheRocks's Avatar
Senior Member
Thanks Meter: 31
Seems like you put a lot of time and effort in this post.
Very good and clear instructions on something I wanted to add to my custom rom for a long time. (without just adding some files)
Thank you very much.
15th July 2011, 03:42 AM |#7  
designgears's Avatar
Inactive Recognized Developer
Flag SLC
Thanks Meter: 8,976
Donate to Me
No credit for the how to you copied this from?

what a shame
The Following User Says Thank You to designgears For This Useful Post: [ View ] Gift designgears Ad-Free
15th July 2011, 05:38 AM |#8  
_JKay_'s Avatar
Retired Recognized Developer
Thanks Meter: 14,807
Donate to Me
Nice guide. Two things when using apkmanager:

1) Never ever edit the public.xml
2) When Recompiling: Never sign system files. Copy their signature!

Sent from my GT-I9100 using XDA Premium App
15th July 2011, 06:37 AM |#9  
Hunteres's Avatar
Senior Member
Flag Dublin
Thanks Meter: 140
Originally Posted by designgears

No credit for the how to you copied this from?

what a shame

as Cognition user i can only agree with "my" developer, that most of the statings above are simply coppied - Ctrl+a--->Ctrl+V ---> well done
15th July 2011, 08:35 AM |#10  
Thanks Meter: 24
Originally Posted by _JKay_

Nice guide. Two things when using apkmanager:

1) Never ever edit the public.xml
2) When Recompiling: Never sign system files. Copy their signature!

Sent from my GT-I9100 using XDA Premium App

If we don't edit Public.xml, how are going to achieve this? I keep getting errors while recompiling using apkmanager? They sometimes don't even extract the resources.arsc and throw a lot of errors.
I'm working on adding a few options in the settings apk and neither apkmanger nor apktool is letting me decompile settings apk. It always throws errors. I need to decompile to edit a few xml in values which i don't find if i unzip it with 7-zip or winrar! Editing smali files is not a prob for now!
Any solutions?
15th July 2011, 08:38 AM |#11  
Thanks Meter: 24
@ sicopat
All three options call the Shutdown thread and present the "Your phone will shutdown" dialog. How do we change this?
And i also want to add the subtext in all three options in the main options, where are those located?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes