[Galaxy S II Android Development] danividalg:
[GUIDE] How to add customizable 15 statusbar toggle buttons on a Stock ICS LPQ ROM

Hi every one,

As promised, here is a guide on how to add the Wanam customizable 15 toggle buttons statusbar to a Samsung Stock Android 4.0.3 ICS LPQ ROM

I have made it on a LPQ rom, but I suppose that this will work on any ICS rom, even on custom roms.

Please, if you like this information, don't forget to give thanks to (go to each link and click on thanks button to the author):

- lidroid for making this thread and make possible this wonderful statusbar http://xdaforums.com/showthread.php?t=1289896

- sicopat for making the tutorial for deodexing and re-odexing http://xdaforums.com/showthread.php?t=1208320

- wanam for his help and for the 15 toggle button statusbar from his rom http://xdaforums.com/showthread.php?t=1436817

- sileshnair for his help http://xdaforums.com/showpost.php?p=23686975&postcount=605

- M_J_Nazari for his help http://xdaforums.com/showpost.php?p=24059374&postcount=651

- LegendK95 for his help http://xdaforums.com/showpost.php?p=24081656&postcount=655

If I forgot to mention anyone please pm and I will edit

First of all you need your phone rooted. Please don't ask how to root. Use search function.

MAKE A BACKUP OF YOUR PHONE

DO IT AT YOUR OWN RISK

I AM NOT RESPONSABLE IF YOU BREAK YOUR DEVICE OR DROP YOUR COFEE !

I will detail steps to make it on a Windows PC. On a linux or mac should be similar.

Summarized steps are:

- Deodex stock LPQ SystemUI.apk

- Decompile wanam SystemUI.apk

- Copied wanam 15 toggle button statusbar files to deodexed LPQ system folder

- Copied "important" lines from wanam "PhoneStatusBar.smali" file

- Created "classes.dex" file with smali

- Opened original stock "SystemUI.apk" with 7zip and copied file "classes.dex" in root directory

- Zipaligned the new SystemUI.apk

- Decompile the new SystemUI.apk with Wanam APK Manager

- Copied "important" lines from wanam "tw_status_bar_expanded.xml", "ids.xml" and "public.xml" files

- Compile again with Wanam APK Manager

- Zipaligned the new compiled SystemUI.apk

- Deleted on the phone the file "/system/app/SystemUI.odex" (make a backup before)

- Copied to the phone the new compiled and zipaligned file "SystemUI.apk" to "/system/app/"

- Copied to the phone the file "QuickPanelSettings.apk" to "/system/app/"

- Copied to the phone the file "lidroid-res.apk" to "/system/framework/"

- Re-Odex SystemUI.apk if you want

- Reboot into recovery

- Clear dalvik cache

- Reboot

Ok, now I will detail all these steps:

- Make a directory on your PC named "Working Directory"

- Use "RootExplorer" or "ES Explorador de Archivos" to copy your entite "/system/framework/" directory to your "/sdcard/"

- Use "RootExplorer" or "ES Explorador de Archivos" to copy "/system/app/SystemUI.apk" and "/system/app/SystemUI.odex" directory to your "/sdcard/framework/" directory

- Copy your "/sdcard/framework/" from your phone to your "Working Directory" on your PC

- Download "all_for_deodexing_reodexing.zip" from sicopat's thread http://xdaforums.com/showthread.php?t=1208320

- Unzip "all_for_deodexing_reodexing.zip" to your "Working Directory" folder

- Download the Wanam APK Manager from http://xdaforums.com/showpost.php?p=23935070&postcount=14

- Unzip the Wanam APK Manager to "Working Directory\Wanam APK Manager"

- Download and unzip WanamLite ROM from http://xdaforums.com/showthread.php?t=1436817

- Copy WanamLite/system/app/SystemUI.apk as SystemUI.wanam.apk to "Working Directory\Wanam APK Manager\place-apk-here-for-modding\" folder

- Run "Script.bat" from "Working Directory\Wanam APK Manager\"

- Choose option 22 (set current project)

- Choose "SystemUI.wanam.apk"

- Choose option 9 (decompile)

- Close script

If your SystemUi.apk is odexed follow this steps:

- Open a cmd window (Start --> Run --> cmd.exe)

- Go to your "Working Directory"

- To deodex SystemUI.apk run command "java -Xmx1024m -jar baksmali.jar -c :core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar -x SystemUI.odex"

If your SystemUI.apk is deodexed (normal on custom ROMs) follow this steps:

- Copy "Working Directory\SystemUI.apk" to "Working Directory\Wanam APK Manager\place-apk-here-for-modding\" folder

- Run "Script.bat" from "Working Directory\Wanam APK Manager\"

- Choose option 22 (set current project)

- Choose "SystemUI.apk"

- Choose option 9 (decompile)

- Close script

- Delete "Working Directory\Wanam APK Manager\place-apk-here-for-modding\SystemUI.apk"

- Rename folder "Working Directory\Wanam APK Manager\projects\SystemUI.apk\smali" as ""Working Directory\Wanam APK Manager\projects\SystemUI.apk\out"

- Move folder "Working Directory\Wanam APK Manager\projects\SystemUI.apk\out" to "Working Directory"

- Delete folder"Working Directory\Wanam APK Manager\projects\SystemUI.apk"

- Copy "Working Directory\Wanam APK Manager\projects\SystemUI.wanam.apk\smali\wanam" folder to "Working Directory\out\" folder

- Copy "Working Directory\Wanam APK Manager\projects\SystemUI.wanam.apk\smali\com\android\wanam" folder to "Working Directory\out\com\android\" folder

- Compare files "Working Directory\out\com\android\systemui\statusbar\phone\PhoneStatusBar.smali" with file "Working Directory\Wanam APK Manager\projects\SystemUI.wanam.apk\smali\com\android\systemui\statusbar\phone\PhoneStatusBar.smali". Ignore lines like ".registers...", ".prologue", ".locals...", ".line...", ignore "superficial" modifications like "goto_4" in one file and "goto_0" in the other file, etc. Copy only blocks related to the wanam 15 toggle button statusbar (tip: look for "wanam" word). At this moment (wanam 9.8) there are no lines to replace, all are lines to copy from wanam version to stock version. This blocks of lines to copy are:

.field mPowerWidget:Lcom/android/wanam/systemui/StBar/PowerWidget;

iget-object v1, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mPowerWidget:Lcom/android/wanam/systemui/StBar/PowerWidget;

invoke-virtual {v1}, Lcom/android/wanam/systemui/StBar/PowerWidget;->updateWidget()V

const v0, 0x7f0e00bc

invoke-virtual {v1, v0}, Lcom/android/systemui/statusbar/phone/ExpandedView;->findViewById(I)Landroid/view/View;

move-result-object v0

check-cast v0, Lcom/android/wanam/systemui/StBar/PowerWidget;

iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mPowerWidget:Lcom/android/wanam/systemui/StBar/PowerWidget;

iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mPowerWidget:Lcom/android/wanam/systemui/StBar/PowerWidget;

move-object/from16 v1, v0

invoke-virtual {v1}, Lcom/android/wanam/systemui/StBar/PowerWidget;->setupWidget()V

Attached are the stock LPQ version, modified version and wanam version of this file.

- Run command "java -Xmx1024m -jar smali.jar out -o classes.dex"

- Open "Working Directory\SystemUI.apk" with 7zip

- Drag and drop "Working Directory\classes.dex" into the 7zip window to add this file to the SystemUI.apk

- Run command "zipalign -v 4 SystemUI.apk zip_SystemUI.apk"

- Delete "SystemUI.apk" and rename "zip_SystemUI.apk" as "SystemUI.apk"

- Now we have a deodexed and zipaligned SystemUI.apk with the first part of the modification done

- Copy the new deodexed and zipaligned "Working Directory\SystemUI.apk" to "Working Directory\Wanam APK Manager\place-apk-here-for-modding\" folder

- Run "Script.bat" from "Working Directory\Wanam APK Manager\"

- Choose option 22 (set current project)

- Choose "SystemUI.apk"

- Choose option 9 (decompile)

- Close script

- Compare files "Working Directory\Wanam APK Manager\projects\SystemUI.wanam.apk\res\layout\tw_status_bar_expanded.xml" with file "Working Directory\Wanam APK Manager\projects\SystemUI.apk\res\layout\tw_status_bar_expanded.xml". Copy the line

<com.android.wanam.systemui.StBar.PowerWidget android:id="@id/exp_power_stat" android:layout_width="fill_parent" android:layout_height="wrap_content" />

from wanam file to our modified file

- Compare files "Working Directory\Wanam APK Manager\projects\SystemUI.wanam.apk\res\values\ids.xml" with file "Working Directory\Wanam APK Manager\projects\SystemUI.apk\res\values\ids.xml". Copy the line

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

from wanam file to our modified file

- Compare files "Working Directory\Wanam APK Manager\projects\SystemUI.wanam.apk\res\values\public.xml" with file "Working Directory\Wanam APK Manager\projects\SystemUI.apk\res\values\public.xml". Copy the line

<public type="id" name="exp_power_stat" id="0x7f0e00bc" />

from wanam file to our modified file

- Run "Script.bat" from "Working Directory\Wanam APK Manager\"

- Choose option 22 (set current project)

- Choose "SystemUI.apk"

- Choose option 11 (compile)

- Close script

- Delete "Working Directory\SystemUI.apk" (or rename it as SystemUI.deodexed.zipaligned.apk)

- Copy "Working Directory\Wanam APK Manager\place-apk-here-for-modding\unsignedSystemUI.apk" to "Working Directory"

- Run command "zipalign -v 4 unsignedSystemUI.apk SystemUI.apk"

- Ok, now we have our new SystemUI.apk deodexed, zipaligned and ready to be copied to our phone

- Now copy the following files to your phone, to /sdcard/15tbsb/:

* "Working Directory\SystemUI.apk"

* From the WanamLite ROM "WanamLite\system\app\QuickPanelSettings.apk"

* From the WanamLite ROM "WanamLite\system\framework\lidroid-res.apk"

* "Working Directory\dexopt-wrapper"

- Then only left to copy each file to the right phone system folder with "Root Explorer" or "ES Explorador de Archivos":

* Copy "/sdcard/15tbsb/SystemUI.apk" to "/system/app/" folder

* Move "/system/app/SystemUI.odex" to "/sdcard/15tbsb/SystemUI.original.odex"

* Copy "/sdcard/15tbsb/QuickPanelSettings.apk" to "/system/app/" folder

* Copy "/sdcard/15tbsb/lidroid-res.apk" to "/system/framework/" folder

- Now reboot and we should have the 15 toggle buttons statusbar in our phone :)

At this moment we have a deodexed SystemUI.apk, if we want to re-odex it follow this steps (very summarized, if you have doubts look at http://xdaforums.com/showthread.php?t=1208320):

- Run adb shell and put the following commands (you should have activated "USB Debug"):

* su

* mount -o rw,remount -t yaffs2, /dev/block/mtdblock /system (this should mount /system as read/write, you can also use "RootExplorer" or "ES Explorador de Archivos" to mount /system as r/w)

* cp /system/app/SystemUI.apk /system/framework/

* cp /sdcard/15tbsb/SystemUI.original.odex /system/framework/

* dexopt-wrapper /system/framework/SystemUI.apk /system/framework/SystemUI.patched.odex /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar (this create our own odex file)

* chmod 777 /system/framework/SystemUI.original.odex

* chmod 777 /system/framework/SystemUI.patched.odex

* busybox dd if=/system/framework/SystemUI.original.odex of=/system/framework/SystemUI.patched.odex bs=1 count=20 skip=52 seek=52 conv=notrunc (this copy signature from original odex to new odex file)

* cp /system/framework/SystemUI.apk /system/app/

* cp /system/framework/SystemUI.patched.odex /system/app/SystemUI.odex

* cp /system/framework/SystemUI.patched.odex /sdcard/15tbsb/

* rm /system/framework/SystemUI.apk

* rm /system/framework/SystemUI.original.odex

* rm /system/framework/SystemUI.patched.odex

- Now reboot and you should have all working with SystemUI odexed

At this point I had problems (no statusbar, but no error messages), I don't know why. I solved it downloading a CWM zip file from sileshnair (I can't find the link now) and copying and replacing the files inside with the new ones we need.

I have attached this CWM file and you only need to open it with 7zip and drag and drop the files "SystemUI.apk", "SystemUI.odex" (the one generated as SystemUI.patched.odex) and "QuickPanelSettings.apk" into the "/system/app/" folder of the zip, and the file "lidroid-res.apk" into the "/system/framework/" folder of the zip

Once you have the modified "15BarStatus.zip" copy it to your phone to "/sdcard/15tbsb/", then reboot into CWM recovery, install custom zip, select "/sdcard/15tbsb/15BarStatus.zip" file. Then reboot and all should work ok XD

Hope this help to everyone that need it :D

If you have questions post reply and if you see that I do not reply you in two or three days you can pm me to ask me for look the forum.

Have a nice day, thanks to all from who I have learned and best regards to everyone XD