[HOW TO][Gingerbread] Adding Reboot option to Power Menu

Search This thread

projectmax

Member
Jan 3, 2013
39
2
Here is a tutorial with screenshots on how to add the reboot option to the power menu for the Defy.


3. Next we need to modify Defy's shutdown method to accept 1 more option .
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 25

Code:
.field public static mReboot:I

Screenshot :

screenshot4km.jpg


Then at line 545 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

Then after this code on about line 555

invoke-static {}, Landroid/os/Power;->shutdown()V

.line 512
return-void


Add this code

Code:
:reboot
      const-string v4, "now"

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

      return-void

Screenshot :

screenshot9bw.jpg


Save and close

Compile framework

mods/devs, please help me on adding reboot, recovery and download in the power menu..my phone is an alcatel ot-918N running on stock 2.3.6 gingerbread. The problem I am having is in the shutdownThread.xml, I can't find the code in the post above, it seems that I have a different codes in the shutdownThread. can you please help me on adding the 3 options in my power menu..thanks so much..

here's my shutdownThread file..
shutdownThread.xml
 

rushic24

Member
Apr 21, 2012
44
6
In defys shutdown method i cannot find com folder in decompiled framework-res.apk

Or which framework are u talking about

Sent from my GT-S6802 using Tapatalk 2
 

rushic24

Member
Apr 21, 2012
44
6
I got it its framework.dex :)

Sent from my GT-S6802 using Tapatalk 2

---------- Post added at 01:22 PM ---------- Previous post was at 01:17 PM ----------

I decompiled the android.policy it
already contains GlobalAction$10.smali shall i overwrite it ?
After overwriting it gives some error in compiling plz help

Sent from my GT-S6802 using Tapatalk 2

---------- Post added at 01:29 PM ---------- Previous post was at 01:22 PM ----------

attaching android.policy.dex
Please mod this

http://www.mediafire.com/?290dst9uc7gflch

Sent from my GT-S6802 using Tapatalk 2
 
Last edited:

iZLeeP

Senior Member
Jan 23, 2014
528
151
Manila
mods/devs, please help me on adding reboot, recovery and download in the power menu..my phone is an alcatel ot-918N running on stock 2.3.6 gingerbread. The problem I am having is in the shutdownThread.xml, I can't find the code in the post above, it seems that I have a different codes in the shutdownThread. can you please help me on adding the 3 options in my power menu..thanks so much..

here's my shutdownThread file..
shutdownThread.xml

Have you found the solution to your question. We have the same smali file and I am stuck at this point as well.
 

DroidBot

Senior Member
Apr 7, 2013
421
231
Mumbai
OT... but a worth question.
Does anybody know, how to get expanded notification on gingerbread rom. please reply asap if anybody knows the solution.
Thanks in advance.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 24
    Here is a tutorial with screenshots on how to add the reboot option to the power menu for the Defy.

    This is not my work .It is a rewrite of this thread modified for use on the Defy .

    For this operation you will need :

    1. APK Manager

    2. smali/baksmali or use the one attached .

    3. Notepad++

    In this tutorial we are going to modify these files :framework-res.apk,frmework.jar ,android.policy.jar .
    You require knowledge of decompiling/recompiling apk and jar files ,and some basic text editing (.xml and .smali)

    For this example I'm using the 4.5.1-134-DFP-132 rom ,but this should work on any Gingerbread rom ???

    Ok,let's start.

    1. We need to add this line to your build.prop file or the whole thing will not work :

    Code:
    ro.mot.deep.sleep.supported=true

    Screenshot :

    screenshot17ul.jpg


    2. Next we need to add the resources to framework-res.apk .Decompile the framework-res.apk file.
    In the project folder open "framework-res.apk\res\values\strings.xml" and add your string resources .

    Code:
    <string name="reboot">Reboot</string>

    Screenshot :

    screenshot16n.jpg


    save and close

    Now open "framework-res.apk\res\drawable-hdpi" and add an image that will be shown next to the reboot string in the power menu .
    Name the image "ic_lock_reboot.png".

    Screenshot :

    screenshot1wt.jpg


    Recompile the framework-res.apk .This will create an unsignedframework-res.apk file in the "place-apk-here-for-modding" folder.
    Decompile the unsignedframework-res.apk file and open "unsignedframework-res.apk\res\values\public.xml"
    Find your image and string id's and write them down .

    Screenshot :

    screenshot6ry.jpg


    screenshot5uq.jpg


    3. Next we need to modify Defy's shutdown method to accept 1 more option .
    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 25

    Code:
    .field public static mReboot:I

    Screenshot :

    screenshot4km.jpg


    Then at line 545 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

    Then after this code on about line 555

    invoke-static {}, Landroid/os/Power;->shutdown()V

    .line 512
    return-void


    Add this code

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

    Screenshot :

    screenshot9bw.jpg


    Save and close

    Compile framework

    4. 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 1 so in method createDialog on line 628 change this :

    Code:
    const/4 v0, 0x[COLOR="Red"]4[/COLOR]
    
          new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;

    To this :

    Code:
    const/4 v0, 0x[COLOR="Red"]5[/COLOR]
    
          new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;

    Screenshot :

    screenshot10pd.jpg


    Now add the new menu items this is where the resource id's that we added to framework-res.apk com into play.
    So on line 658 after "aput-object v1, v0, v12" add this code :

    Code:
    const/4 v1, 0x4
    
          new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$10;
    
          const v3, [COLOR="Red"]0x108045c[/COLOR]
    
          const v4, [COLOR="Red"]0x10404fc[/COLOR]
    
          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

    Screenshot :

    screenshot11ws.jpg


    Make sure to change the resource id's to match what you added to to framework-res.apk .

    Save and close .

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

    Copy GlobalActions$5.smali and name it GlobalActions$10.smali open GlobalActions$10 and replace all instances of GlobalActions$5
    with GlobalActions$10 then add this code to line 54 before
    "invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V"

    Code:
    const/4 p0, 0x1
    
          sput p0, Lcom/android/internal/app/ShutdownThread;->mReboot:I

    Screenshot :

    screenshot13t.jpg


    Save and close

    Compile android.policy

    Done.

    Now you can test it on the phone.
    2
    @spear ... it's 4.5.1-134_DFP-231

    Here you go. Flash via CWM.
    2
    I notice that you also added 1% battery steps to that nandroid. Could you explain how to do that? I've got a theme which has 1% steps for the battery icon (cooked at the UOT Kitchen), but the phone still only displays 10% steps.

    My phone has GB 2.3.4, build 4.5.1-134_DFP-82 as standard. I'm a bit wary about flashing a whole new build at this early stage but I'd be happy to flash an update just for 1% battery steps.

    Here is a How-To

    http://xdaforums.com/showpost.php?p=13784360&postcount=54
    2
    Can you send me just your file services.jar for compare with my file please? Thanks

    Here you go .From 4.5.1-134_DFP-132 rom
    1
    Of course it's easier :D,but some of us here like to know how it is done .;)
    Furthermore it's not just for this specific rom .I belive it can be applied to all gingerbread roms (didn't try it on all ,maybe the line numbers and resources don't match ,but the principle is the same ).

    Guess the title is a bit confusing .Changing it.:rolleyes: