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
<string name="reboot_recovery">Recovery</string> <string name="reboot_download">Download</string> <string name="reboot">Reboot</string>
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.
<public type="string" name="reboot_recovery" id="0x010403c3" /> <public type="string" name="reboot_download" id="0x010403c4" /> <public type="string" name="reboot" id="0x010403c5" />
"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
<public type="drawable" name="reboot" id="0x010803aa" /> <public type="drawable" name="recovery" id="0x010803ab" /> <public type="drawable" name="download" id="0x010803ac" />
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
.field public static mReboot:I
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
.line 531 invoke-static {}, Landroid/os/Power;->shutdown()V .line 532 return-void
: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
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.sm ali"
the first thing that we need to do is increase the array length by 3
so in method createDialog on line 431 change this
const/4 v0, 0x3 new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
const/4 v0, 0x6 new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
to framework-res com into play so on line 457 after "aput-object v2, v0, v1"
add this 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
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"
const/4 v2, 0x1 sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
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"
const/4 v2, 0x2 sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
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"
const/4 v2, 0x3 sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
compile android.policy
done test on the phone.
flash the attached update.zip with the stock updater.