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

Search This thread

Br1cK'd

Inactive Recognized Developer
Sep 23, 2010
2,402
1,840
Colorado
Just to clarify, this is your edited public.xml?

As far as I can tell, it should be the same identifier as you posted in the error, 0x010803d6, thats the next available identifier for the type drawable. The one you posted has 0x01080493 as the value, but try the 803d6 value, that shold be the right one.

Try it again, being sure to take your time. If you are getting frustrated, it never hurts to walk away from it for a little while to let your brain refresh.
 
  • Like
Reactions: serendipityguy

Br1cK'd

Inactive Recognized Developer
Sep 23, 2010
2,402
1,840
Colorado
Sorry man, my day got seriously busy at work.

I have ported this to GB, I know it works if you're following the steps to the letter. If you're looping at boot, something is wrong for sure. I recommend trying the mod again, from scratch, and following the steps to the letter.
 

Br1cK'd

Inactive Recognized Developer
Sep 23, 2010
2,402
1,840
Colorado
I have tryed some 3 a 4 times but I do something wrong thats why I ask for someone to take a look for this maybe someone knows wat I do wrong.

I see one big problem right off the bat, you skipped step 2, or got confused. This may explain why you didn't find the "invoke-static {}, Landroid/os/Power;->shutdown()V" string.

In step two of the OP, you are supposed to decompile the framework.jar to add those edits. The zip you posted only contains the android.policy.jar and the framework-res.apk, that leads me to believe you missed the entire step two of the OP.

Hope this helps.
 
Last edited:

Br1cK'd

Inactive Recognized Developer
Sep 23, 2010
2,402
1,840
Colorado
If you're following their method, maybe you should ask for help in that thread. I know this works for the Vibrant if you follow the steps in this thread's OP, I'm not sure about the other method you posted.

If you're trying to blend the two methods, that might be your problem.

You should stick with the method that is for your phone, whichever device you have.



EDIT - Also, there is a problem with your android-policy.jar you posted, seems to have gone corrupt. I cannot even open it to drag out the classes.dex. I did redownload the file, but the problem persists.
 
Last edited:

Br1cK'd

Inactive Recognized Developer
Sep 23, 2010
2,402
1,840
Colorado
Look dude, I am reading, and I'm trying to help you, but the android.policy you posted is borked, it won't decompile on either my home or work pcs. Thats probably your problem with the reboots, is that somehow you managed to completely break the android.policy you were editing.

I got nothin else in reference to your files man, if I can't look at what you tried to do, I can't help. Simple as that.

I don't know how you were decompiling the android.policy, but you may want to follow the steps in post 2 of the linked thread, even use the attached autosmali that jellette put together, to help you work with the classes.dex in your android.policy. This will work for the framework.jar as well, any .jar file for that matter can use the same steps to classout the classes.dex, and put it back together after editing.

http://xdaforums.com/showthread.php?t=998574
 

toadlife

Inactive Recognized Developer
Aug 19, 2008
1,208
1,012
Lemoore, CA
Thank you so much for taking the time to write out this guide. After several failures (the code for my phone is significant differences from the examples!) I was finally able to mod my power menu on my Epic 4G.
 

Br1cK'd

Inactive Recognized Developer
Sep 23, 2010
2,402
1,840
Colorado
I try dis weekend again and try something else I come back later with my new trying hihi..


Thanks for helping me so far!!



Verzonden via Tapatalk.


Files I can decompile, that is a good thing, now I can be helpful, I think. :p

Your framework.jar and framework-res.apk look great, but in the android.policy.jar there are a few problems.

Since you are only adding reboot to the menu, you only need parts of the code to edit your smalis. In the first step in the android.policy, you have added calls for all 6 entries that would be present is you did the full mod.

So in the code, where you change "const/4 v0, 0x3" to "const/4 v0, 0x6" as per the OP and whats in your edited files, you really only need to put const/4 v0, 0x4" (that would mean four total entries on your power menu in that string)

