[Verizon Samsung Galaxy S III] Didact74:
Time for another MOD :)​

This guide is meant for DEVs who want to incorporate this MOD into their ROM. I will post up a flashable zip later but just know it will only be for Stock Deodexed Roms. Most people are running custom ROMs now so flashing this over one of them will break themes and things.

Always Nandroid before making or attempting to MOD your phone

What will this MOD do?

-This MOD will allow you to select up to 20 different icons to use for your battery.

So what, I can do this now with any one of my battery flashable zips, why do I need this?

-Because this MOD will let you make these changes immediately, on the fly, and with no flashing or rebooting needed. :)

This is a pretty involved MOD with lot of changes and file additions. I will do my best to remember everything but I make no promises. If you catch something I missed or are having issues with something just post it up in this thread and I will try to help you.

Big Thanks to DSA for letting me look through some of his stuff for implementation.!

With that said, lets begin........

First thing to mention is there is an attached zip file to this thread. In this ZIP you will find the files needed to get this MOD going. The files you need are located in folders within the zip. Each folder name describes where those files should be placed. If you encounter a message that says the file you are adding already exists, write over it with the new file. This includes new icons as well.

We will be working with two system files:

SystemUI.apk

SecSettings.apk

We will begin with SecSettings.apk

Once you have decompiled SecSettings, navigate to res/values/arrays

Add the following lines of code

<string-array name="battery_icon_entries">
<item>Stock icon only</item>
<item>Text only</item>
<item>Icon with text</item>
<item>Icon with centered text</item>
<item>C Style</item>
<item>Android</item>
<item>Blueglass</item>
<item>Castaway</item>
<item>Chrysis</item>
<item>Dark Blue HC</item>
<item>Dark Blue Stock</item>
<item>Green Glass</item>
<item>Green HC</item>
<item>Green Stock</item>
<item>ICS Blue HC</item>
<item>ICS Blue Stock</item>
<item>Little Android</item>
<item>Naddict</item>
<item>Sense</item>
<item>Hide</item>
</string-array>
<string-array name="battery_icon_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>11</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
<item>-1</item>
<item>-2</item>
<item>-3</item>
<item>-4</item>
<item>-5</item>
<item>-6</item>
<item>-7</item>
<item>-8</item>
<item>-9</item>
</string-array>

Navigate to res/values/strings and add the following lines of code

<string name="battery_icon_category">Battery icon options</string>
<string name="battery_icon">Battery icon style</string>

Navigate to res/xml/display_settings.xml and add the following in RED. You will write over some code doing this.

<CheckBoxPreference android:title="@string/sub_lcd_auto_lock" android:key="sub_lcd_auto_lock" android:summary="@string/sub_lcd_auto_lock_summary" />
<CheckBoxPreference android:title="@string/key_night_mode" android:key="key_night_mode" />
<ListPreference android:persistent="false" android:entries="@array/key_backlight_entries" android:title="@string/key_backlight" android:key="key_backlight" android:widgetLayout="@layout/round_more_icon" android:entryValues="@array/key_backlight_values" />
[COLOR="red"]<ListPreference android:persistent="false" android:entries="@array/touch_key_light_entries" android:title="@string/touch_key_light" android:key="touch_key_light" android:summary="@string/touch_key_light_summary" android:widgetLayout="@layout/round_more_icon" android:entryValues="@array/touch_key_light_values" />
<CheckBoxPreference android:persistent="false" android:title="@string/display_saving" android:key="power_saving_mode" android:summary="@string/display_saving_mode_summary" />
<CheckBoxPreference android:persistent="false" android:title="@string/notification_pulse_title" android:key="notification_pulse" />
<PreferenceCategory android:title="@string/battery_icon_category" android:key="battery_icon_category">
<ListPreference android:entries="@array/battery_icon_entries" android:title="@string/battery_icon" android:key="battery_icon_list" android:entryValues="@array/battery_icon_values" />
<CheckBoxPreference android:persistent="false" android:title="@string/display_battery_percentage" android:key="display_battery_level" android:summary="@string/display_battery_percentage_summary" />
</PreferenceCategory>
[/COLOR]</PreferenceScreen>

Navigate to smali/com/android/settings/DisplaySettings.smali and add the following lines in RED

.field private mAutoLockmode:Landroid/preference/CheckBoxPreference;

