FORUMS
Remove All Ads from XDA

[MULTI-MOD] Reboot Option, Percentage Battery, Percentage WiFi, & ASU Signal Strength

1,190 posts
Thanks Meter: 301
 
By MrRusch, Senior Member on 11th November 2010, 11:20 PM
Post Reply Email Thread
I managed to port untermensch's modification to add reboot option(s) to our power menu. See original thread for more information on the process.
Alternative versions also include the Super Circle Battery modification, my own WiFi percentage indicator and ASU network signal strength mods.

Click image for larger version

Name:	screenshot.jpg
Views:	3146
Size:	22.3 KB
ID:	677038

Requirements:
1. Root privileges
2. Choose appropriate firmware version below.

2.3_3.0.1.G.0.75_GENERIC
See this post for Reboot Option only.
See this post for Reboot Option & Percentage Battery.
See this post for Reboot Option & Percentage Battery & WiFi Percentage & ASU Signal Strength.
See this post for Reboot Option & Percentage Battery & WiFi Percentage & ASU Signal Strength + Roaming.

2.1.A.0.435_GLOBAL See this post.
2.0.2.A.0.24_GLOBAL See this post.
2.0.A.0.504_GLOBAL See this post's attachments.

Note: This replaces core system files, i.e. will remove previously installed themes and modifications. If you have problems, push back the original files.

Automatic (xRecovery) Installation:
Reboot into xRecovery and flash update.zip if supplied.

Automatic (ADB GUI) Installation:
Use the X10 Mod Tool, to push the files to the device.
SystemUI.apk goes in system/app if present, and rest in system/framework.

Manual (Terminal Emulator) Installation:
1. Unrar archive.
2. Copy extracted files to /sdcard, and
3. In Terminal Emulator:
a) make sure you have super user permissions (su),
b) remount /system partition as read-write (mount -o remount,rw -t yaffs2 /dev/block/mtdblock2 /system),
c) replace framework.jar (dd if=/sdcard/framework.jar of=/system/framework/framework.jar),
d) replace android.policy.jar (dd if=/sdcard/android.policy.jar of=/system/framework/android.policy.jar),
e) replace SystemUI.apk (dd if=/sdcard/SystemUI.apk of=/system/app/SystemUI.apk) if present,
f) replace framework-res.apk (dd if=/sdcard/framework-res.apk of=/system/framework/framework-res.apk) if present, and
g) reboot device (reboot) if not automatic.
The Following 7 Users Say Thank You to MrRusch For This Useful Post: [ View ] Gift MrRusch Ad-Free
 
 
12th November 2010, 12:01 AM |#2  
pacm23's Avatar
Member
Thanks Meter: 3
 
More
Thanks Mr. Rusch glad your also modding the x10
12th November 2010, 02:48 AM |#3  
chongbh's Avatar
Senior Member
Flag Singpapore
Thanks Meter: 14
 
More
Tested on my Singapore X10i but it cannot boot up, I am repairing my X10 via the PC Companion now.
12th November 2010, 09:42 AM |#4  
MrRusch's Avatar
OP Senior Member
Thanks Meter: 301
 
More
Under contruction
Percentage Battery
A. The 101 stat_sys_battery_X.png and 21 stat_sys_battery_charge_X.png images of which the modification is based, need to be inserted into framework-res.apk.
1. Decompile framework-res.apk with APK Tool or X10 Mod Tool.
2. Add images to res/drawable-hdpi/.

B. These images then need to be referenced in public.xml as drawables.
1. Open res/values/public.xml in e.g. Notepad.
2. Find last drawable-id and increment by one hexadecimal value (XxXXXXXXXX).
3. Create and add all of your drawables as below, incrementing by one hexadeimal value per item.
Code:
<public type="drawable" name="stat_sys_battery_X" id="XxXXXXXXXX" />
4. Save and Close.

C. The XMLs controlling the battery stats (stat_sys_battery.xml and stat_sys_battery_charge.xml) need to be adjusted to percentage levels (100 on battery, and 20 at charging).
1. Replace stat_sys_battery.xml with the one attached to this post.
2. Replace stat_sys_battery_charge.xml with the one attached to this post.
3. Recompile framework-res.apk with APK Tools or X10 Mod Tool.

Replace framework-res.apk on your device.

Reboot Option
A. The reboot.png needs to be inserted into the framework-res.apk.
1. Decompile framework-res.apk with APK Tool or X10 Mod Tool.
2. Add reboot.png to res/drawable-hdpi/.

B. This image is then to be referenced in public.xml as a drawable.
1. Open res/values/public.xml in e.g. Notepad.
2. Find last drawable-id and increment by one hexadecimal value (XxXXXXXXXX).
3. Create and add your drawable as below,
Code:
<public type="drawable" name="reboot" id="XxXXXXXXXX" />
C. The string "Reboot" needs to be added as well, in public.xml and strings.xml.
1. Find last string-id and increment by one hexadecimal value (XxXXXXXXXX).
2. Create and add your string as below,
Code:
<public type="string" name="reboot" id="XxXXXXXXXX" />
3. Save and Close public.xml.
5. Open res/values/strings.xml in e.g. Notepad.
6. Create and add your string as below,
Code:
<string name="reboot">Reboot</string>
7. Save and Close.
8. Recompile framework-res.apk with APK Tool or X10 Mod Tool.

