Transparent Statusbar for Android (Gingerbread, Cyanogenmod 7.0.3) MDPI

By | June 15, 2011

Description:

I went through alot of trouble figuring out this stupid little theme hack. I am using Cyanogenmod 7.0.3 on a Nook Color, so it uses a “MDPI” framework for its theme. Turns out there are close to 5 million threads on the subject and 99% of them are worthless. After 3 days of googling and trying random solutions, what you’re left with is 3 or 4 Posts that you have to combine and redact to even come close to figuring out what you need.

Here are several of the horrible “methods” that are described across all the android forums:

– Replacing the .PNG files in system/framework/framework-res.apk (you can open apk’s in 7zip btw)
– Replacing the statusbar .PNG files in system/app/SystemUI.apk
– Modifying the binary XML within SystemUI.apk/res/layout/
– Decompiling the binary XMLs to editable ascii only to find out that theres no easy way to do it
– completely mucking with /system/framework/services.jar
– etc.. and so on.

Turns out, you dont need to touch framework-res.apk or ANYTHING else, specially not services.jar. framework-res.apk only needs to be modified if you are working on a secondary or third party theme. Resources for the default theme all come from the SystemUI.apk. I modified all the status_bar*.png files and title_bar_shadow.9.png, but I believe you only need to edit status_bar_background.png, statusbar_background.9.png, and statusbar_background_9.png. I’m not in the mood to go back and double check, maybe later.

What you would think is simple though, isn’t quite. You would THINK that just updating the PNG files would be enough. It’s not. I tried it a million times while trying all those other bad ideas. After the PNG files are modified, you also need to edit the file, classes.dex, which is in the root of SystemUI.apk. Turns out, .dex is yet another format only native to the Android platform. You can decompile and recompile them using smali/baksmali. Once you have decompiled the .dex file, you’ll be left with a bunch of files. For transparency on the statusbar to work, we need to edit two entries in StatusBarService.smali. After the 2 entries are changed, we save the file then recompile classes.dex, update the SystemUI.apk, then put it on our android device. That’s it. So while it’s not as simple as just editing the PNG files and updating the SystemUI.apk archive, it’s still a hell of a lot simpler than all these forum posts lead on. Actual instructions below.

Instructions:

  • Copy /system/app/SystemUI.apk to your sdcard and then to your computer where you can edit it
  • Install 7-Zip if you do not already have it. 7-Zip can browse into .apk files and let you update them easily.
  • Open SystemUI.apk in 7-Zip, do not extract it, just open it.
  • Browse to the folder res/drawable-mdpi/, then find all the png files that start with “status_bar”. Drag them into a folder on your desktop.
  • Open the PNG files in Paint.Net, Gimp, Photoshop, or whatever your favorite editor is capable of png transparency.
  • Delete the background. It’s now transparent. If you want semi-transparency, do that instead.
  • Select all of your modified PNG files and drag them back into same spot you got them from in the SystemUI.apk file
  • Press Backspace a couple times in 7-Zip to go back up to the root folder in the .apk, you should see classes.dex sitting there.
  • Drag classes.dex out to a folder
  • Download smali and baksmali from here:  http://code.google.com/p/smali/downloads/list, put them in the same dir you put classes.dex
  • Open a CMD prompt and change to that directory
  • Type the following (replace 1.2.6 with whatever version it was you dl’d):
  •                                      java -jar baksmali-1.2.6.jar -o classout/ classes.dex
  • Back in the folder, go into the new classout directory that was created.
  • Find the file named StatusBarService.smali, open it in a text editor.
  • Search for .line 1393, the line just under it should read: const/4 v5, -0x3. If it does not, but instead reads const/4 v5, 0x1 or const/4 v5, 0x2, change it.
  • Search for new-instance v0, Landroid/view/WindowManager$LayoutParams; a couple lines down you should see const/4 v5, 0x2. Change it to const/4 v5, -0x3 also.
  • Save the file and exit.
  • Go back to your CMD prompt and enter this command (this recompiles the .dex file with your changes):
  •                                     java -jar smali-1.2.6.jar classout -o classes.dex 
  • Add classes.dex back to where you got it from in SystemUI.apk.
  • Take your updated SystemUI.apk file and place it on your SD card. If you took it out, put the SD card back in your Android device. (instead of using a SD card you could use something else to move the files around, like dropbox).
  • Open up Terminal on your Android device, change to the directory you put the update SystemUI.apk file. ex: cd /sdcard/myupdate/
  • Type the following commands:
  •                           mount -o remount,rw /system/
  •                           cp -f SystemUI.apk /system/app
  •  The above command probably just crashed Launcher. Press Force Close. Reboot your device.

That’s it. You should now have a transparent status bar.

Here is a working SystemUI.apk for a stock encore/MDPI Cyanogenmod 7.0.3 install with all the changes to the .dex file and PNGs already done.

SystemUI.zip

It should not be needed to be said, but I do not in any way take any responsibility if you brick your shit.  Theres no reason this should brick anything, but always remember to backup your files. At the most if you mess up, you can just reinstall Cyanogenmod.

Leave a Reply

Your email address will not be published. Required fields are marked *