[Thunderbolt Android Development] orkillakilla:
Guide: Adding/Removing Quick Settings to Stock Sense 2.1 SystemUI.apk On The ThunderBolt

Written by orkillakilla

Thanks to Ihtpf69 for his work on the extra quick settings and helping me add them.

Thanks also to Thunderstick for his help in showing me how to add them.

THIS IS NOT FOR BEGINNERS!!!!!​

NOTE: This will not work on the newest MR4 leak, which has Sense 3.0. I'm am currently working on getting the quick settings added to that, but is taking some time to figure things out and work out the kinks. I will update the guide when I have everything working.

I will be using apktool for this guide. I don’t like apkmanager. I will be demonstraighting how to add Flashlight and Reboot. (7n1 Volume, Task Manager, Auto-Rotate, and Brightness are enabled by some edits already made to the modded QuickSettings.smali)

Prerequisites:

apktool (and knowledge of how to use it)

SystemUI.apk

xml editor (i use gedit)

ADB (to push apk for testing)

Quick Settings smali files and graphics:

http://thisismyandroid.com/?dir=orkillakilla/Quick Setting Files (please note that these files are the work of Ihtpf69 of TeamBAMF and he has given me permission to mirror the files for this guide)

Important

To have the Task Manager quick setting work properly, you must install the HTC Task Manager apk which is available at the quicksetting files link above (easiest way is to push via adb to /system/app or to add to /system/app when cooking a ROM)

To have the reboot options work correctly, you must be on a ROM that has the extended reboot options already enabled, or add the additional reboot smali files found with the other quick settings files you downloaded earlier to android.policy.jar:

replace PhoneWindowManager.smali and PhoneWindowManager$Reboot Receiver.smali found in /smali/android/internal/policy/impl/ with the ones you downloaded.

The section for removing quick settings is located at the very bottom of the post. (Thanks to Thunderstick for showing me how)

Step One:

First you will need to decompile SystemUI.apk Once you have that done, navigate to /res/drawable-hdpi. This is where all the icons for the notification bar and pulldown menu are stored.

You will need to place all the pgn files for Flashlight and Volume. No need to add anything for the other quicksettings as they are already there, just not implemented.

Step Two:

You will now navigate to /res/layout/quick_settings.xml and open it. What you are going to work with is this section:

<include android:id="@id/volume" layout="@layout/status_bar_preference" />
<include android:id="@id/brightness" layout="@layout/status_bar_preference" />
<include android:id="@id/rotation" layout="@layout/status_bar_preference" />
<include android:id="@id/wifi" layout="@layout/status_bar_preference" />
<include android:id="@id/hotspot" layout="@layout/status_bar_preference" />
<include android:id="@id/network" layout="@layout/status_bar_preference" />
<include android:id="@id/wimax" layout="@layout/status_bar_preference" />
<include android:id="@id/bluetooth" layout="@layout/status_bar_preference" />
<include android:id="@id/gps" layout="@layout/status_bar_preference" />
<include android:id="@id/settings" layout="@layout/status_bar_preference" />
<include android:id="@id/task_manager" layout="@layout/status_bar_preference" />

This determined which options are shown where. You can move them around to your preference. Say if you want the brightness above the volume, simply move the brightness entry above the volume entry.

To add the flashlight and reboot, you will need to manually add them, keeping the same style that is already there:

<include android:id="@id/flashlight" layout="@layout/status_bar_preference" />

And the same for reboot. Put them where you want them to show up.

Step Three:

You will now navigate to /res/values/ids.xml

At the bottom right above , you need to add ids for reboot and volume.

<item type="id" name="flashlight">false</item>

and same for reboot. It doesn’t matter which you add first.

Step Four:

Navigate to /res/values/strings.xml You will need to add a string for Flashlight, so that the word Flashlight appears on the quick setting.

At the bottom, add the following:

<string name="status_bar_quick_settings_flashlight">Flashlight</string>

Step Five:

Note: The resource ids I will be using are for a stock Sense 2.1 SystemUI.apk. Resource ids must be in acending order, and you cannot skip numbers, or create your own random id.

Navigate to /res/values/public.xml

This is one of the tricky parts. You have to give everthing you’ve added so far (all the drawable icons, the ids, and the string) a resource id.

We will start with the ids. At the very bottom of the xml file, above </resources>, add the id’s for reboot and flashlight:

<public type="id" name="flashlight" id="0x7f0a0055" />

the id number is an example.

You will need to make the flashlight id number one more than the previous. For example:

If the id “close” has and id number of 0x7f0a0054, then flashlight needs to be 0x7f0a0055, and reboot needs to be 0x7f0a0056. You cannot skip numbers, or make your own.

Now we will give the string and id number. Scroll to the last string entry, and add flashlight right below it:

<public type="string" name="status_bar_quick_settings_flashlight" id="0x7f080034" />

Again, if the string above the new flashlight string’s id is 0x7f080033, then flashlight must be 0x7f080034

Here is the tedious part. We must give all the drawable icons a resource id.

Scroll to the last drawable entry, and begin adding your icons. The name must be the exa

Reason for Editing:

ct name of the icons file name.

Begin with the flashlight icons:

<public type="drawable" name="widget_flashlight_off" id="0x7f020190" />
<public type="drawable" name="widget_flashlight_on" id="0x7f020191" />

Now the Volume icons:

<public type="drawable" name="widget_icon_sound_alarm" id="0x7f020192" />
<public type="drawable" name="widget_icon_sound_bluetooth" id="0x7f020193" />
<public type="drawable" name="widget_icon_sound_dtmf" id="0x7f020194" />
<public type="drawable" name="widget_icon_sound_media" id="0x7f020195" />
<public type="drawable" name="widget_icon_sound_notifications" id="0x7f020196" />
<public type="drawable" name="widget_icon_sound_ringtone" id="0x7f020197" />
<public type="drawable" name="widget_icon_sound_settings" id="0x7f020198" />
<public type="drawable" name="widget_icon_sound_voice" id="0x7f020199" />

Step Six:

We will now be moving from the /res folder, to the /smali folder.

Navigate to /smali/com/android/systemui/statusbar/preference

You will now add the smali files you downloaded here. Delete the original QuickSettings.smali and add the modded one, renaming it to QuickSettings.smali

Now open the QuickSettings.smali.

Scroll down to .line 59 You will see under that “new-instance”. When you see that, a new quick settings has started.

Scroll down till you see:

new-instance v4, Lcom/android/systemui/statusbar/preference/BT;

We are going to use this for our flashlight.

Copy the following to the clipboard:

new-instance v4, Lcom/android/systemui/statusbar/preference/BT;

iget-object v5, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mContext:Landroid/content/Context;

const v6, 0x7f0a001f

invoke-virtual {p0, v6}, Lcom/android/systemui/statusbar/preference/QuickSettings;->findViewById(I)Landroid/view/View;

move-result-object v6

invoke-direct {v4, v5, v6}, Lcom/android/systemui/statusbar/preference/BT;->(Landroid/content/Context;Landroid/view/View;)V

aput-object v4, v2, v3

