Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,804,151 Members 36,939 Now Online
XDA Developers Android and Mobile Development Forum

[TUTORIAL][JB/KK] how to add reboot , recovery and bootloader options in Power menu

Tip us?
 
sandy7
Old
(Last edited by sandy7; 28th July 2014 at 01:09 PM.)
#1  
sandy7's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 6,864
Posts: 6,187
Join Date: May 2012
Location: bangalore

 
DONATE TO ME
Tutorial [TUTORIAL][JB/KK] how to add reboot , recovery and bootloader options in Power menu

So lets Start

Required
1-apktool
2-notepad++
3-some brains







[CENTER]REBOOT OPTIONS KK 4.4.2

USE THE RESOURCES ATTACHED BELOW (IF U HAVE ANY PROBLEMS DE/RECOMPILING ANDROID.POLICY.JAR USE THE smali.jar and backsmali.jar attached in the below resources)

framework-res.apk
-----------------

1 - Add to strings.xml:
Code:
	<string name="reboot">@string/factorytest_reboot</string>
    <string name="reboot_normal">@string/factorytest_reboot</string>
	<string name="reboot_recovery">Recovery</string>
    <string name="reboot_bootloader">Bootloader</string>


2 - Add to arrays.xml:

Code:
	<string-array name="reboot_options">
        <item>@string/reboot_normal</item>
        <item>@string/reboot_recovery</item>
        <item>@string/reboot_bootloader</item>
    </string-array>
    <string-array name="reboot_actions">
        <item>now</item>
        <item>recovery</item>
        <item>bootloader</item>
    </string-array>

3 - Add under \res\drawable-xxhdpi\ folder:

ic_lock_reboot.png


4 - Compile framework-res.apk



android.policy.jar
------------------

1 - Edit:

\com\android\internal\policy\impl\GlobalActions.sm ali

...LOOK FOR...

Code:
	
	.line 252
    .local v9, "quickbootEnabled":Z
    :goto_3d
    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, 0x10400cb

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

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

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

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

    const v2, 0x108094c           ----- HEX ID OF ic_lock_reboot.png ( make sure to change the hex id comparing ur Public xml  )
    const v3, 0x10407e8          ----- HEX ID OF reboot STRING ( make sure to change the hex id comparing ur Public xml  )

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

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

    .line 283
    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
2 - Add these three new files:

GlobalActions$12$1.smali
GlobalActions$12$2.smali
GlobalActions$12.smali


3 - Done !!




FOR JB 4.3





Before u decompile anything see this Guide by @erorcun for how to compile a JB framework without bootloop..
http://forum.xda-developers.com/show....php?t=2321207



STEP-1

Decompile Framework-res.apk

goto to res/vlaues/arrays.xml

and add these lines at the end

Code:
    <string-array name="reboot_options">
        <item>@string/reboot_normal</item>
        <item>@string/reboot_recovery</item>
        <item>@string/reboot_bootloader</item>
    </string-array>
    <string-array name="reboot_actions">
        <item>now</item>
        <item>recovery</item>
        <item>bootloader</item>
    </string-array>

now goto res/values/strings
and add these lines at the end


Code:
    <string name="reboot">Reboot</string>
    <string name="reboot_normal">Reboot</string>
    <string name="reboot_recovery">Recovery</string>
    <string name="reboot_bootloader">Bootloader</string>

goto add the ic_lock_reboot.png which i have i provided in the resources attached below this post to drawablw-hdpi folder

so before compiling the framework-res.apk follow erorcun's guide to properly recompile framework-res.apk

once recompile is done ....decompile again to get the HEX ID's

STEP-2

decompile android.policy.jar

goto classout\com\android\internal\policy\impl

and add the 3 smali's files which i provided in the resources attached below

Now option classout\com\android\internal\policy\impl\GlobalAc tions.smali

and find these lines and add the red marked lines between them

Code:
    .line 235
    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, 0x10400fa

    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

    .line 213
    move-object/from16 v0, p0

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

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

    const v3, 0x1080827

    const v4, 0x104060b

    move-object/from16 v0, p0

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

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

    .line 260
    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

now we need to assign the Hex id's as per ur Public.xml

NOTE: the hex id's might be different from mine and yours so be careful while comparing

new as per the above changes in GlobalActions.xml

assign the id's as below

<public type="drawable" name="ic_lock_reboot" id="0x01080827" />

Code:
 new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$11;

    const v3, 0x1080827

<public type="string" name="reboot" id="0x0104060b" />

Code:
new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$11;

    const v3, 0x1080827

    const v4, 0x104060b


Now option up classout\com\android\internal\policy\impl\GlobalAc tions$11.smali

find and replace the following

@line 70
<public type="string" name="reboot" id="0x0104060b" />


Code:
const v3, 0x104060b

@line 90
<public type="array" name="reboot_options" id="0x0107003b" />


Code:
const v3, 0x107003b

@line 105
<public type="string" name="ok" id="0x0104000a" />



Code:
  const v2, 0x104000a

@line 147
<public type="bool" name="config_sf_slowBlur" id="0x0111000b" />


Code:
const v3, 0x111000b

