# [HOW TO] Add/Remove Quick Settings To Sense 2.1 SystemUI.apk [UPDATED 2/7 STREAMLINED]



## orkillakilla (Jul 9, 2011)

*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 showing me how to add them.​Thanks 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%20Setting%20Files (please note that these files are the work of Ihtpf69 of TeamBAMF and he has given me permission to mirror them for this guide.)​
*Important*
To have the Task Manager quick setting work properly, you must install the HTC Task Manager apk which are available at the download link for the quicksetting files 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" /><br />
<include android:id="@id/brightness" layout="@layout/status_bar_preference" /> <include android:id="@id/rotation" layout="@layout/status_bar_preference" /><br />
<include android:id="@id/wifi" layout="@layout/status_bar_preference" /><br />
<include android:id="@id/hotspot" layout="@layout/status_bar_preference" /><br />
<include android:id="@id/network" layout="@layout/status_bar_preference" /><br />
<include android:id="@id/wimax" layout="@layout/status_bar_preference" /><br />
<include android:id="@id/bluetooth" layout="@layout/status_bar_preference" /><br />
<include android:id="@id/gps" layout="@layout/status_bar_preference" /><br />
<include android:id="@id/settings" layout="@layout/status_bar_preference" /><br />
<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 volume and reboot, you will need to manually add them, keeping the same style that is already there:


```
<include android:id=”@id/voume” 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 </resources>, you need to add ids for reboot and volume.


```
<item type=”id” name=”reboot”>false</item>
```
 and same for flashlight. 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, above </resources>, 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 exact name of the icons file name.

Begin with the flashlight icons:


```
<public type=”drawable” name=”widget_icon_flashlight_off” id =”0x7f020190” /><br />
<public type=”drawable” name=”widget_icon_flashlight_on” id=”0x7f020191” />
```
Now the Volume icons:


```
<public type=”drawable” name=”widget_icon_sound_alarm” id=”0x7f020192” /><br />
<public type=”drawable” name=”widget_icon_sound_bluetooth” id=”0x7f020193” /><br />
<public type=”drawable” name=”widget_icon_sound_dtmf” id=”0x7f020194” /><br />
<public type=”drawable” name=”widget_icon_sound_media” id=”0x7f020195” /><br />
<public type=”drawable” name=”widget_icon_sound_notifications” id=”0x7f020196” /><br />
<public type=”drawable” name=”widget_icon_sound_ringtone” id= “0x7f020197” /><br />
<public type=”drawable” name=”widget_icon_sound_settings” id=”0x7f020198” /><br />
<public type=”drawable” name=”widget_icon_sound_voice” id=”0x7f020199” />
```
*Step Six:*

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;<br />
<br />
	iget-object v5, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mContext:Landroid/content/Context;<br />
<br />
	const v6, 0x7f0a001f<br />
<br />
	invoke-virtual {p0, v6}, Lcom/android/systemui/statusbar/preference/QuickSettings;->findViewById(I)Landroid/view/View;<br />
<br />
	move-result-object v6<br />
<br />
	invoke-direct {v4, v5, v6}, Lcom/android/systemui/statusbar/preference/BT;-><init>(Landroid/content/Context;Landroid/view/View;)V<br />
<br />
	aput-object v4, v2, v3<br />
<br />
	.line 62<br />
	iget-object v2, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mSettingItems:[Lcom/android/systemui/statusbar/preference/StatusBarPreference;<br />
<br />
	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;<br />
<br />
	iget-object v5, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mContext:Landroid/content/Context;<br />
<br />
	const v6, 0x7f0a0021<br />
<br />
	invoke-virtual {p0, v6}, Lcom/android/systemui/statusbar/preference/QuickSettings;->findViewById(I)Landroid/view/View;<br />
<br />
	move-result-object v6<br />
<br />
	invoke-direct {v4, v5, v6}, Lcom/android/systemui/statusbar/preference/Settings;-><init>(Landroid/content/Context;Landroid/view/View;)V<br />
<br />
	aput-object v4, v2, v3<br />
<br />
	.line 66<br />
	iget-object v2, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mSettingItems:[Lcom/android/systemui/statusbar/preference/StatusBarPreference;<br />
<br />
	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<br />
		0x52t 0x0t 0x2t 0x7ft<br />
		0x57t 0x0t 0x2t 0x7ft<br />
		0x53t 0x0t 0x2t 0x7ft<br />
		0x54t 0x0t 0x2t 0x7ft<br />
		0x55t 0x0t 0x2t 0x7ft<br />
		0x56t 0x0t 0x2t 0x7ft<br />
0x52t 0x0t 0x2t 0x7ft<br />
		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, [URL=res:Landroid/content/res/Resources]res:Landroid/content/res/Resources[/URL];<br />
const/4 v1, 0x0<br />
<br />
	const-string/jumbo v2, "Voice Volume"<br />
<br />
	aput-object v2, v0, v1<br />
<br />
const/4 v1, 0x1<br />
<br />
	const-string/jumbo v2, "System Volume"<br />
<br />
	aput-object v2, v0, v1<br />
<br />
const/4 v1, 0x2<br />
<br />
	const-string/jumbo v2, "Ringer Volume"<br />
<br />
	aput-object v2, v0, v1<br />
<br />
const/4 v1, 0x3<br />
<br />
	const-string/jumbo v2, "Media Volume"<br />
<br />
	aput-object v2, v0, v1<br />
<br />
	const/4 v1, 0x4<br />
<br />
	const-string/jumbo v2, "Alarm Volume"<br />
<br />
	aput-object v2, v0, v1<br />
<br />
	const/4 v1, 0x5<br />
<br />
	const-string/jumbo v2, "Notification Volume"<br />
<br />
	aput-object v2, v0, v1<br />
<br />
	const/4 v1, 0x6<br />
<br />
	const-string/jumbo v2, "Bluetooth Volume"<br />
<br />
	aput-object v2, v0, v1<br />
<br />
	const/4 v1, 0x7<br />
<br />
	const-string/jumbo v2, "System Volume"<br />
<br />
	aput-object v2, v0, v1<br />
<br />
	const/16 v1, 0x8<br />
<br />
	const-string/jumbo v2, "DTMF Volume"<br />
<br />
	aput-object v2, v0, v1
```
That is the order in which the resource id's should read.

*Step Ten:*

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

*IMPORTANT:* 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 [URL=HOTSPOT:I]HOTSPOT:I[/URL] = 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;<br />
<br />
	new-instance v3, Lcom/android/systemui/statusbar/preference/HotSpot;<br />
<br />
	iget-object v4, p0, Lcom/android/systemui/statusbar/preference/QuickSettings;->mContext:Landroid/content/Context;<br />
<br />
	const v5, 0x7f0a001c<br />
<br />
	invoke-virtual {p0, v5}, Lcom/android/systemui/statusbar/preference/QuickSettings;->findViewById(I)Landroid/view/View;<br />
<br />
	move-result-object v5<br />
<br />
	invoke-direct {v3, v4, v5}, Lcom/android/systemui/statusbar/preference/HotSpot;-><init>(Landroid/content/Context;Landroid/view/View;)V<br />
<br />
	aput-object v3, v2, v9
```
Save and recompile and your quick settings are gone. Enjoy!


----------



## BuffoGT (Jul 10, 2011)

AWESOME guide!! One quick Question, do you have a list of the changes to the QuickSettings.smali file? The version that is with 2.3.6 seems to be pretty different so wondering if you have any ideas around that one? I can DIF the 605.9 SystemUI and the currently circulating SystemUI you have out, but was wondering if there is a quick guide on what needs to be done there?

Also any plans to create one for the 2.3.6 version of SystemUI since that Leak is out now?


----------



## tanknspank (Jun 10, 2011)

Great work on this writeup! Definitely going to try this out.

Sent from my Thunderbolt


----------



## jdkoreclipse (Jun 16, 2011)

Great tut. If I ever decide to dev for the bolt again this will be very useful

Sent from my Galaxy Nexus using RootzWiki


----------



## orkillakilla (Jul 9, 2011)

BuffoGT said:


> AWESOME guide!! One quick Question, do you have a list of the changes to the QuickSettings.smali file? The version that is with 2.3.6 seems to be pretty different so wondering if you have any ideas around that one? I can DIF the 605.9 SystemUI and the currently circulating SystemUI you have out, but was wondering if there is a quick guide on what needs to be done there?
> 
> Also any plans to create one for the 2.3.6 version of SystemUI since that Leak is out now?


I'm currently working on quick settings for the new leak. It is a lot different. So far I have the flashlight working. I'll update when I get everything worked out

Sent from my FactoryROM ThunderBolt


----------



## NickxxSfk (Dec 20, 2011)

Very helpful! Gonna add these in later.

Sent from my Desensed Tbolt


----------



## orkillakilla (Jul 9, 2011)

I will be updating the guide to be a bit more specific with this icon array for the volume.smali. I'll probably have it sometime tonight

Sent from my FactoryROM ThunderBolt


----------



## orkillakilla (Jul 9, 2011)

Updated Step Nine to be more specific about the Icon array for Volume.smali


----------



## orkillakilla (Jul 9, 2011)

Guide updated. I streamlined the process by removing a step that isn't necessary. Also added how to remove quick settings located at the bottom of the OP.


----------



## orkillakilla (Jul 9, 2011)

Updated OP with working links to the quicksetting files. Thanks to I[background=rgb(251, 248, 244)]htpf69 for allowing me to mirror them.[/background]


----------

