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



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 :

Okarin
untermensch
PaoloM70



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
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 :
"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 "", the three lines:

Code:
... string name="reboot_recovery">RecoveryReboot
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:



and for :


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;->(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;->(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;->(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 " 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 "" 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:

0 comments:

Post a Comment

Open Panel

Blogroll

counter