now open up classout\com\android\internal\policy\impl\GlobalAc tions$11$2.smali

@line 59
<public type="array" name="reboot_actions" id="0x0107003c" />


Code:
const v2, 0x107003c

save it and recompile android.policy.jar


now push all the files into ut phone...will have the new Advanced reboot options


CREDITS

@serajr --- my smali teacher
@auras76 -- for testing this method will work or not
The Following 18 Users Say Thank You to sandy7 For This Useful Post: [ Click to Expand ]
 
sandy7
Old
#2  
sandy7's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 6,864
Posts: 6,187
Join Date: May 2012
Location: bangalore

 
DONATE TO ME
reserved
The Following User Says Thank You to sandy7 For This Useful Post: [ Click to Expand ]
 
sandy7
Old
#3  
sandy7's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 6,864
Posts: 6,187
Join Date: May 2012
Location: bangalore

 
DONATE TO ME
need this to
The Following User Says Thank You to sandy7 For This Useful Post: [ Click to Expand ]
 
serajr
Old
#4  
serajr's Avatar
Recognized Developer / Recognized Themer
Thanks Meter 9,683
Posts: 2,521
Join Date: Apr 2011
Location: Rafard - SP

 
DONATE TO ME
Default Congrats...

Anytime bro...
The Following User Says Thank You to serajr For This Useful Post: [ Click to Expand ]
 
Pangkoy08
Old
#5  
Pangkoy08's Avatar
Senior Member
Thanks Meter 159
Posts: 440
Join Date: Mar 2013
Location: Deep South
Default Inquiry...

I've tried and followed this instructions to a reboot to recovery.

I was able to recompile it after i've added the strings in strings.xml and the hdpi and xhdpi, However, when I decompiled it again to get the hex id it is giving me an error would you mind telling me what i've missed out?

Here is the log.

Decompiling "framework-res.apk"
With Tickle My Android
(tinyurl.com\ticklemyandroid)

----------------

I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Francis\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=sharedUserId, value=0x00000020
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Unknown Source)
at brut.androlib.res.util.ExtMXSerializer.writeAttrib uteValue(ExtMXSerializer.java:38)
at org.xmlpull.mxp1_serializer.MXSerializer.attribute (MXSerializer.java:673)
at org.xmlpull.v1.wrapper.classic.XmlSerializerDelega te.attribute(XmlSerializerDelegate.java:106)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializer Wrapper.writeStartTag(StaticXmlSerializerWrapper.j ava:267)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializer Wrapper.event(StaticXmlSerializerWrapper.java:211)
at brut.androlib.res.decoder.XmlPullStreamDecoder$1.e vent(XmlPullStreamDecoder.java:80)
at brut.androlib.res.decoder.XmlPullStreamDecoder.dec ode(XmlPullStreamDecoder.java:130)
at brut.androlib.res.decoder.XmlPullStreamDecoder.dec odeManifest(XmlPullStreamDecoder.java:144)
at brut.androlib.res.decoder.ResFileDecoder.decodeMan ifest(ResFileDecoder.java:131)
at brut.androlib.res.AndrolibResources.decode(Androli bResources.java:218)
at brut.androlib.Androlib.decodeResourcesFull(Androli b.java:115)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:11 4)
at brut.apktool.Main.cmdDecode(Main.java:146)
at brut.apktool.Main.main(Main.java:77)

----------------

Decompile Not Successful!

Thank you for your time. =)

IT DOESN'T HURT TO PRESS THANKS BUTTON FOR ANY APPRECIATION, IT GIVES US MOTIVATION TO DO MORE.

The Following User Says Thank You to Pangkoy08 For This Useful Post: [ Click to Expand ]
 
sandy7
Old
#6  
sandy7's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 6,864
Posts: 6,187
Join Date: May 2012
Location: bangalore

 
DONATE TO ME
Quote:
Originally Posted by Pangkoy08 View Post
I've tried and followed this instructions to a reboot to recovery.

I was able to recompile it after i've added the strings in strings.xml and the hdpi and xhdpi, However, when I decompiled it again to get the hex id it is giving me an error would you mind telling me what i've missed out?

Here is the log.

Decompiling "framework-res.apk"
With Tickle My Android
(tinyurl.com\ticklemyandroid)

----------------

I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Francis\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=sharedUserId, value=0x00000020
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Unknown Source)
at brut.androlib.res.util.ExtMXSerializer.writeAttrib uteValue(ExtMXSerializer.java:38)
at org.xmlpull.mxp1_serializer.MXSerializer.attribute (MXSerializer.java:673)
at org.xmlpull.v1.wrapper.classic.XmlSerializerDelega te.attribute(XmlSerializerDelegate.java:106)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializer Wrapper.writeStartTag(StaticXmlSerializerWrapper.j ava:267)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializer Wrapper.event(StaticXmlSerializerWrapper.java:211)
at brut.androlib.res.decoder.XmlPullStreamDecoder$1.e vent(XmlPullStreamDecoder.java:80)
at brut.androlib.res.decoder.XmlPullStreamDecoder.dec ode(XmlPullStreamDecoder.java:130)
at brut.androlib.res.decoder.XmlPullStreamDecoder.dec odeManifest(XmlPullStreamDecoder.java:144)
at brut.androlib.res.decoder.ResFileDecoder.decodeMan ifest(ResFileDecoder.java:131)
at brut.androlib.res.AndrolibResources.decode(Androli bResources.java:218)
at brut.androlib.Androlib.decodeResourcesFull(Androli b.java:115)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:11 4)
at brut.apktool.Main.cmdDecode(Main.java:146)
at brut.apktool.Main.main(Main.java:77)