D. ShutdownThread.java needs to be modified to handle the reboot-command from the power menu.
1. Decompile framework.jar with X10 Mod Tool or baksmali.jar.
2. Open com\android\internal\app\ShutdownThread.smali in e.g Notepad.
3. After the last entry in the "# static fields" section, add
Code:
.field public static mReboot:I
4. Search for "invoke-static {}, Landroid/os/Power;->shutdown()V", and add the following code before this line.
Code:
sget v1, Lcom/android/internal/app/ShutdownThread;->mReboot:I
	
const/4 v2, 0x1
	
if-eq v1, v2, :reboot
5. After the next return-void statement, add this code
Code:
:reboot
	
const-string v4, "now"
	
invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void
This will send the "now" command to the kernels shutdown process. When we get our kernels sorted, we can add other commands such as "recovery" or "download" here.
6. Save and Close.
7. Recompile framework.jar with X10 Mod Tool or smali.jar.

E. GlobalActions.java needs to be modified to present the reboot-
drawble/string in the power menu.

1. Decompile android.policy.jar with X10 Mod Tool or baksmali.jar.
2. Open com\android\internal\policy\impl\GlobalActions.sma li in e.g Notepad.
3. In the "createDialog" method, extend the array by changing this
Code:
const/4 v0, 0x3

new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
to this
Code:
const/4 v0, 0x4

new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;
Note here that depending on how many options that already exist in your power menu, this constant's value may differ. The point is - increment it by 1.

4. Add the reboot menu item by adding the following code after last instance of "aput-object v2, v0, v1"
Code:
    const/4 v1, 0x3

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

    const v3, XxXXXXXXX # reboot icon resource id

    const v4, YxYYYYYYY # 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
Note: Swap XxXXXXXXX for the drawable-ID and YxYYYYYYY for the string-ID. The constant v1 decides the placement in the array we extended above. So you can adjust this if you want to place the entry somewhere other than at the end. But remember to adjust the other entries as well then.
5. Save and Close.
6. Now make a copy of GlobalActions$3.smali and rename it to GlobalActions$7.smali.
7. Open GlobalActions$7.smali in e.g Notepad.
8. Replace all instances of "GlobalActions$3" inside it, with "GlobalActions$7".
9. Search for "invoke-static {v0, v1}, Lcom/android/internal/app/ShutdownThread;->shutdown(Landroid/content/Context;Z)V", and add the following code in the line before
Code:
const/4 v2, 0x1
	
sput v2, Lcom/android/internal/app/ShutdownThread;->mReboot:I
10. Save and Close.
11. Recompile android.policy.jar with X10 Mod Tool or smali.jar.

Replace framework.jar, android.policy.jar and framework-res.apk on your device.

Percentage WiFi
A. The 21 stat_sys_wifi_signal_X.png images need to be inserted into framework-res.apk (<2.3.3) or SystemUI.apk (>2.3.3).
1. Decompile framework-res.apk with APK Tool or X10 Mod Tool.
2. Add images to res/drawable-hdpi/.

B. These images then need to be registered as drawables in public.xml.
1. Open res/values/public.xml in e.g. Notepad.
2. Find last drawable-id and increment by one hexadecimal value (XxXXXXXXXX).
3. Create and add all of your drawables as below, incrementing by one hexadeimal value per item.
Code:
<public type="drawable" name="stat_sys_wifi_signal_X" id="XxXXXXXXXX" />
4. Recompile framework-res.apk (<2.3.3) or SystemUI.apk (>2.3.3) with APKTool or X10 Mod Tool.

C. StatusBarPolicy.java needs to load the new WiFi-drawables into status bar.
1. Decompile services.jar with X10 Mod Tool.
2. Open StatusBarPolicy.smali in e.g. Notepad.
3. Go the start of the constructor at ".method static constructor <clinit>()V".
4. Increment " .locals X" by one decimal value.
5. Under " .prologue", add another registry to extend the array with,
Code:
    const/16 vX, 0x21
