- 7 Nov 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.
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.
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 .
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
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:
another example:
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.
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.
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>
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>
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" />
For example, adding
Code:
<public type="array" name="shutdown_reboot_actions" id="0x0107001e"/>
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"/>
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"/>
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"/>
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.