----------------

Decompile Not Successful!

Thank you for your time. =)
as i mentioned u need to recompile ur framework using erorcun's guide...the link is in OP.....that y u getting this error
 
whalesplaho
Old
#7  
whalesplaho's Avatar
Senior Member
Thanks Meter 1,372
Posts: 5,977
Join Date: Feb 2012
Location: Treasure Island
Code:
   
 .line 235
    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, 0x10400fa

    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
cant find dat brov..... please help!!!






...what's tha sense of workin' hard if you never get to play...

...Pac


 
sandy7
Old
(Last edited by sandy7; 16th September 2013 at 06:31 PM.)
#8  
sandy7's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 6,864
Posts: 6,187
Join Date: May 2012
Location: bangalore

 
DONATE TO ME
Quote:
Originally Posted by whalesplaho View Post
Code:
   
 .line 235
    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, 0x10400fa

    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
cant find dat brov..... please help!!!
u need to add this line to GlobalActions.smali

EDIT: follow the tut properly....below this line u need to add the RED lines showed in OP
 
NuriJ
Old
#9  
Recognized Themer
Thanks Meter 1,072
Posts: 1,180
Join Date: Nov 2011
Nice guide.. Thanks.
Would the 'bootloader' option reboot into fastboot then?

Quote:
Originally Posted by Pangkoy08 View Post
I've tried and followed this instructions to a reboot to recovery.

I was able to recompile it after i've added the strings in strings.xml and the hdpi and xhdpi, However, when I decompiled it again to get the hex id it is giving me an error would you mind telling me what i've missed out?

Here is the log.

Decompiling "framework-res.apk"
With Tickle My Android
(tinyurl.com\ticklemyandroid)

----------------

I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Francis\apktool\framework\1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=sharedUserId, value=0x00000020
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Unknown Source)
at brut.androlib.res.util.ExtMXSerializer.writeAttrib uteValue(ExtMXSerializer.java:38)
at org.xmlpull.mxp1_serializer.MXSerializer.attribute (MXSerializer.java:673)
at org.xmlpull.v1.wrapper.classic.XmlSerializerDelega te.attribute(XmlSerializerDelegate.java:106)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializer Wrapper.writeStartTag(StaticXmlSerializerWrapper.j ava:267)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializer Wrapper.event(StaticXmlSerializerWrapper.java:211)
at brut.androlib.res.decoder.XmlPullStreamDecoder$1.e vent(XmlPullStreamDecoder.java:80)
at brut.androlib.res.decoder.XmlPullStreamDecoder.dec ode(XmlPullStreamDecoder.java:130)
at brut.androlib.res.decoder.XmlPullStreamDecoder.dec odeManifest(XmlPullStreamDecoder.java:144)
at brut.androlib.res.decoder.ResFileDecoder.decodeMan ifest(ResFileDecoder.java:131)
at brut.androlib.res.AndrolibResources.decode(Androli bResources.java:218)
at brut.androlib.Androlib.decodeResourcesFull(Androli b.java:115)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:11 4)
at brut.apktool.Main.cmdDecode(Main.java:146)
at brut.apktool.Main.main(Main.java:77)

----------------

Decompile Not Successful!

Thank you for your time. =)
Wrong frameworks installed i guess..
 
whalesplaho
Old
#10  
whalesplaho's Avatar
Senior Member
Thanks Meter 1,372
Posts: 5,977
Join Date: Feb 2012
Location: Treasure Island
Quote:
Originally Posted by sandy7 View Post
u need to add this line to GlobalActions.smali

EDIT: follow the tut properly....below this line u need to add the RED lines showed in OP
i dnt know where to place it since i cant tha above line...... should i add it anywhere?

what about here?

Code:
 .line 211
    move-object/from16 v0, p0

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

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

    const v3, 0x1080030

    const v4, 0x104018e

    move-object/from16 v0, p0

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

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

    move-object/from16 v0, p0

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

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

    const v3, 0x7f020000

    const v4, 0x7f030000

    move-object/from16 v0, p0

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

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

    .line 236
    move-object/from16 v0, p0

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

    move-object/from16 v0, p0

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

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

    .line 239
    move-object/from16 v0, p0

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

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

    const v3, 0x10805e8

    const v4, 0x10400c1

    move-object/from16 v0, p0

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

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

    .line 263
    move-object/from16 v0, p0

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

    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mSilentModeAction:Lcom/android/internal/policy/impl/GlobalActions$Action;

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






...what's tha sense of workin' hard if you never get to play...

...Pac



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes