[REF] How to add Reboot to power menu (updated 10/21/2010)

Search This thread

untermensch

Senior Member
Apr 4, 2009
480
622
Portland
this is the final method that will add reboot,recovery and download options
to the power menu updated 10/21/2010

============================================================
Step 1.

the first thing we need to do is add string and image resources to framwork-res
for this example I am using a stock JI6 ROM your resource id's will be different
if on another ROM

use apk_manager to decompile framework-res

open "values\strings.xml" and add our string resources
Code:
<string name="reboot_recovery">Recovery</string>
<string name="reboot_download">Download</string>
<string name="reboot">Reboot</string>
save and close

open "values\public.xml" and assign our strings resource id's

scroll until you get to the end of the "<public type="string"" id list
note the id of the last string, in this example it is "10403c2" sometimes
the id's are out of order so search for "10403c2 + 1" or "10403c3"
if the next id is unused then we can start assigning id's to the strings
we added.
Code:
<public type="string" name="reboot_recovery" id="0x010403c3" />
<public type="string" name="reboot_download" id="0x010403c4" />
<public type="string" name="reboot" id="0x010403c5" />
now is a good time to add the image resources so add your icons to
"res\drawable-hdpi"
and assign id's to them the same way we did for the strings
in this example, using the example icons in the zip file I had
Code:
<public type="drawable" name="reboot" id="0x010803aa" />
<public type="drawable" name="recovery" id="0x010803ab" />
<public type="drawable" name="download" id="0x010803ac" />
save and close

now framework-res has the resources needed for this mod use
apk_manager to compile.

============================================================
Step 2.

next we need to modify Samsung's shutdown method to accept 3 more options
so decompile framework and open "com\android\internal\app\ShutdownThread.smali"

since we are going to pass an integer to ShutdownThread and then evaluate
that integer when the code runs we have to have a spot for the integer so
add this to line 37
Code:
.field public static mReboot:I
then in method run at line 1463 add this code before "invoke-static {}, Landroid/os/Power;->shutdown()V"
Code:
sget v1, Lcom/android/internal/app/ShutdownThread;->mReboot:I
	
const/4 v2, 0x1
	
if-eq v1, v2, :reboot
	
const/4 v2, 0x2
	
if-eq v1, v2, :rebootRecovery
	
const/4 v2, 0x3
	
if-eq v1, v2, :rebootDownload

then after this code on about line 1477
Code:
.line 531
invoke-static {}, Landroid/os/Power;->shutdown()V

.line 532
return-void
add this code
Code:
:reboot
	
const-string v4, "now"
	
invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void
	
:rebootRecovery
	
const-string v4, "recovery"
	
invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void
	
:rebootDownload
	
const-string v4, "download"
	
invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void
save and close

compile framework

============================================================
Step 3.

now we are going to add the extra options to the power menu

decompile android.policy

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

the first thing that we need to do is increase the array length by 3
so in method createDialog on line 431 change this
Code:
const/4 v0, 0x3

new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
to this
Code:
const/4 v0, 0x6

new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
now add the new menu items this is where the resource id's that we added
to framework-res com into play so on line 457 after "aput-object v2, v0, v1"
add this code
Code:
    const/4 v1, 0x3

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

    const v3, 0x10803aa # reboot icon resource id

    const v4, 0x10403c5 # reboot string resource id 

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

    aput-object v2, v0, v1

    const/4 v1, 0x4

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

    const v3, 0x10803ab # recovery icon resource id

    const v4, 0x10403c3 # recovery string resource id

    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, 0x10803ac # download icon resource id

    const v4, 0x10403c4 # download string resource id

    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

make sure to change the resource id's to match what you added to to framework-res

save and close

next add the code that runs when the menu item is pressed

copy GlobalActions$3.smali and name it GlobalActions$7.smali
open GlobalActions$7 and replace all instances of GlobalActions$3
with GlobalActions$7 then add this code to line 52 before
"invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V"
Code:
const/4 v2, 0x1
	
sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
save and close

copy GlobalActions$3.smali and name it GlobalActions$8.smali
open GlobalActions$8 and replace all instances of GlobalActions$3
with GlobalActions$8 then add this code to line 52 before
"invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V"
Code:
const/4 v2, 0x2
	
sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
save and close

copy GlobalActions$3.smali and name it GlobalActions$9.smali
open GlobalActions$9 and replace all instances of GlobalActions$3
with GlobalActions$9 then add this code to line 52 before
"invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V"
Code:
const/4 v2, 0x3
	
sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
save and close

compile android.policy