Note: vX is also incremented by one decimal value.
6. Now search for "sput-object v0, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->sWifiSignalImages:[[I"
The three rows above this, will look like this
Code:
    new-array vX, vY, [I

    fill-array-data vX, :array_Q

    aput-object vX, vZ, v4
6. In the first row, swap vY to the constant we created to initiate the array with.
7. From the second row, copy the ":array_Q" value and go to this marker.
8. Extend this array at the end with references to the drawables-IDs we registered in public.xml earlier.
Note: The ID-format is backwards, i.e.
0xXXt 0xYYt 0xZZt 0xQQt = 0xQQZZYYXX

9. Save and Close.
10. Recompile services.jar with X10 Mod Tool.

D. WifiManager's calculateSignalLevel() functions decision-logic needs to be modified for the 20 levels of WiFi (5% increments).
Note: This function should according to the APIs work as is, as it recieves the array-length as maximum value. For some reason though, I constantly face OutOfBoundsExceptions when using this. Instead, I have created my own logic in java, converted it into smali-code, and replaced the original function with it.
1. Decompile framework.jar with X10 Mod Tool or baksmali.jar.
2. Open WifiManager.smali in e.g. Notepad.
3. Replace the "calculateSignalLevel" function with the one attached to this post.
4. Save and Close.
5. Recompile framework.jar with X10Mod Tool or smali.jar.

Replace framework.jar, services.jar and framework-res.apk on your device.

ASU/dBm Signal Strength
A. The 33 stat_sys_signal_X.png images need to be inserted into framework-res.apk.

B. These images then need to be registered as drawables in public.xml.

C. StatusBarPolicy.java needs to be modified to choose drawable by ASU-value.

D. StatusBarPolicy.java needs to load the new ASU-drawables into status bar.

E. For roaming to work, same process (1-4) needs to be repeated for stat_sys_r_signal_X.png images.
Attached Files
File Type: txt calculateSignalLevel.txt - [Click for QR Code] (6.8 KB, 54 views)
File Type: rar stat_sys_battery_XMLs.rar - [Click for QR Code] (1.1 KB, 75 views)
The Following User Says Thank You to MrRusch For This Useful Post: [ View ] Gift MrRusch Ad-Free
12th November 2010, 11:35 AM |#5  
Senior Member
Flag BCN
Thanks Meter: 34
 
More
Thank you very much for your mod, tested on my X10 with 2.1 Global Generic and work very well.
To serve options:
Recovery and Download?

Great Work

PD: It would be possible to modify the text of the options?:

Reboot----- for Reiniciar
Recovery----for Recuperar
Download--- for Descargar
It's because I have the X10 in Spanish
12th November 2010, 12:04 PM |#6  
MrRusch's Avatar
OP Senior Member
Thanks Meter: 301
 
More
Quote:
Originally Posted by tiggerbcn

PD: It would be possible to modify the text of the options?:

Reboot----- for Reiniciar
Recovery----for Recuperar
Download--- for Descargar
It's because I have the X10 in Spanish

You'd have to mod the APK. So depends how comfortable you are with this.

Edit: Decompile the APK, modify strings.xml, and recompile.

Sent from my X10i using XDA App
12th November 2010, 01:23 PM |#7  
Senior Member
Flag BCN
Thanks Meter: 34
 
More
Buffff, that will not do, be so kind to modify that file and put it here to download it?, I've put a link to this post in a forum Spanish and there are some who call me, but I have the tools to edit these files
Thanks

PD:and these options are used?
Recovery and Download
12th November 2010, 01:44 PM |#8  
Senior Member
Flag La Coruña
Thanks Meter: 1
 
More
Hi, MrRusch. How can I install ONLY that grey battery icon with the percentage within it? Is it possible?

Thanks in advance

PS: I'm the one who asked tiggerbcn for the spanish translation btw
12th November 2010, 02:07 PM |#9  
mith500's Avatar
Senior Member
Thanks Meter: 7
 
More
is it possible to modify it to have the reboot option only?
as I dont think I would be using the other options...and would rather not press them by mistake....he he
12th November 2010, 02:18 PM |#10  
Crowds's Avatar
Senior Member
Flag Azeitão
Thanks Meter: 2,236
 
Donate to Me
More
Quote:
Originally Posted by MrRusch

You'd have to mod the APK. So depends how comfortable you are with this.

Edit: Decompile the APK, modify strings.xml, and recompile.

Sent from my X10i using XDA App

where i can find that "stings.xml" ?
thks
12th November 2010, 02:35 PM |#11  
MrRusch's Avatar
OP Senior Member
Thanks Meter: 301
 
More
Quote:
Originally Posted by rendeiro2005

where i can find that "stings.xml" ?
thks

It's in res\values in the APK.

Quote:
Originally Posted by Zenghelis

Hi, MrRusch. How can I install ONLY that grey battery icon with the percentage within it? Is it possible?

Thanks in advance

PS: I'm the one who asked tiggerbcn for the spanish translation btw

You will find the battery mod itself in this thread.

Quote:
Originally Posted by tiggerbcn

Buffff, that will not do, be so kind to modify that file and put it here to download it?, I've put a link to this post in a forum Spanish and there are some who call me, but I have the tools to edit these files
Thanks

PD:and these options are used?
Recovery and Download

Sorry all, but I will not be making language-specific mods, as this would lead to requests for lots of different languages. If you want to modify it to your language, follow the instructions I have given here (or consult your national chef for help).

As for the latter part of your question - perhaps someone else here can answer this, as this is my first Android device.

Quote:
Originally Posted by mith500

is it possible to modify it to have the reboot option only?
as I dont think I would be using the other options...and would rather not press them by mistake....he he

Yes, this version is coming.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes