[Desire HD Themes and Apps] slopppy:
How to create your own Auto-Brightness settings

OK, this is long over due ... sorry guys.

I set up the tools on my PC ages ago, so I'll do my best to remember. If something doesn't work, let me know and I'll tweak these instructions. I'll put them in the OP once we can confirm they're right.

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. We can re-visit this later if it's an issue.

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.

Now, if someone knows a way to get this onto the phone without having to cook a flashable zip in the UOT kitchen, then let me know! I've tried pushing it to the phone via adb, with the phone in cwm recovery, but haven't got it to work!

*** Preacher65 mentions below that you can easily copy the modded file into a pre-existing flasheable zip. If you know how to do that, then by all means go for it. If not, continue following the UOT Kitchen steps below ***

Therefor, I continue with these steps:

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!

OK ... I think that's it! If someone wants to give it a try, let me know how you go! If you have issues or queries, let me know and I'll help when I can.