done test on the phone.

flash the attached update.zip with the stock updater.
 

Attachments

  • device.jpg
    device.jpg
    28 KB · Views: 22,142
  • JI6_stock.zip
    6.5 MB · Views: 5,535
  • JI6_deodex.zip
    6.4 MB · Views: 5,637
  • powermenu_final.zip
    22.8 KB · Views: 10,168
Last edited:

hyao

Member
Sep 29, 2010
19
0
where is policy file
how to decompile
i use ubuntu
thx

Sent from my SGH-T959 using XDA App
 

s0niqu3

Senior Member
Feb 23, 2005
718
391
someone asked for this so here it is.

decompile android.policy

make a copy of GlobalActions$3.smali and name it to GlobalActions$7.smali open GlobalActions$7.smali

and replace all instances of GlobalActions$3 with GlobalActions$7

replace method onPress with this

Code:
.method public onPress()V
    .registers 3

    const-string v0, "Reboot Now"

    invoke-static {v0}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

    return-void
.end method

save and close

now open GlobalActions.smali

and in method createDialog

the first thing that we need to do is increase the array length by 1 so find this
Code:
const/4 v0, 0x3

new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
and change to
Code:
const/4 v0, 0x4

new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
next we add the new menu item so on line 457 we add this next bit of code after "aput-object v2, v0, v1"
Code:
const/4 v1, 0x3 # position in the menu array

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

const v3, 0x1080030  # power icon

const v4, 0x10402af  # reboot string

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

aput-object v2, v0, v1
framework-res already has a string for reboot so no modifications are needed to framework-res

save and close then compile android.policy

Hi,

Thanks so much for this, absolutely fantastic work like always!

For anyone that doesn't know how to decompile/compile apk files search for either APK Manager, or smali/baksmali tutorial/help/etc., it should help you out greatly.

And for those that want a flashable .zip, well, here you go, BUT, I'm lazy, so it requires some conditions:

1) You use a rom based on JI6 that's fully deodexed
2) you have previously flashed (or your custom rom included) the epic/puzzle lockscreen mod (also from untermensch)
3) You disable voodoo (if you use it) prior to flashing since this zip attempts to wipe your dalvik-cache


That said, zip should flash fine from clockwork, and all it does is replace your android.policy.jar with one pre-modded for lockscreen & reboot option support, and it wipes your dalvik-cache since that's the safest thing to do after applying any mod, period.

Cheers, =)
 

Attachments

  • JI6_lockscreen_mod_REBOOT_menu_option.zip
    144.8 KB · Views: 1,778

Master™

Senior Member
Sep 24, 2010
3,250
1,230
Hi,

Thanks so much for this, absolutely fantastic work like always!

For anyone that doesn't know how to decompile/compile apk files search for either APK Manager, or smali/baksmali tutorial/help/etc., it should help you out greatly.

And for those that want a flashable .zip, well, here you go, BUT, I'm lazy, so it requires some conditions:

1) You use a rom based on JI6 that's fully deodexed
2) you have previously flashed (or your custom rom included) the epic/puzzle lockscreen mod (also from untermensch)
3) You disable voodoo (if you use it) prior to flashing since this zip attempts to wipe your dalvik-cache


That said, zip should flash fine from clockwork, and all it does is replace your android.policy.jar with one pre-modded for lockscreen & reboot option support, and it wipes your dalvik-cache since that's the safest thing to do after applying any mod, period.

Cheers, =)

I was just about to upload the zip... :(
Oh well, beat me to it
 

b0ricuaguerrero

Senior Member
Sep 30, 2007
510
166
brooklyn, N.Y
Hi,

Thanks so much for this, absolutely fantastic work like always!

For anyone that doesn't know how to decompile/compile apk files search for either APK Manager, or smali/baksmali tutorial/help/etc., it should help you out greatly.

And for those that want a flashable .zip, well, here you go, BUT, I'm lazy, so it requires some conditions:

1) You use a rom based on JI6 that's fully deodexed
2) you have previously flashed (or your custom rom included) the epic/puzzle lockscreen mod (also from untermensch)
3) You disable voodoo (if you use it) prior to flashing since this zip attempts to wipe your dalvik-cache


That said, zip should flash fine from clockwork, and all it does is replace your android.policy.jar with one pre-modded for lockscreen & reboot option support, and it wipes your dalvik-cache since that's the safest thing to do after applying any mod, period.

Cheers, =)
You sir are a gentleman and a scholar
 

ronin4740

Senior Member
Oct 22, 2007
508
68
Many thanks for the file!