.line 62
iget-object v2, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mSettingItems:[Lcom/android/systemui/statusbar/preference/StatusBarPreference;

const/4 v3, 0x3

Now paste it right below const/4 v3, 0x3

You are now going to change BT to Flashlight (there are two of them). You will also change the following:

const v6, 0x7f0a001f

To the resource id you gave the id flashlight earlier in public.xml. For this example, it will be 0x7f0a0055

Now you will scroll down and find:

new-instance v4, Lcom/android/systemui/statusbar/preference/Settings;

You will copy this to the clipboard:

new-instance v4, Lcom/android/systemui/statusbar/preference/Settings;

iget-object v5, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mContext:Landroid/content/Context;

const v6, 0x7f0a0021

invoke-virtual {p0, v6}, Lcom/android/systemui/statusbar/preference/QuickSettings;->findViewById(I)Landroid/view/View;

move-result-object v6

invoke-direct {v4, v5, v6}, Lcom/android/systemui/statusbar/preference/Settings;->(Landroid/content/Context;Landroid/view/View;)V

aput-object v4, v2, v3

.line 66
iget-object v2, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mSettingItems:[Lcom/android/systemui/statusbar/preference/StatusBarPreference;

const/4 v3, 0x7

Again, you will change Settings to Reboot both times, and change the it to 0x7f0a0056.

Step Seven:

Now navigate to /smali/com/android/systemui/statusbar/preference/Flashlight.smali

Scroll down till you find this:

const v1, 0x7f080032

You will need to change that id to the one you gave your flashlight string. In this case it would be 0x7f080034.

Scroll down a bit more and find:

const v1, 0x7f02004a

and change that id to the id you gave your widget_flashlight_off icon. In this case it would be 0x7f020190.

Now near the bottom you will see:

const v1, 0x7f080032

again change it to 0x7f080034

Now navigate to /smali/com/android/systemui/statusbar/preference/Flashlight$1.smali

Scroll down till you see:

const v1, 0x7f020049

Change this id to the id you gave widget_flashlight_on. In this case it would be 0x7f020191.

Scroll down a bit more and change

const v1, 0x7f02004a

to const v1, 0x7f020190

Step Eight:

Navigate to /smali/com/android/systemui/statusbar/preference/Volume.smali

This is one of the trickiest parts.

If you scroll down, you will find an array that looks like this:

0x51t 0x0t 0x2t 0x7ft
0x52t 0x0t 0x2t 0x7ft
0x57t 0x0t 0x2t 0x7ft
0x53t 0x0t 0x2t 0x7ft
0x54t 0x0t 0x2t 0x7ft
0x55t 0x0t 0x2t 0x7ft
0x56t 0x0t 0x2t 0x7ft
0x52t 0x0t 0x2t 0x7ft
0x58t 0x0t 0x2t 0x7ft

These are actually the resource ids for your sound icons you’ve added.

Take the first line of the array, and read it right to left.

0x7ft is the first part of the resource id, (0x7f)020192. 0x2t is the next part 0x7f(02)0192. 0x0 is 0x7f02(00)92, which needs to be changed to 0x1. So now your resource id is 0x7f02(01)92.

The last part is the last 2 digits of the resource id.

So for the first line, if your resource id is 0x7f020192, then that line of the array should look like this:

0x92 0x1t 0x2t 0x7ft

Also, so you know what order the id's should go in, if you look a few lines up, you'll see this:

.local v8, res:Landroid/content/res/Resources;
const/4 v1, 0x0

const-string/jumbo v2, "Voice Volume"

aput-object v2, v0, v1

const/4 v1, 0x1

const-string/jumbo v2, "System Volume"

aput-object v2, v0, v1

const/4 v1, 0x2

const-string/jumbo v2, "Ringer Volume"

aput-object v2, v0, v1

const/4 v1, 0x3

const-string/jumbo v2, "Media Volume"

aput-object v2, v0, v1

const/4 v1, 0x4

const-string/jumbo v2, "Alarm Volume"

aput-object v2, v0, v1

const/4 v1, 0x5

const-string/jumbo v2, "Notification Volume"

aput-object v2, v0, v1

const/4 v1, 0x6

const-string/jumbo v2, "Bluetooth Volume"

aput-object v2, v0, v1

const/4 v1, 0x7

const-string/jumbo v2, "System Volume"

aput-object v2, v0, v1

const/16 v1, 0x8

const-string/jumbo v2, "DTMF Volume"

aput-object v2, v0, v1

That is the order in which the resource id's should read.

Step Nine:

Compile your app with apktool. If you followed this to the t, you shouldn’t get any errors.

If you don't want to sign the apk, take the Meta-INF and AndroidManifest.xml from the ORIGINAL apk and add them to the /SystemUI/build/apk folder, and recompile again. This ensures the apk is signed properly.

Now push your modded SystemUI.apk to your phone through adb.

Reboot.

When you boot up, you should have your additional quick settings.

How To Remove Quick Settings:

I prefer to remove some quick settings that I don't ever use, like the hotspot and bluetooth. I will now show you how to remove them. It's pretty simple.

Step One:

Navigate to /res/layout and open quick_settings.xml

Remove the line of the quick setting(s) you would like to remove.

Example: If you want the Hotspot quick setting removed, you would remove the following line:

<include android:id="@id/hotspot" layout="@layout/status_bar_preference" />

You may remove however many you wish.

Step Two:

Now you will navigate to /smali/com/android/systemui/statusbar/preference and open QuickSettings.smali

At the top, you will remove the entry for whatever quick settings you're removing.

Example:

.field private static final HOTSPOT:I = 0x5

Now search for Hotspot, or whatever quick setting your removing, and remove the following lines of code:

iget-object v2, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mSettingItems:[Lcom/android/systemui/statusbar/preference/StatusBarPreference;

new-instance v3, Lcom/android/systemui/statusbar/preference/HotSpot;

iget-object v4, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mContext:Landroid/content/Context;

const v5, 0x7f0a001c

invoke-virtual {p0, v5}, Lcom/android/systemui/statusbar/preference/QuickSettings;->findViewById(I)Landroid/view/View;

move-result-object v5

invoke-direct {v3, v4, v5}, Lcom/android/systemui/statusbar/preference/HotSpot;-><init>(Landroid/content/Context;Landroid/view/View;)V

aput-object v3, v2, v9

Save and recompile and your quick settings are gone. Enjoy!