[Galaxy Note GT-N7000 Android Development] majdinj:
Notification panel extra toggles - the original way (Airplane, Torch, AllShareCast)

​

In this tutorial, we will be working with 3 files; SystemUI.apk, SecSettings.apk and SecSettingsProvider.apk

First download the View attachment 2362446 file.

SystemUI.apk:

Here we will put all missing resources for Torch toggle (other resources for Airplane and AllShareCast are already exist).

- Decompile SystemUI.apk

- Go to res\drawable-xhdpi folder and add new image resources [tw_quick_panel_icon_flashlight_off.png] and [tw_quick_panel_icon_flashlight_on.png].

- Go to res\values folder and open strings.xml and add this line resource:

<string name="quickpanel_flashlight_text">Torch</string>

- Now compile SystemUI.apk, then decompile the newly compiled SystemUI.apk again (this is to generate new ids from new resources in public.xml).

- In the new decompiled SystemUI.apk, go to res\values and open public.xml and locate these lines:

<public type="string" name="quickpanel_flashlight_text" id="0x7f0a01b7" />
<public type="drawable" name="tw_quick_panel_icon_flashlight_on" id="0x7f02033d" />
<public type="drawable" name="tw_quick_panel_icon_flashlight_off" id="0x7f02033c" />

You might get different ids, just use what is in your public.xml..!!

- Leave public.xml opened

- Copy FlashlightQuickSettingButton.smali from resource file to smali\com\android\systemui\statusbar\policy\quicksetting folder

- Open FlashlightQuickSettingButton.smali and change the 3 ids that starts with 0x7f?????? with new ids generated in public.xml in the following orders:

.method public constructor <init>(Landroid/content/Context;)V
.locals 9

.prologue
const/4 v6, 0x0

.line 35
const/4 v2, 0x0

const v3, [B][COLOR="Red"]0x7f0a01b7[/COLOR] [COLOR="Green"]<!-- id of quickpanel_flashlight_text[/COLOR][/B]

const v4, [B][COLOR="Red"]0x7f02033d[/COLOR] [COLOR="Green"]<!-- id of tw_quick_panel_icon_flashlight_on[/COLOR][/B]

const v5, [B][COLOR="Red"]0x7f02033c[/COLOR] [COLOR="Green"]<!-- id of tw_quick_panel_icon_flashlight_off[/COLOR][/B]

move-object v0, p0

- Save changes.. and that's all for SystemUI.apk.. Compile.

SecSettings.apk:

We will also add the missing resources only..!!

- Decompile SecSettings.apk

- Go to res\drawable-xhdpi folder and add new image resources [notification_panel_airplane.png] and [notification_panel_flashlight.png]

- Go to res\values folder and add these line resources to strings.xml:

<string name="notification_panel_airplane">Airplane Mode</string>
<string name="notification_panel_flashlight">Torch</string>

- Go to smali\com\android\settings folder and open NotificationPanel.smali file.

- Search for the method ".method public MakeConvertPanelName()V" and add the blue lines (make sure to match all registers v and p according to your smali):

.method public MakeConvertPanelName()V
.registers 4

.prologue
.line 119
iget-object [B][COLOR="Red"]v0, p0[/COLOR][/B], Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string [B][COLOR="Red"]v1[/COLOR][/B], "Wifi"

const-string [B][COLOR="Red"]v2[/COLOR][/B], "notification_panel_wifi"

invoke-virtual {[B][COLOR="Red"]v0, v1, v2[/COLOR][/B]}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

...
...

.line 137
iget-object [B][COLOR="Red"]v0, p0[/COLOR][/B], Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string [B][COLOR="Red"]v1[/COLOR][/B], "Sync"

const-string [B][COLOR="Red"]v2[/COLOR][/B], "notification_panel_sync"

invoke-virtual {[B][COLOR="Red"]v0, v1, v2[/COLOR][/B]}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

[B][COLOR="RoyalBlue"] # Airplane patch start

iget-object v0, p0, Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string v1, "AirplaneMode"

const-string v2, "notification_panel_airplane"

invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

# End

# Torch patch start

iget-object v0, p0, Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string v1, "Flashlight"

const-string v2, "notification_panel_flashlight"

invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

# End[/COLOR][/B]

.line 138
iget-object v0, p0, Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string v1, "Empty"

const-string v2, "notification_panel_empty"

invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

.line 139
iget-object [B][COLOR="Red"]v0, p0[/COLOR][/B], Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string [B][COLOR="Red"]v1[/COLOR][/B], "notification_panel_wifi"

const-string [B][COLOR="Red"]v2[/COLOR][/B], "Wifi"

invoke-virtual {[B][COLOR="Red"]v0, v1, v2[/COLOR][/B]}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

...
...

.line 157
iget-object [B][COLOR="Red"]v0, p0[/COLOR][/B], Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string [B][COLOR="Red"]v1[/COLOR][/B], "notification_panel_sync"

const-string [B][COLOR="Red"]v2[/COLOR][/B], "Sync"

invoke-virtual {[B][COLOR="Red"]v0, v1, v2[/COLOR][/B]}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

[B][COLOR="RoyalBlue"] # Airplane patch start

iget-object v0, p0, Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string v1, "notification_panel_airplane"

const-string v2, "AirplaneMode"

invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

# End

# Torch patch start

iget-object v0, p0, Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string v1, "notification_panel_flashlight"

const-string v2, "Flashlight"

invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

# End[/COLOR][/B]

.line 158
iget-object v0, p0, Lcom/android/settings/NotificationPanel;->mConvertPanelItemstring:Ljava/util/HashMap;

const-string v1, "notification_panel_empty"

const-string v2, "Empty"

invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

- Go to smali\com\android\settings folder and open WirelessSettings.smali

- In the method ".method public onCreate(Landroid/os/Bundle;)V", locate this part and delete or comment out the red line:

.line 525
move-object/from16 v0, p0

iget-object v0, v0, Lcom/android/settings/WirelessSettings;->mMediaShareCategory:Landroid/preference/PreferenceCategory;

move-object/from16 v23, v0

const-string v24, "allshare_cast_settings"

move-object/from16 v0, p0

move-object/from16 v1, v24

invoke-virtual {v0, v1}, Lcom/android/settings/WirelessSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v24

[B][COLOR="Red"]invoke-virtual/range {v23 .. v24}, Landroid/preference/PreferenceCategory;->removePreference(Landroid/preference/Preference;)Z[/COLOR][/B]

This will show AllShareCast tab in Settings -> More settings menu under Media share category but it will not functioned yet..!!

- Now we need to add smali resources for AllShareCast.. Go to res\values and open public.xml and keep it opened, we will use it later.

- Now copy the entire folder resource [wfd] in smali\com\android\settings\ folder

- Now the funny part begins, inside [wfd] folder, open WfdHelpActivity.smali, WfdPickerActivity.smali and WfdPickerDialog.smali and change all ids that start with 0x7f with ids in public.xml. To make this easy, I wrote a comment beside each id to which it must be referred to in public.xml, example:

const v3, 0x7f090392	[B][COLOR="Green"]#wifi_p2p_scan_title[/COLOR][/B]

In this example, you need to see what is the id in public.xml for wifi_p2p_scan_title and then put it instead of 0x7f090392

- Save changes and compile.

- Now open the new compiled SecSettings.apk by WinRAR or 7-zip and go to res folder and drop out the raw folder in your computer then drop it back and set compression method to STORE.. see picture

and that's all for SecSettings.apk.

SecSettingsProvider.apk:

- Decompile SecSettingsProvider.apk

- Go to res\values and open strings.xml and add this new database to this string id (the blue):

<string name="def_candidate_notification_list_q1">DrivingMode;SmartStay;[B][COLOR="RoyalBlue"]AirplaneMode;Flashlight;AllShareCast;[/COLOR][/B]</string>

- That's all for SecSettingsProvider.apk,,

Finally, push all 3 modified apks and Torch.apk from resource file to your phone,, fix permissions (644) and reboot. After booting complete, open titanium backup --> manipulate data --> wipe data for user & system app --> delete the data of settings storage, then reboot for the new database in settings.db to load.

If you don't have titanium backup, then you need to do full data wipe.!!

Thanks to:

[MENTION=1670609]shoman94[/MENTION] and [MENTION=2471504]jeboo[/MENTION] who introduce this mod first.
[MENTION=2312076]tkari4[/MENTION] for doing most of AllShareCast porting from Note 2

[MENTION=3065070]Goldie[/MENTION]: for his idea of using titanium backup instead of full wipe to load the new database and for his valuable advices.