[PORT][MOD] Porting Evo 3 Way Reboot To Other Devices


bigrushdog

<b>Forum Donator</b>
Nov 7, 2010
247
38
I just finish porting the 3 Way Reboot from CM6.1 to the Evo. It appears it is now 100% stable so now we can start the process of bringing this awesome port to other devices.

To start, download the attached zip which contains the necessary files to implement this port. These files are from CM6.1 and we are very thankful and fortunate that the CM Team developed this mod in the first place.

3 way reboot resource pack

Next, remove framework.jar and android.policy.jar from your respective rom and decompile using smali/baksmali.
In your decompiled framework.jar, browse to com/android/internal/app and replace ShutdownThread.smali and ShutdownThread$2.smali with the ones in the download.

In your decompiled android.policy.jar, browse to com/android/internal/policy/impl and replace GlobalActions$3.smali, GlobalActions$4.smali, and PowerDialog.smali with the ones from the download.

Leave these decompiled jars as they are for now. We will return to them shortly.

Next, take framework-res.apk from your respective rom and use your method of choice to decompile.

Navigate to strings.xml and insert the following at the bottom of the code.

Code:
<string name="reboot_system">Reboot phone</string>
<string name="global_action_reboot">Reboot</string>
Save the changes to strings.xml and close your code editor.

Next, open arrays.xml and add the following at the bottom of the code.

Code:
<string-array name="shutdown_reboot_options">
     <item>Reboot</item>
     <item>Recovery</item>
     <item>Bootloader</item>
</string-array>
<string-array name="shutdown_reboot_actions">
     <item></item>
     <item>recovery</item>
     <item>bootloader</item>
</string-array>
Save the changes to arrays.xml and close your code editor.

Now, open public.xml and add the following. This is where things start to get a little tricky ;) .

Code:
<public type="array" name="shutdown_reboot_actions" id="0x0107001e"/>
<public type="array" name="shutdown_reboot_options" id="0x0107001f"/>
Code:
<public type="string" name="reboot_system" id="0x010403a5"/>
<public type="string" name="global_action_reboot" id="0x010403a6" />
Notice the "public type" is different. The top two are public type "array" and the bottom two are public type are "string". In public.xml, the added elements must be added to the bottom of each respective public type in order to maintain the hex id sequence.

For example, adding

Code:
<public type="array" name="shutdown_reboot_actions" id="0x0107001e"/>
only works if the element above it has a hex ID of 0x0107001d. The proper hex sequence must be maintained in each element type in public.xml. Therefore, you must adjust the hex id of the added code to properly integrate with the code already present.

Here is an example of the bigger picture:
Code:
    <public type="string" name="lunar_chu" id="0x010403a2"/>
    <public type="string" name="lunar_nian" id="0x010403a3"/>
    <public type="string" name="lunar_yue" id="0x010403a4"/>
    <public type="string" name="reboot_system" id="0x010403a5"/>
    <public type="string" name="global_action_reboot" id="0x010403a6"/>
    <public type="dimen" name="app_icon_size" id="0x01050000"/>
    <public type="dimen" name="thumbnail_height" id="0x01050001"/>
    <public type="dimen" name="thumbnail_width" id="0x01050002"/>
    <public type="dimen" name="toast_y_offset" id="0x01050003"/>
another example:

Code:
    <public type="array" name="common_nicknames" id="0x0107001b"/>
    <public type="array" name="imAddressTypes" id="0x0107001c"/>
    <public type="array" name="carrier_properties" id="0x0107001d"/>
    <public type="array" name="shutdown_reboot_actions" id="0x0107001e"/>
    <public type="array" name="shutdown_reboot_options" id="0x0107001f"/>
    <public type="drawable" name="blank_tile" id="0x010800b0"/>
    <public type="drawable" name="loading_tile" id="0x01080287"/>
    <public type="drawable" name="no_tile_128" id="0x010802cc"/>
    <public type="drawable" name="alert_dark_frame" id="0x01080000"/>
Notice how the hex id sequence flows. These are examples from the public.xml from framework-res.apk from the Evo port. Your will likely vary, but the idea is the same.

This is the hard part. You have to map all the hex id references in the smali to match the proper elements in the public.xml.

This table may assist you in finding all the smali references and remapping them accordingly.

Code:
PowerDialog.smali

line 213 0x109004b points to <public type="layout" name="power_dialog" id="0x0109004b"/>

line 253 0x10d0001 points to <public type="bool" name="config_sf_slowBlur" id="0x010d0001"/>

line 277 0x104010c points to <public type="string" name="power_dialog" id="0x0104010c"/>

line 286 0x10201e1 points to <public type="id" name="keyguard" id="0x010201e1"/> 

line 297 0x10201e2 points to <public type="id" name="off" id="0x010201e2"/>

line 308 0x10201e4 points to <public type="id" name="radio_power" id="0x010201e4"/>

