Adding Reboot Button on Power Menu S5660DXKT8 (Developer Only)

Overview

After trying to work especial on my Samsung Galaxy Gio display, Now i will try to make modifications to the power menu. Power menu will appear when you press the power button at the top right side of your smartphone. When was i use cyanogenMod 7.2 in the power menu available  button to reboot. it is very easy for us when we will just reboot our smartphone. My mission is I want to modify the stock rom to my liking, if I want to be able to look like the stock rom Ice Cream Sandwich view, but according to my version. here I am still learning based tutorial on the internet so if you want to learn to modify your android, let's learn together. I will try to detailing every step that should be done.

What do you need ?

  1. APKTOOL [http://code.google.com/p/android-apktool/]

    This tool will allow you to decompile and compile all apk', When you decompile an apk, you can now edit the xml's.
  2. ADB [http://developer.android.com/guide/developing/tools/adb.html]

    Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. You will be able to push, replace, delete, overwrite files directly from your computer to your android device.
  3. SMALI/BAKSMALI [http://code.google.com/p/smali/]

    assembler/disassembler for Android's dex format.
  4. 7-ZIP [http://www.7-zip.org/]

    An open source file archiver with a high compression ratio.

    Results

    button-modding

    How to do

    1. First thing you must to do is pull all file that need to make this mod. this all file place on /system/framework/
      • framework.jar
      • android.policy.jar
      • framework-res.apk 

      place that 3 files on folder named Original, you can restore from this folder if anything goes wrong.
    2. Edit framework-res.apk first this step is very easy.
      • decompile framework-res.apk
      • navigate to framework-res/res/values
      • edit string.xml
      • <string name="reboot_recovery">Recovery</string>
        <string name="reboot_download">Download</string>
        <string name="reboot">Reboot</string>
      • Edit public.xml
      • <public type="string" name="reboot_recovery" id="0x010403c3" />
        <public type="string" name="reboot_download" id="0x010403c4" />
        <public type="string" name="reboot" id="0x010403c5" />
        <public type="drawable" name="reboot" id="0x010803aa" />
        <public type="drawable" name="recovery" id="0x010803ab" />
        <public type="drawable" name="download" id="0x010803ac" />
      • you must use unuse id, or the easy way is replace the last APKTOOL_DUMMY with your's. Save, Close and Compile your framework-res.apk join it with your original framework-res.apk but remember not to replace but copy your's original framework-res.apk
    3. Now we must modify shutdown method so it accept our new 3 method. this step a little harder, it need to modify framework.jar file
      • decompile framework.jar using baksmail tool.
      • navigate to out/com/android/internal/app
      • edit ShutdownThread.smali add below text before .field private static mReboot:Z or maybe you can add it on line 29
      • .field public static mReboot:I
      • find invoke-static {v4, v2}, Landoid/util/log;->i(Ljava/lang/String;Ljava/lang/String;)I add below after above text or maybe you can add it on line 792
      • 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
      • find .line 599 add below before it or maybe you can add it on line 812
      • :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 all change, compile with smali and merge the change to original framework.jar, remember to copy the original don't replace it.
    4. Now we going to add an extra option to power menu, to do it we must modify android.policy.jar
      • decompile android.policy.jar with baksmali tool
      • navigate to out/com/android/internal/policy/impl
      • open GlobalActions.smali find this text mAirplaneModeOn:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction; pay attention on below text find new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$4; on my file it GlobalActions$4 maybe in your's different so you must adjust it.
      • find on folder out/com/android/internal/policy/impl/GlobalActions$4.smali copy paste it 3 time and name it GlobalActions$8.smali, GlobalActions$9.smali, GlobalActions$10.smali
      • back to GlobalActions.smali find const/4 v0, 0x4 replace it with const/4 v0, 0x7
      • still on GlobalActions.smali find const/4 v1, 0x3 replace it with const/4 v1, 0x7 this make shutdown button located at the bottom of power menu
      • still on GlobalActions.smali find const/4 v1, 0x7, yes right this is the shutdown button that you edit on step above , add this text on above it or you can add it on line 799
      • const/4 v1, 0x3
        
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$8;
        
        const v3, 0x108042b # reboot icon resource id
        
        const v4, 0x1040512 # reboot 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, 0x4
        
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$9;
        
        const v3, 0x108042c # recovery icon resource id
        
        const v4, 0x1040510 # recovery 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
        
        const/4 v1, 0x5
        
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$10;
        
        const v3, 0x108042a # download icon resource id
        
        const v4, 0x1040511 # download string resource id
        
        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
      • Edit GlobalActions$8.smali find and replace GlobalActions$4 with GlobalActions$8  do this step with another GlobalActions$9.smali and GlobalActions$10.smali but with different number.
      • Edit GlobalActions$8.smali, GlobalActions$9.smali, and GlobalActions$10.smali find this text invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V  add below text or maybe you can add it on line 53

      • GlobalActions$8.smali
        const/4 v2, 0x1
         
        sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I

        GlobalActions$9.smali
        const/4 v2, 0x2
         
        sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I

        GlobalActions$10.smali
        const/4 v2, 0x3
         
        sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
      • Save all change, compile with smali and merge the change to original android.policy.jar, remember to copy the original don't replace it.
    5. Now you will have 3 mod file framework.jar, android.policy.jar and framework-res.apk. use adb command to flash it/copy it to your /system/framework folder
    6. hope this tutorial can help you and if you have problem you can ask me i will glad to help you.

    Download

    If you don't like  the progress and wanna the result then you can download it here : DXKT8-MOD-Restart
    your ROM must be stock rom with S5660DXKT8 baseband.
    password : andylah
    if you wanna apply this, you must be using adb command cause i don't know how to create flashable update.zip right now :)
    Adding Reboot Button on Power Menu S5660DXKT8 (Developer Only) | AS | 5