[COLOR="red"].field private mBatteryStyle:Landroid/preference/ListPreference;[/COLOR]

.field private mBrightness:Lcom/android/settings/BrightnessPreference;

Find ".method public onCreate(Landroid/os/Bundle;)V and add the following lines in RED

const-string v11, "font_size"

invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v11

check-cast v11, Landroid/preference/ListPreference;

iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mFontSizePref:Landroid/preference/ListPreference;

.line 394
iget-object v11, p0, Lcom/android/settings/DisplaySettings;->mFontSizePref:Landroid/preference/ListPreference;

invoke-virtual {v11, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

[COLOR="red"]const-string v11, "battery_icon_list"

invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v11

check-cast v11, Landroid/preference/ListPreference;

iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

const-string v11, "battery_icon_list"

const/4 v12, 0x0

invoke-static {v8, v11, v12}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v11

iget-object v12, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

invoke-static {v11}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

move-result-object v11

invoke-virtual {v12, v11}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V

iget-object v12, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

invoke-virtual {v12, p0}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
[/COLOR]
.line 396
const-string v11, "display_battery_level"

invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v11

check-cast v11, Landroid/preference/CheckBoxPreference;

iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mDisplayBatteryLevel:Landroid/preference/CheckBoxPreference;

.line 398
invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getActivity()Landroid/app/Activity;

Find ".method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z" and add the following lines in RED

const-string v2, "contextualpage_settings"

invoke-virtual {v2, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v0

[COLOR="red"] if-eqz v0, :cond_10
[/COLOR]
.line 1014
check-cast p2, Ljava/lang/Boolean;

invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

move-result v0

if-eqz v0, :cond_c

const-string v1, "DisplaySettings"

const-string v3, "CONTEXTUALPAGE_SWITCH_CHANGED changed = false"

invoke-static {v1, v3}, Landroid/util/Log;->secD(Ljava/lang/String;Ljava/lang/String;)I

goto :goto_7

:cond_f
move-wide v0, v4

goto/16 :goto_3

[COLOR="red"]:cond_10
iget-object v1, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

if-ne p1, v1, :cond_1

check-cast p2, Ljava/lang/String;

invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

move-result-object v1

invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I

move-result v0

invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v1

const-string v2, "battery_icon_list"

invoke-static {v1, v2, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

goto/16 :goto_4
[/COLOR].end method

Thats it for SecSettings, recompile and push to /system/app. Make sure everything boots and you see your new selections in SystemSettings->display->Battery Icon selection. It will not be functional yet, but you should see it there.

SYSTEMUI.apk

Decompile SystemUI.apk and add all the new files if have not already done so.

Now recompile SystemUI.apk, delete the old SystemUI folder and decompile again creating a new SystemUI folder.

We do this step so the system can take all the new files we just added and generate new IDs for them. If you get errors compiling its probably because you forgot to add a file or a line of code......or i missed a step in this tutorial :). To verify tht the new IDs are there, simply navigate to res/values/public and search for one of the new files we just added like "stat_sys_battery_castaway". If you find it, you are good to proceed.

Navigate to res/values/ids and add the following files

<item type="id" name="battery_combo">false</item>
<item type="id" name="battery_text_center">false</item>
<item type="id" name="battery_text_only">false</item>
<item type="id" name="battery_text_only_low">false</item>
<item type="id" name="battery_text_only_plugged">false</item>
<item type="id" name="battery_cluster">false</item>
<item type="id" name="battery_notification">false</item>

Navigate to res/values/strings and add the following

<string name="battery_test">99</string>

Navigate to res/values/styles and add the following

</style>
<style name="Battery_Offset">
<item name="android:textSize">11.0dip</item>
<item name="android:textStyle">bold</item>
<item name="android:layout_gravity">bottom|left|center</item>
<item name="android:paddingBottom">1.0dip</item>
<item name="android:layout_marginRight">4.0dip</item>
<item name="android:shadowColor">#ff000000</item>
<item name="android:shadowDx">0.0</item>
<item name="android:shadowDy">0.0</item>
<item name="android:shadowRadius">2.5</item>
</style>
<style name="Battery_Center">
<item name="android:textSize">9.0dip</item>
<item name="android:textStyle">bold</item>
<item name="android:layout_gravity">center</item>
<item name="android:layout_marginRight">0.0dip</item>
<item name="android:shadowColor">#ff000000</item>
<item name="android:shadowDx">0.0</item>
<item name="android:shadowDy">0.0</item>
<item name="android:shadowRadius">2.5</item>
</style>
<style name="TextAppearance.StatusBar.BatteryTextOnly" parent="@*android:style/TextAppearance.StatusBar.Icon">
<item name="android:textSize">16.0dip</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">@*android:color/holo_blue_light</item>
</style>
<style name="TextAppearance.StatusBar.BatteryTextOnly_Plugged" parent="@*android:style/TextAppearance.StatusBar.Icon">
<item name="android:textSize">16.0dip</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">@*android:color/holo_green_light</item>
</style>
<style name="TextAppearance.StatusBar.BatteryTextOnly_Low" parent="@*android:style/TextAppearance.StatusBar.Icon">
<item name="android:textSize">16.0dip</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">@*android:color/holo_red_light</item>
</style>

Navigate to smali/com/android/systemui/statusbar/phone/PhoneStatusBar.smali

Find "method protected makeStatusBarView()Lcom/android/systemui/statusbar/phone/PhoneStatusBar;" and

REMOVE

the lines in RED

new-instance v9, Lcom/android/systemui/statusbar/policy/LocationController;

iget-object v10, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;

invoke-direct {v9, v10}, Lcom/android/systemui/statusbar/policy/LocationController;-><init>(Landroid/content/Context;)V

iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mLocationController:Lcom/android/systemui/statusbar/policy/LocationController;

.line 756
[COLOR="Red"]new-instance v9, Lcom/android/systemui/statusbar/policy/BatteryController;

iget-object v10, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;

invoke-direct {v9, v10}, Lcom/android/systemui/statusbar/policy/BatteryController;-><init>(Landroid/content/Context;)V

iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;

.line 757
iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;

iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

const v11, 0x7f0d003c

invoke-virtual {v9, v11}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;

move-result-object v9

check-cast v9, Landroid/widget/ImageView;

invoke-virtual {v10, v9}, Lcom/android/systemui/statusbar/policy/BatteryController;->addIconView(Landroid/widget/ImageView;)V
[/COLOR]
.line 760
sget-boolean v9, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->useTouchWizGUI:Z

if-eqz v9, :cond_5

.line 761
iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

const v10, 0x7f0d00af

invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;

move-result-object v9

check-cast v9, Landroid/widget/TextView;

iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;

.line 762
[COLOR="red"] iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
[/COLOR]
iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;

[COLOR="red"] invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/policy/BatteryController;->addLabelView(Landroid/widget/TextView;)V
[/COLOR]
.line 764
iget-object v9, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;

invoke-virtual {v9}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v9

const-string v10, "display_battery_percentage"

invoke-static {v10}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

move-result-object v10

const/4 v11, 0x0

Now for the really fun part :) Take a look at the six files in the zip in the folder named SystemUI_smali_com_android_systemui_statusbar_policy

There are two files in this folder we will concentrate on

-BatteryController.smali

-BatteryControllerNotification.smali

Here is what we are going to do. We need to go through both files and find all the System ID's. These can be identified by looking for the

0x7fxxxxx

We need to find all these IDs and verify or change them to the correct IDs found in your res/values/public. Why? Because you just added over 3000 new files to your SystemUI.apk and there is no telling exactly what IDs were assigned to them without verifying it first. If you used the IDs in my files and one was different, the MOD would fail.

So here is how to do this. First you will notice I have done half the legwork for you by naming what each ID is in my files. So when you are searching for IDs you will see somethin like this

const v8, 0x7f0a001c #status_bar_settings_battery_meter_format

The "0x7f0a001c" is the ID and the "#status_bar_settings_battery_meter_format"is the name associated with the ID.

What you will do is open one of the two files at a time as well as open your public.xml file so you have both files available in your editor. Find each ID, copy the description beside it (without the hashtag) and search for this description in your public.xml file. Verify the ID is the same and if its not change it to the correct one. You have to do this for all IDs in both of those files. Take your time and go slow, if you miss one or copy one wrong the MOD will fail.

Thats it! You can recompile files and push to /system/app. enjoy the MOD!!

Please dont forget to buy me a coke or hit the thanks button!

Keep an eye out for more MODs soon!