Apply Minimum Brightness Patch without losing theme

djakrse

Active Member
Joined
Jun 9, 2010
Messages
1,122
Reaction score
4
Location
TX
I'm posting this tutorial to explain how I applied xeudoxus's brightness patch and retained the SD theme. I want to attempt to contribute at least this much in asking for it on the ROM. There's probably a better way, but this worked for me. If anyone can improve the procedure, don't hesitate to add comments or questions. No tutorial is completely self-encompassing and I still have questions about the process myself.

Sorry for the length. I like to include words so other people can interpret properly if they must. This was not posted with my Android phone!

Disclaimer: I am not a professional. This is what worked for me. Make a nandroid backup before replacing your framework-res.apk and you should be fine. Either way, nobody takes responsibility for what happens but you.

Prerequisites:
Android SDK - Android SDK | Android Developers
xUltimate Auto Brightness Patcher - http://www.droidforums.net/forum/xeudoxus/47283-release-xultimate.html; http://www.xeudoxus.com/android/xUltimate-ABP.zip
7-Zip for Windows (for viewing and modifying our framework-res.apk)
7-Zip Command Line Version - Download
Theme-Porter - Theme-Porter [v1.0] [Any Firmware / Rom Compatible] [WINDOWS] - xda-developers
Basic command-line experience

1) Transfer framework-res.apk Droid > PC
First, enable USB Debugging on your phone. Open a command prompt in Windows and go to <SDK install path>\tools (SDK\tools). I specified the destination as the location of the brightness patcher for the following step:

cd c:\droid\android-sdk-windows\tools
adb pull /system/framework/framework-res.apk c:\droid\

Note: Keep track of your framework-res.apk files. I renamed the original "framework-res.apk.orig" and renamed copies as they were modified.

2) xUltimate Auto Brightness Patcher
Extract xeudoxus's xUltimate Auto Brightness Patcher to "c:\droid\" if you haven't already. There are x86 (xUltimate-ABP-x86.exe) and x64 (xUltimate-ABP-x64.exe) versions, so choose wisely. Run the patcher in the same directory as your framework-res.apk. The newly patched framework-res.apk file is still signed and about 1.5 MB smaller than before, because the resources.arsc file within has been compressed. This file was not compressed in the original and I soon found out that my droid would not boot with the newly patched framework. I assume most other droids (ROMs?) have no problem with this as xeudoxus released this patcher with no mention of it (that I found).

It is stated that the brightness patch process will strip the framework of theming. As far as I can tell the images are still there, but apparently the resources.arsc must control which images are used and have been reset to stock. Enter Theme-Porter. It basically takes your old (original, themed) and new (patched, unthemed) apks and copies the images from old to new, effectively re-theming the patched framework. I'm guessing it must also modify the resources.arsc file to use your themed images. Awesome.

3) Theme-Porter
Extract Theme-Porter into "c:\droid\Theme-Porter\". Place a copy of the original, themed framework-res.apk in "C:\droid\Theme-Porter\old\framework\". Place the newly modified framework-res.apk in "C:\droid\Theme-Porter\new\framework\". Carefully examine any batch file you didn't write before running, then/or run "Script.bat".

After using this great script, I transferred it to my phone and found it wouldn't boot. Using 7-Zip, I compared the resulting framework with my original and brightness-patched versions and found there to be no difference in the files within, save for the resources.arsc and the amount of compression used on the files. There is some mention about this on Google, I mean, the internet <Issue 67 - android-apktool - Compress resources.arsc file in framework-res.apk - Project Hosting on Google Code>. Now concerned about any differences in compression, I wanted to place my patched and re-themed resources.arsc into the original framework-res.apk. You may want to try your luck and attempt using the smaller, re-themed apk as your final product (/system is full enough, right?).

4) Possible issues with compression
I suppose you can skip this step if you aren't concerned about compression. Your experience(s) may trump mine. Otherwise, extract 7-Zip Command Line Version (7za.exe) to "c:\droid" now. 7-Zip CL version will not work with apk as an archive, so place a copy of your original framework-res.apk at "c:\droid" and rename it to "framework-res.zip". Open it with 7-Zip (non-CL), select and delete resources.arsc, and close the archive. Open "C:\droid\Theme-Porter\new\framework\framework-res.apk" from step 3 with 7-Zip and extract the resources.arsc to "c:\droid". Open a Windows command prompt and use 7-Zip command-line version to archive it without compression using the following commands (use 7za -h for help):

cd c:\droid
7za a -mx0 resource-res.zip resources.arsc

5) Nandroid backup
Reboot to recovery and perform a nandroid backup! Do not skip this step because you are anxious to try it out. Your phone will not boot up beyond the M logo if your phone does not like your framework-res.apk.

Transfer the framework back to the phone while in recovery mode. The system is not in use when you replace the framework, so there's no funny business.

6) Transfer framework-res.apk PC > Droid
While in recovery mode, mount /system. Place your final framework-res.apk into your SDK\tools folder. Using the following commands, push the framework to the phone, back up the original file, then rename the new framework. Change framework permissions to match the original file.
adb push framework-res.zip /system/framework/
adb shell
# cd /system/framework
# busybox ls -l (verify your files)
# busybox mv framework-res.apk framework-res.sd7
# busybox mv framework-res.zip framework-res.apk
# busybox chmod 644 framework-res.apk
# busybox ls -l (verify files & permissions)
# exit
Lastly, unmount /system and reboot phone. If you see your boot animation, you've likely succeeded. dancedroid

If everything looks fine when it boots up, test your minimum brightness level in a dark room with auto-brightness enabled. If you are satisfied with the level you chose, you can move your original framework-res.apk (/system/framework/framework-res.sd7) to your /sdcard to free up more space in /system.

fini

Mods, if I need to clean this up a bit just say the word.
 
Top