How many GlobalActions$ smalis are in your stock android.policy.jar before you edit it?

Better yet, can you post your stock android.policy.jar for me to compare? I might be able to edit it for you real quick.

EDIT - It also looks like you missed a part of the third step, and didn't create the GlobalActions$9 smali that your code is calling for, try the attached android.policy, I edited it for you, and let me know if it works.
 

Attachments

  • android.policy.jar
    134.4 KB · Views: 6
Last edited:

Br1cK'd

Inactive Recognized Developer
Sep 23, 2010
2,402
1,840
Colorado
Hai,

I gif some answers on your question!


how manny GlobalActions$ smalis are in your stock android.policy.jar before you edit it?
I had 7 GlobalActions$ smalis

It also looks like you missed a part of the third step!
Yes I thought that I only need the GlobalActions$8 and that 9 and 10 was for Download Mode and Recovery Mode so my mistake.


I have Flashed the MOD again with your android.policy.jar and it's not working so I send you the original android.policy.jar so mabye you can edit this good for me.


Thanks!


I'll give it a run with this stock file. Although you cleared up some confusion I was having. When you referenced the resource ids in the GlobalActions.smali, you referenced them to GlobalActions$9 which does not exist in your edited android.policy.
 
  • Like
Reactions: AndroiDer

Br1cK'd

Inactive Recognized Developer
Sep 23, 2010
2,402
1,840
Colorado
Here you go, this is the edited from the stock file you posted earlier. Flash it with your other framework files, it should work.

*crosses fingers*
 

Attachments

  • android.policy.jar
    134.3 KB · Views: 22
  • Like
Reactions: AndroiDer

x-dira

