Apply Minimum Brightness Patch without losing theme

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.

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:

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.

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.

Useful Searches

About DroidForums.net

DroidForums.net was founded in 2009 originally dedicated for the Motorola Droid, the first Verizon Android Phone. We have since expanded our community to cover all Android Phones, Android Tablets, and Android Wearables. We discuss various topics including Android Help, Android Device Reviews, Android Apps, Phone Accessories, Android Games and more. Our ultimate goal is to be the Internet's best and largest Android Forum.