line 319 0x10201e3 points to <public type="id" name="silent" id="0x010201e3"/>

line 386 0x1040110 points to <public type="string" name="screen_lock" id="0x01040110"/>

line 427 0x104011f points to <public type="string" name="safeMode" id="0x0104011f"/>

line 459 0x104010e points to <public type="string" name="turn_on_radio" id="0x0104010e"/>

GlobalAction.smali

line 452     const v5, 0x104011d points to     <public type="string" name="global_action_reboot" id="0x010403a6"/>

shutdownthread.smali

line 189 0x1040390 points to     <public type="string" name="reboot_system" id="0x010403a5"/>  

line 198 0x1040112 points to     <public type="string" name="shutdown_progress" id="0x01040112"/>

line 227 0x10d0001 points to     <public type="bool" name="config_sf_slowBlur" id="0x010d0001"/>

line 397 0x1040112 points to     <public type="string" name="shutdown_progress" id="0x01040112"/>

line 406 0x1040112 points to     <public type="string" name="shutdown_progress" id="0x01040112"/>

line 491 0x1080027 points to     <public type="drawable" name="ic_dialog_alert" id="0x01080027"/>

line 493 0x1040013 points to     <public type="string" name="yes" id="0x01040013"/>

line 495 0x1040009 points to     <public type="string" name="no" id="0x01040009"/>

line 554 0x1040390 points to     <public type="string" name="reboot_system" id="0x010403a5"/>

line 560 0x107001d points to     <public type="array" name="shutdown_reboot_options" id="0x0107001d"/>  

line 608 0x10d0001 points to     <public type="bool" name="config_sf_slowBlur" id="0x010d0001"/>

line 656 0x1040112 points to     <public type="string" name="shutdown_progress" id="0x01040112"/>

line 662 0x1040113 points to     <public type="string" name="shutdown_confirm" id="0x01040113"/>

shutdowntread$2.smali

line 62 0x107001e points to     <public type="array" name="shutdown_reboot_actions" id="0x0107001e"/>
So, go through each referenced .smali, and change the hex id at the noted code line to reflect the proper string.

Keep in mind, this .smali was coded to work with the framework-res.apk in CM6.1. You are changing the .smali to reflect the proper strings in YOUR framework-res.apk. If you are lucky, most references will be the same.

NOTE: It appears my code line numbers may be off by about 2. It looks like my viewer window was not maximized and the line numbers were compressed slightly. OOPS!

When you have remapped all the hex references, compile your new framework.jar, android.policy.jar, and framework-res.apk. Place your three new framework files into this special zip to make a flashable package.

Flashable Container From Framework Files

Or, you may place the three framework files into your rom directly.

I may add to this tutorial as the situation requires. Please post with questions, feedback, positive criticism, etc.

Peace.
 
bigrusdog said:
I just finish porting the 3 Way Reboot from CM6.1 to the Evo. It appears it is now 100% stable so now we can start the process of bringing this awesome port to other devices.

:arrow: :arrow: :arrow: :arrow: MORE TO FOLLOW
Would love to see what what changed or added to get it to work...
 
lithid said:
bigrusdog said:
I just finish porting the 3 Way Reboot from CM6.1 to the Evo. It appears it is now 100% stable so now we can start the process of bringing this awesome port to other devices.

:arrow: :arrow: :arrow: :arrow: MORE TO FOLLOW
Would love to see what what changed or added to get it to work...

Unless any of the ROMs on other phones (i.e. not Evo) have made changes to their framework, this should work fine on any phone. The mod actually adds material into the original framework more than changing anything, but it shouldn't be too difficult to make the same changes to any similar framework.

Also, now that this is posted in the porting section, it can get some attention of the other developers on the other phones and we can find out how easy this might really be to get running on the others. So, thanks again n_i_x et al for setting up this site.
 
Hi friend, as i told you on last PM i am getting problems with last step.

I have decompiled framework.jar and android.policy.jar, then changed out the correct smali files.
The next step was easy, have added new elements in arrays and string.xml. Then added in public.xml the new elements carefully.

My last string id was 0x010403a6 so i have write 0x010403a7 and 0x0104038.
<public type="string" name="reboot_system" id="0x010403a7"/>
<public type="string" name="global_action_reboot" id="0x010403a8" />

There was no problem with array ID, i have used yours.
<public type="array" name="shutdown_reboot_actions" id="0x0107001e"/>
<public type="array" name="shutdown_reboot_options" id="0x0107001f"/>
These are next ones to use.

ok, now i have the problems, i cant find the hex Id in smali

I open with notepad2 the GlobalAction.smali but i doesn´t find this line.

line 452 const v5, 0x104011d points to <public type="string" name="global_action_reboot" id="0x010403a6"/>

I have searched by "global_action_reboot", "reboot", .... but no luck. Also i have searched on another classes with sub-classes but same luck.

Whta can i do? any idea?
thanks again and sorry for my bad english
 