Senior Member
Nov 6, 2011
436
126
how to convert deodex to odex?
I need convert android.policy.jar to android.policy.jar+android.policy.odex .....flash in stock rom
sory! my english so bad :(
thanks very much!
 

lingfude

Senior Member
Jun 22, 2011
591
569
Aveiro
dmec-reviews.blogspot.pt
how to convert deodex to odex?
I need convert android.policy.jar to android.policy.jar+android.policy.odex .....flash in stock rom
sory! my english so bad :(
thanks very much!

Follow this instructions (http://xdaforums.com/showthread.php?t=841287):

Yeah, it took me a week of digging to find this answer.

Disclaimer:

1. Proceed at your own risk and don't blame me if you brick your phone.
2. While I've done my best to document the steps I took, there's always a chance I've mistyped something.
3. If you're unsure at any point, STOP! Re-read everything so you fully understand what you're doing.
4. Editing .odex files can be extremely tricky! All it takes is a bad edit to royally screw up your phone.

This guide assumes:

* you have a Captivate and it's running stock Eclair. (Don't know about other phones or other OSes.)
* you have rooted your phone, and have busybox & Superuser Permissions installed.
* you have adb installed and working on a PC.
* you have baksmali and smali installed and working on a PC (along with Java).
* you have downloaded the utility "dexopt-wrapper". (Do a search - you'll find it.)
* you know what the BOOTCLASSPATH value is for your phone. (Hint: It's in /init.rc)
* you have made a complete backup of your phone! (Yes, if something goes wrong, it's much nicer to be able to restore files from a recent backup than to have to wipe the phone and start from scratch again.)
- I highly recommend you install ROM Manager w/ ClockworkMod. (And don't delete /sdcard/update.zip)

Notations:
When you see a line beginning with >, that's a command to be executed on the PC.
When you see a line beginning with #, that's a command to be executed on the phone.

Ready? Here we go:

put the dexopt-wrapper onto your phone.
> adb push dexopt-wrapper /sdcard

copy all of the /system/framework files onto your PC.
> adb pull /system/framework

let's pretend you want to change something in services.odex.

decompile the .odex file
> baksmali -x services.odex -o services.out

now edit whatever .smali file you want in the services.out folder.

rebuild the classes.dex file for services.odex.
> smali -o classes.dex services.out

now put classes.dex into services.jar (I used WinRAR, but other ZIP utilities should work.)

put the new .jar file onto your phone.
> adb push services.jar /sdcard

> adb shell

become super user
# su

put the dexopt-wrapper utility into the bin folder with the correct permissions. (you only need to do this once, obviously.)
# cd /system/bin
# busybox cp /sdcard/dexopt-wrapper .
# busybox chmod 755 dexopt-wrapper

# cd /sdcard

create a new .odex file from the new .jar file
# dexopt-wrapper services.jar new.odex [BOOTCLASSPATH]
yes, fill in the value of BOOTCLASSPATH, without the []

here's the "special sauce": copy over the "signature" from the current .odex file into the new .odex file. do NOT continue until this command succeeds!
hint: the file size of the new.odex file should not change!
# busybox dd if=/system/framework/services.odex of=new.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

now replace the old .odex file with the new .odex file.
# cd /system/framework
# busybox cp /sdcard/new.odex services.odex
# busybox chmod 644 services.odex

and you're done.
# sync
# reboot

Now, if all goes well, your phone should reboot normally.

However, if something has not gone well, you'll hear the bootup sounds, but the screen will be "stuck" on the first white logo screen. That means the new .odex file was not accepted. What to do? Well, first, (and with all do respect) Don't Panic! Plug in the USB line and issue:

> adb reboot recovery

That should drop you into the recovery. "Apply Updates" and that will get you into ClockworkMod. Then you can restore the /system files from your full backup (the one you did RIGHT BEFORE doing any of this, right?) and be back up and running in just a few minutes. (Yeah, I had to do this many times. It's scary the first time, but you get use to it after a while.)

Good luck!
 
  • Like
Reactions: x-dira

klin1344

Senior Member
Nov 11, 2011
3,486
5,611
Thanks for the guide :D
this was my first time smali editing so I was very skeptical that it wouldn't work.
But it turns out I got it to work!
 

DarkNiz

Senior Member
Mar 18, 2010
305
24
Cape Town
How does one edit framework.jar on an odexed ROM? If I open it with 7zip, all I see is a META-INF folder with MANIFEST.MF inside and outside the folder, all I see is a "preloaded-classes" file :confused:
 

jeboo

Recognized Developer
Apr 2, 2010
817
4,059
Update for ICS 4.0.3

This is one of my favorite mods, so it seems only appropriate to provide an updated guide for ICS. I won't rewrite the original post, but instead will point out changes in structures/code for each of the 3 "steps." This is based on LP3 for the Galaxy S2 btw.

Step 1.

The only change here is that we no longer need to allocate any resources for "reboot" since samsung has added it.

Step 2.

In ShutdownThread.smali, we NEED TO CHANGE our variable mReboot to mRecovery (Samsung added their own mReboot). Be sure to adjust any references to mReboot in the rest of the code we add!! Now, we will adjust the code inserted before Landroid/os/Power;->shutdown()V:

Code:
sget v1, Lcom/android/internal/app/ShutdownThread;->mRecovery:I
	
const/4 v2, 0x1
	
if-eq v1, v2, :rebootRecovery
	
const/4 v2, 0x2
	
if-eq v1, v2, :rebootDownload

Do note that recovery and d/l are now assigned 1, 2, respectively.

You also want to delete this fragment of code as well:
Code:
:reboot
	
const-string v4, "now"
	
invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void

Step 3.

This is where the patch becomes a bit more involved, as the structures have changed a bit.

In GlobalActions.smali, we will add two new variables at the top of the smali:
Code:
.field private mRecovery:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

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

Now find:
iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
and the following code will go directly after that line:
Code:
new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$15;

    const v1, 0x10807d0 # recov icon resource id

    const v2, 0x104064f # recov string resource id 

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

    const v1, 0x10807d1 # dl icon resource id

    const v2, 0x1040650 # dl string resource id

    invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$16;-><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;
NOTE the resource/string IDs..If you mess that up or forget, you will get reboots! Also note that the globalactions$15/16 may vary depending on your base firmware.

Just below the code you just pasted, you will see the array size line const/4 v0, 0x6. Change it to:
Code:
const/16 v0, 0x8

Below that line you will see the array filled with the various functions, so we want to insert our 2 new functions just before
invoke-static {v0}, Lcom/google/android/collect/Lists;->newArrayList
Code:
    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;->mDownload:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

    aput-object v2, v0, v1

And that's all for GlobalActions.smali. Lastly, you want to create GlobalActions$15 & 16 based upon the proper singlepress template (for LP3, it was GlobalActions$5). And don't forget when you make the changes within those 2 files, to adjust the const/4 v2, 0x2/3 to 1/2.

Read over the OP a few times then follow this, and it should work out :)
 
Last edited:

acocalypso

Senior Member
Feb 7, 2011
491
254
this is my createDialog method, i cant find new-array or something like that to change it. Can someone help me?

Code:
.method private createDialog()Landroid/app/AlertDialog;
    .locals 10

    .prologue
    const/4 v9, 0x1

    .line 118
    new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$SilentModeAction;

    iget-object v1, p0, Lcom/android/internal/policy/impl/GlobalActions;->mAudioManager:Landroid/media/AudioManager;

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

    invoke-direct {v0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$SilentModeAction;-><init>(Landroid/media/AudioManager;Landroid/os/Handler;)V

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

    .line 120
    new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$1;

    const v2, 0x10802e2

    const v3, 0x10802e3

    const v4, 0x1040159

    const v5, 0x104015a

    const v6, 0x104015b

    move-object v1, p0

    invoke-direct/range {v0 .. v6}, Lcom/android/internal/policy/impl/GlobalActions$1;-><init>(Lcom/android/internal/policy/impl/GlobalActions;IIIII)V

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

    .line 160
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

    .line 163
    iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

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

    const v2, 0x1080030

    const v3, 0x1040155

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

    invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

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

    const v2, 0x10807f5

    const v3, 0x104051b

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

    invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 183
    iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

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

    invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 187
    iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

    iget-object v1, p0, Lcom/android/internal/policy/impl/GlobalActions;->mSilentModeAction:Lcom/android/internal/policy/impl/GlobalActions$SilentModeAction;

    invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 190
    new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$MyAdapter;

    const/4 v1, 0x0

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

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

    .line 192
    new-instance v7, Landroid/app/AlertDialog$Builder;

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

    invoke-direct {v7, v0}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    .line 194
    .local v7, ab:Landroid/app/AlertDialog$Builder;
    iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mAdapter:Lcom/android/internal/policy/impl/GlobalActions$MyAdapter;

    invoke-virtual {v7, v0, p0}, Landroid/app/AlertDialog$Builder;->setAdapter(Landroid/widget/ListAdapter;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    move-result-object v0

    invoke-virtual {v0, v9}, Landroid/app/AlertDialog$Builder;->setInverseBackgroundForced(Z)Landroid/app/AlertDialog$Builder;

    .line 197
    invoke-virtual {v7}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

    move-result-object v8

    .line 198
    .local v8, dialog:Landroid/app/AlertDialog;
    invoke-virtual {v8}, Landroid/app/AlertDialog;->getListView()Landroid/widget/ListView;

    move-result-object v0

    invoke-virtual {v0, v9}, Landroid/widget/ListView;->setItemsCanFocus(Z)V

    .line 199
    invoke-virtual {v8}, Landroid/app/AlertDialog;->getWindow()Landroid/view/Window;

    move-result-object v0

    const/16 v1, 0x7d8

    invoke-virtual {v0, v1}, Landroid/view/Window;->setType(I)V

    .line 201
    invoke-virtual {v8, p0}, Landroid/app/AlertDialog;->setOnDismissListener(Landroid/content/DialogInterface$OnDismissListener;)V

    .line 203
    return-object v8
.end method
 
Last edited:

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.