Post Reply

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

OP sicopat

15th July 2011, 12:16 AM   |  #1  
sicopat's Avatar
OP Senior Member
Thanks Meter: 947
 
789 posts
Join Date:Joined: Oct 2007
Donate to Me
More
[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 :
Quote:

Okarin
untermensch
PaoloM70




warnings :
Quote:

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

Quote:

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

framework res.apk
android.policy.jar

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

"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:
Code:
    <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 :
Code:
    <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 :
Code:
    <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 "
Code:
invoke-static {v0}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;
" and insert just above:

Code:
    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 :
Code:
    const/4 v1, 0x1

    invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V
With :
Code:
    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
and
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
and
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:

Last edited by sicopat; 9th August 2011 at 10:44 AM.
The Following 110 Users Say Thank You to sicopat For This Useful Post: [ View ]
15th July 2011, 12:42 AM   |  #2  
Senior Member
Thanks Meter: 45
 
470 posts
Join Date:Joined: May 2009
Thanks you! finally someone willing to write a tutorial on this.
15th July 2011, 01:20 AM   |  #3  
smaberg's Avatar
Recognized Developer
Thanks Meter: 920
 
2,339 posts
Join Date:Joined: Mar 2007
Donate to Me
More
great tutorial.

thanx, we all need help sometimes
The Following User Says Thank You to smaberg For This Useful Post: [ View ]
sileshnair
15th July 2011, 01:27 AM   |  #4  
Guest
Thanks Meter: 0
 
n/a posts
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
Senior Moderator / Recognized Developer - The Android Surgeon
Thanks Meter: 3,744
 
3,098 posts
Join Date:Joined: Jun 2006
Donate to Me
More
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: 30
 
136 posts
Join Date:Joined: Jun 2008
More
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.
Last edited by NitroOnTheRocks; 15th July 2011 at 03:12 AM.
15th July 2011, 03:42 AM   |  #7  
designgears's Avatar
Recognized Developer
Flag SLC
Thanks Meter: 8,681
 
4,876 posts
Join Date:Joined: Feb 2010
Donate to Me
More
No credit for the how to you copied this from?

what a shame

http://forum.xda-developers.com/showthread.php?t=811532
The Following User Says Thank You to designgears For This Useful Post: [ View ]
15th July 2011, 05:38 AM   |  #8  
_JKay_'s Avatar
Recognized Developer
Thanks Meter: 14,819
 
5,488 posts
Join Date:Joined: Aug 2010
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: 95
 
605 posts
Join Date:Joined: Nov 2010
More
Quote:
Originally Posted by designgears

No credit for the how to you copied this from?

what a shame

http://forum.xda-developers.com/showthread.php?t=811532

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  
Member
Thanks Meter: 24
 
75 posts
Join Date:Joined: Dec 2010
Quote:
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?

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Galaxy S II Themes and Apps by ThreadRank