Addtional Thoughts

Hi friend, as i told you on last PM i am getting problems with last step.

I have decompiled framework.jar and android.policy.jar, then changed out the correct smali files.
The next step was easy, have added new elements in arrays and string.xml. Then added in public.xml the new elements carefully.

My last string id was 0x010403a6 so i have write 0x010403a7 and 0x0104038.
<public type="string" name="reboot_system" id="0x010403a7"/>
<public type="string" name="global_action_reboot" id="0x010403a8" />

There was no problem with array ID, i have used yours.
<public type="array" name="shutdown_reboot_actions" id="0x0107001e"/>
<public type="array" name="shutdown_reboot_options" id="0x0107001f"/>
These are next ones to use.

ok, now i have the problems, i cant find the hex Id in smali

I open with notepad2 the GlobalAction.smali but i doesn´t find this line.

line 452 const v5, 0x104011d points to <public type="string" name="global_action_reboot" id="0x010403a6"/>

I have searched by "global_action_reboot", "reboot", .... but no luck. Also i have searched on another classes with sub-classes but same luck.

Whta can i do? any idea?
thanks again and sorry for my bad english

Dude, your English is awesome!

You actually got pretty far. Let's take a look at GlobalAction.smali. Remember, you will not see any of these strings or arrays on smali. You will only see the hex reference id. So, in a CM6.1 GlobalAction.smali, around Line 452, you will find

Code:
const v5, 0x104011d

But keep in mind,

Code:
0x104011d

points to the string "global_action_reboot" in the CM6.1 FRAMEWORK-RES.APK, NOT YOURS. So, by referencing your framework-res.apk, we discover that the string global_action_reboot is references by

Code:
0x010403a8

Notice that in framework-res.apk, there is a "0" in front of the "1". In all the smali for this mod, drop that zero

Code:
0x10403a8

So, finally, line 452 will now look like

Code:
const v5, 0x10403a8

This is the concept of remapping the CM6.1 smali to match up with your framework-res.apk It should also be noted, that you should likely pull the smali files from the CM6.1 rom OF YOUR DEVICE. The resource pack in the OP is pulled from CM6.1 for the Evo. It will likely work for DInc too. Keep this thread alive. This is a VERY DIFFICULT mod to pull off. It took me about 6 week of playing to finally get it.
 
Ok, understood

I need change out those hex references with my framekork-res hex. Seems easy lol
One more quuestion, Yesterder i saw in PowerDialog.smali several lines like this one :

const v5, 0x104010e <public type="string" name="turn_on_radio" id="0x0104010e"/>

Must i delete second half (<public type="string" name="turn_on_radio" id="0x0104010e"/>)?


Thanks :)
 
Ok, understood

I need change out those hex references with my framekork-res hex. Seems easy lol
One more quuestion, Yesterder i saw in PowerDialog.smali several lines like this one :

const v5, 0x104010e <public type="string" name="turn_on_radio" id="0x0104010e"/>

Must i delete second half (<public type="string" name="turn_on_radio" id="0x0104010e"/>)?


Thanks :)

Yes, you must, or it won't compile. I don't know how those got in there, but several people have mentioned it. It should look like

Code:
const v5, 0x104010e

thanks for showing me that.
 
got bootloops on first attempt >< uploaded files to the evo forum if anyone wants to take a peek
 
You actually got pretty far. Let's take a look at GlobalAction.smali. Remember, you will not see any of these strings or arrays on smali. You will only see the hex reference id. So, in a CM6.1 GlobalAction.smali, around Line 452, you will find

Wait...in the zip you posted from CM6.1, there's GlobalActions$3.smali and GlobalActions$4.smali, but no GlobalActions.smali, so wouldn't the GlobalActions.smali in the android.policy.jar still be the MIUI one? We would then need to extract GlobalActions.smali from the CM6.1 android.policy.jar and replace it in the MIUI android.policy.jar...right?
 
Wait...in the zip you posted from CM6.1, there's GlobalActions$3.smali and GlobalActions$4.smali, but no GlobalActions.smali, so wouldn't the GlobalActions.smali in the android.policy.jar still be the MIUI one? We would then need to extract GlobalActions.smali from the CM6.1 android.policy.jar and replace it in the MIUI android.policy.jar...right?

No, you gotta use the GlobalActions that came with MIUI. But it's ok, because there is only a single hex pointer that has to be changed. I'll have to update the OP though. It seems implementing the mod breaks Power button long press. should be an easy fix, just leg work.
 
Right...I see now. But MIUI implemented the Visitor Mode thing on the menu, so that pushes Reboot and Power off down on the list. So GlobalActions$3 and $4 would replace $4 and $5 in MIUI.
 
power menu will not return again after the first press if you back out of it

Can anyone help i have a issue when i press the power button to get the power menu up and if i back out of it it will not return again what lines do i need to fix for it i will really appreciate help on this