[Desire HD Themes and Apps] slopppy:
Hi all,

I'm a LeeDroid HD user, and I've spent some time over the last few weeks tweaking the auto-brightness settings to maximise battery life. I've reached a point where I haven't found any problems with my settings for 4 or 5 days now, which I think is a pretty good test. It's on the low side under most light conditions, but I've tried to find a point where I can comfortably read the screen without holding it up to my face, and when outside, this includes wearing sunglasses.

Obviously screen brightness is a very personal thing, so you might not like where I've ended up. When you want to impress your friends with your awesome DHD, you can always override the auto setting and just crank up the brightness control manually ;)

Sharing my settings is also not simple either, since it requires a mod to res-framework.apk, which is used for themes. So ... what I will do is show you a graph of my changes to so you can see what I'm doing:

(Left side of graph is a dark room, right side is the harsh West Australian sun)​

And make a flashable zip available for Lee's default ROM, with no themes installed (Base_LeeDroid_Lower_Auto_Brightness_Patch).

And another flashable zip to use if you've installed the "LeeDrOiD Notification power widget" from the LeeDroid HD OP (LeeDroid-PNW-Lower_Auto_Brightness_Patch).

And I've already had a request to make one for the "Stock 1.84" theme from here, so that's also attached (Stock_1.84-Lower_Auto_Brightness_Patch).

If you have another theme/mod installed, I think that flashing the above will wreck it ... be warned!

If you have a specific theme/mod you're using and want to try my settings, just send me a link to it and I'll cook up a flashable zip for it ... it doesn't take long. Alternatively if you know what you're doing, I can provide my arrays.xml file and you can do it yourself.

ALL files in this post are to be flashed with cwm 2.5.1.3

... I haven't tested with any other version.

Even though I've tested all these patches myself, I'm not an expert at this, so

PLEASE PLEASE PLEASE take a nandroid backup

first in case I've done something fundamentally wrong.

If you don't like my settings, you can either restore your nandroid backup, or if it was a theme specific patch, you could just apply the theme again.

If it all goes pear-shaped ...

I TAKE NO RESPONSIBILITY!

Hope somebody (other than myself) can benefit from my experimenting :)

If any themers want to incorporate my settings, it's just a change to arrays.xml inside framework-res.apk, nothing else. I'll also attach my arrays.xml (zipped), feel free to use it. As a courtesy, please credit me for the auto-brightness settings If you use them.

As mentioned above, if anyone would like to patch this on top of a specific theme/ROM you have already flashed, just ask and I can cook it up. If you feel like making it easier for me, all I need is framework-res.apk, so if you have a link to just download that, you'll get your patch quicker than if I have to download the entire theme :)

If anyone has arrived here from the LeeDroid thread, be aware that these are NEW versions of the files, as the ones in that thread were based on the wrong version (they were too low in the 40-90-160 range).

Cheers all, any feedback is appreciated :)

I have since put together a DIY guide on how to mod the auto-brightness settings inside framework-res.apk yourself. Thanks to those who contributed. Here's the guide!

This was all done on myWindows XP SP3 machine.

1. Download and install a recent Java Runtime Environment (JRE), if you don't already have one. I won't go through those steps, google it. If you're unsure, you can always come back to this step later if it's not working.

2. Download APK Manager from here: http://xdaforums.com/showthread.php?t=695701 ... there's probably lots of good info in this thread if you have questions later about this tool.

3. Unzip the file wherever you want, mine is just on my desktop.

4. I was advised to replace the version of apktool.exe in the 'other' folder with an earlier version. I don't know if this is necessary, and I don't know what version I now have ... possibly 1.3. ** Multiple people have needed to downgrade to the older apktool.exe that I use, so I have attached it to this post. Just extract apktool.exe from the zip and place it in the 'other' folder, replacing the existing apktool.exe.

5. OK, now you should be ready to go! Grab your framework-res.apk either from your phone, or straight from the ROM you've flashed if you haven't applied any themes. framework-res.apk can be found in /system/framework.

6. Copy your framework-res.apk into the "place-apk-here-for-modding" folder.

7. Run script.bat. If you see a text menu pop up then all is good. If you get an error then you've done something wrong! Probably related to your JRE.

8. Choose Option 9 - Decompile apk. Wait until it finishes. Minimise this window now, we'll come back to it later.

9. Go into your projects folder, and you will have a new folder there called framework-res.apk, double click it.

10. Navigate to res/values

11. Open up arrays.xml in a text editor such as Notepad++. Using Windows built in notepad app could cause issues due to Windows -> Linux compatibility issues.

12. Scroll down to the section where it says "<integer-array name="config_autoBrightnessLevels">". This is the section that defines the steps of the ambient light sensor. You probably won't need to adjust these values for now.

13. The next section down should be "<integer-array name="config_autoBrightnessLcdBacklightValues">", this is where the tweaks really begin. The values here relate directly to how bright the screen is at the steps defined in the section above. Minimum value is 1, maximum value seems to be 249, but that could be incorrect. Would make more sense for it to be 255.

14. Change these values as you wish, but change them to the same thing in all these 3 sections - config_autoBrightnessLcdBacklightValues, config_autoBrightnessLcdBacklightValuesUp, config_autoBrightnessLcdBacklightValuesDown.

15. The next 2 sections - config_autoBrightnessButtonBacklightValues, and config_autoBrightnessKeyboardBacklightValues do the same thing, except for the hardware buttons, and keyboard buttons (if present) respectively. Adjust these if you wish.

16. Save the file.

17. Navigate back to the root of the APK Manager directory.

18. Return to your APK Manager window.

19. Choose option 11 - compile APK.

20. When prompted if this is a system APK, type y. Hit Enter.

21. When prompted if you want to copy additional files, type n. Hit Enter.

22. Choose option 22 - Set Current Project

23. Choose option 2 - unsignedframework-res.apk

24. Choose Option 5 - Zipalign apk

25. Choose Option 24 - Quit. On my script version you have to choose option 24 twice. I assume it's a bug on my version, hopefully you won't have to do the same thing.

26. Congrats! You now have a modded framework-res.apk!! You'll find it in the folder "place-apk-here-for-modding", with the new name "unsignedframework-res.apk". Copy it somewhere else (eg. desktop) and rename it to framework-res.apk.

*** If you know how to copy the modded file into a pre-existing flasheable zip, then by all means go for it. If not, continue following the steps below to create a flashable zip in the UOT Kitchen ***

27. Go to the UOT Kitchen - http://uot.dakra.lt/kitchen/ Hopefully it's not busy and it lets you in! If not, you'll have to wait.

28. Go to the file upload tab and upload your new framework-res.apk file.

29. If this is a FROYO ROM that you're modding, then that's it! If it's a GINGERBREAD ROM, then you also have to grab SystemUI.apk and com.htc.resources.apk from your ROM or phone and upload these also. SystemUI.apk can be found in /system/app and com.htc.resources.apk can be found in /system/framework

30. Go back to the Summary tab, then click "Submit Work to Kitchen".

31. When it's done, download the file, boot into cwm, ***DO A NANDROID BACKUP***, then flash your file!

If you've done it right, you're auto-brightness settings should be applied!

If you get stuck in a boot loop, or it just doesn't boot at all ... lucky you have a nandroid backup!

Please note that as this thread progresses, newer versions of the files get posted which makes these ones in the OP redundant. I'll leave them up for now just in case someone needs them, but in general, you'll want to dig deeper into the thread to get flashable files for newer versions of ROMS. :D