[XPERIA X10 Themes and Apps] MrRusch:
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.

<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,

<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,

<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,

<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

.field public static mReboot:I

4. Search for "invoke-static {}, Landroid/os/Power;->shutdown()V", and add the following code

before

this line.

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

: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.smali in e.g Notepad.

3. In the "createDialog" method, extend the array by changing this

const/4 v0, 0x3

new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;

to this

const/4 v0, 0x[B]4[/B]

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"

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

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.

<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,

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

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.