...but because I'm lazy and if I'm reading the file poster's req's correctly her version requires I flash a lockscreen I don't currently have, would any Gentleman or Lady be kind enough to build a .zip file which will work on a Stock Vibrant JI6 install?

Thnx!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 70
    this is the final method that will add reboot,recovery and download options
    to the power menu updated 10/21/2010

    ============================================================
    Step 1.

    the first thing we need to do is add string and image resources to framwork-res
    for this example I am using a stock JI6 ROM your resource id's will be different
    if on another ROM

    use apk_manager to decompile framework-res

    open "values\strings.xml" and add our string resources
    Code:
    <string name="reboot_recovery">Recovery</string>
    <string name="reboot_download">Download</string>
    <string name="reboot">Reboot</string>
    save and close

    open "values\public.xml" and assign our strings resource id's

    scroll until you get to the end of the "<public type="string"" id list
    note the id of the last string, in this example it is "10403c2" sometimes
    the id's are out of order so search for "10403c2 + 1" or "10403c3"
    if the next id is unused then we can start assigning id's to the strings
    we added.
    Code:
    <public type="string" name="reboot_recovery" id="0x010403c3" />
    <public type="string" name="reboot_download" id="0x010403c4" />
    <public type="string" name="reboot" id="0x010403c5" />
    now is a good time to add the image resources so add your icons to
    "res\drawable-hdpi"
    and assign id's to them the same way we did for the strings
    in this example, using the example icons in the zip file I had
    Code:
    <public type="drawable" name="reboot" id="0x010803aa" />
    <public type="drawable" name="recovery" id="0x010803ab" />
    <public type="drawable" name="download" id="0x010803ac" />
    save and close

    now framework-res has the resources needed for this mod use
    apk_manager to compile.

    ============================================================
    Step 2.

    next we need to modify Samsung's shutdown method to accept 3 more options
    so decompile framework and open "com\android\internal\app\ShutdownThread.smali"

    since we are going to pass an integer to ShutdownThread and then evaluate
    that integer when the code runs we have to have a spot for the integer so
    add this to line 37
    Code:
    .field public static mReboot:I
    then in method run at line 1463 add this code before "invoke-static {}, Landroid/os/Power;->shutdown()V"
    Code:
    sget v1, Lcom/android/internal/app/ShutdownThread;->mReboot:I
    	
    const/4 v2, 0x1
    	
    if-eq v1, v2, :reboot
    	
    const/4 v2, 0x2
    	
    if-eq v1, v2, :rebootRecovery
    	
    const/4 v2, 0x3
    	
    if-eq v1, v2, :rebootDownload

    then after this code on about line 1477
    Code:
    .line 531
    invoke-static {}, Landroid/os/Power;->shutdown()V
    
    .line 532
    return-void
    add this code
    Code:
    :reboot
    	
    const-string v4, "now"
    	
    invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V
    
    return-void
    	
    :rebootRecovery
    	
    const-string v4, "recovery"
    	
    invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V
    
    return-void
    	
    :rebootDownload
    	
    const-string v4, "download"
    	
    invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V
    
    return-void
    save and close

    compile framework

    ============================================================
    Step 3.

    now we are going to add the extra options to the power menu

    decompile android.policy

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

    the first thing that we need to do is increase the array length by 3
    so in method createDialog on line 431 change this
    Code:
    const/4 v0, 0x3
    
    new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
    to this
    Code:
    const/4 v0, 0x6
    
    new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
    now add the new menu items this is where the resource id's that we added
    to framework-res com into play so on line 457 after "aput-object v2, v0, v1"
    add this code
    Code:
        const/4 v1, 0x3
    
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$7;
    
        const v3, 0x10803aa # reboot icon resource id
    
        const v4, 0x10403c5 # reboot string resource id 
    
        invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$7;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V
    
        aput-object v2, v0, v1
    
        const/4 v1, 0x4
    
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$8;
    
        const v3, 0x10803ab # recovery icon resource id
    
        const v4, 0x10403c3 # recovery string resource id
    
        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, 0x10803ac # download icon resource id
    
        const v4, 0x10403c4 # download string resource id
    
        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

    make sure to change the resource id's to match what you added to to framework-res

    save and close

    next add the code that runs when the menu item is pressed

    copy GlobalActions$3.smali and name it GlobalActions$7.smali
    open GlobalActions$7 and replace all instances of GlobalActions$3
    with GlobalActions$7 then add this code to line 52 before
    "invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V"
    Code:
    const/4 v2, 0x1
    	
    sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
    save and close

    copy GlobalActions$3.smali and name it GlobalActions$8.smali
    open GlobalActions$8 and replace all instances of GlobalActions$3
    with GlobalActions$8 then add this code to line 52 before
    "invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V"
    Code:
    const/4 v2, 0x2
    	
    sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
    save and close

    copy GlobalActions$3.smali and name it GlobalActions$9.smali
    open GlobalActions$9 and replace all instances of GlobalActions$3
    with GlobalActions$9 then add this code to line 52 before
    "invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V"
    Code:
    const/4 v2, 0x3
    	
    sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
    save and close

    compile android.policy

    done test on the phone.

    flash the attached update.zip with the stock updater.
    5
    someone asked for this so here it is.

    decompile android.policy

    make a copy of GlobalActions$3.smali and name it to GlobalActions$7.smali open GlobalActions$7.smali

    and replace all instances of GlobalActions$3 with GlobalActions$7

    replace method onPress with this

    Code:
    .method public onPress()V
        .registers 3
    
        const-string v0, "Reboot Now"
    
        invoke-static {v0}, Landroid/os/Power;->reboot(Ljava/lang/String;)V
    
        return-void
    .end method

    save and close

    now open GlobalActions.smali

    and in method createDialog

    the first thing that we need to do is increase the array length by 1 so find this
    Code:
    const/4 v0, 0x3
    
    new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
    and change to
    Code:
    const/4 v0, 0x4
    
    new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
    next we add the new menu item so on line 457 we add this next bit of code after "aput-object v2, v0, v1"
    Code:
    const/4 v1, 0x3 # position in the menu array
    
    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$7;
    
    const v3, 0x1080030  # power icon
    
    const v4, 0x10402af  # reboot string
    
    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$7;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V
    
    aput-object v2, v0, v1
    framework-res already has a string for reboot so no modifications are needed to framework-res

    save and close then compile android.policy

    Hi,

    Thanks so much for this, absolutely fantastic work like always!

    For anyone that doesn't know how to decompile/compile apk files search for either APK Manager, or smali/baksmali tutorial/help/etc., it should help you out greatly.

    And for those that want a flashable .zip, well, here you go, BUT, I'm lazy, so it requires some conditions:

    1) You use a rom based on JI6 that's fully deodexed
    2) you have previously flashed (or your custom rom included) the epic/puzzle lockscreen mod (also from untermensch)
    3) You disable voodoo (if you use it) prior to flashing since this zip attempts to wipe your dalvik-cache


    That said, zip should flash fine from clockwork, and all it does is replace your android.policy.jar with one pre-modded for lockscreen & reboot option support, and it wipes your dalvik-cache since that's the safest thing to do after applying any mod, period.

    Cheers, =)
    2
    Hate to be the one to burst your bubble. This tutorial hasn't applied to any firmware after GingerBread. From ICS and up, the google code changed, and these steps won't work. Sorry, wish I had better news for you.

    Edit - Come to think of it, these exact steps didn't work on GB either, eclipse and froyo with a TWIZ interface they did, but since then a lot of the code has changed.

    Give a man a fish and he will eat for a day, teach that same man to use Google Search, and he can answer his own questions for the rest of his life.
    2
    The 4 Way Reboot mod is a lot easier. A lot easier.The only modification for 4Way is to androidpolicy.jar. No edits or modifications to framework-res.apk at all. Told you it was easy. Lol. My 2¢ cent.

    http://xdaforums.com/showthread.php?p=24235582
    18d2487c-47df-0324.jpg
    18d2487c-47e8-1e3e.jpg


    Sent from my SAMSUNG-SGH-I717 using Tapatalk 2
    2
    no no no ,,

    check android policy ,,, totally different

    Code from OP
    Code:
    const/4 v1, 0x3
    
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$7;
    
        const v3, 0x10803aa # reboot icon resource id
    
        const v4, 0x10403c5 # reboot string resource id 
    
        invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$7;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V
    
        aput-object v2, v0, v1
    
        const/4 v1, 0x4
    
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$8;
    
        const v3, 0x10803ab # recovery icon resource id
    
        const v4, 0x10403c3 # recovery string resource id
    
        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, 0x10803ac # download icon resource id
    
        const v4, 0x10403c4 # download string resource id
    
        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

    Code I used in Gingerbread

    Code:
        const/4 v1, 0x4
    
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$8;
    
        const v3, 0x1080434
    
        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, 0x1080435
    
        const v4, 0x1040486
    
        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, 0x1080436
    
        const v4, 0x1040487
    
        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

    Everything shifted up one because there is an additional GlobalActions smali.