[G1 Android Development] miketaylor00:
First I need to give credit to Devsk and everyone else who helped figure out the concept behind this thread http://xdaforums.com/showthread.php?t=548502&page=14

I knew the idea of renicing the processes would work but I couldn't figure out a way to make it happen all of the time. Processes do not even startup necessarily when the phone starts up and if they do, they will close for no appearant reason and then restart. So I wrote a script that updates every three minutes. And it can help in other ways besides phone ring times. I've included the music player and htc music player which makes them run really smoothly and switch tracks instantly. On JacHeroSki 1.8 I include the touch flo process and smoothed out that a lot. It's up to you on what else this script can do. If you have suggestions let me know and I will add them for other people to use.

If you don't want to install this, it is built into xROM and JacHeroSki. It made a huge improvement on both of those ROMs. I was waiting for those releases to come out before I posted this. I know someone else wrote apk that does something similar but I think this is more configurable for the time being and I wrote it before the apk was written. So I wanted to shart it anyway. You can change the priority for any process that you want using this script. I strongly suggest that you don't set anything at -20 or 20 and that you keep the settings that I have there. You can severely screw up your ROM if you do the wrong things here and you might have to wipe and reinstall. I am not responsible if you brick or damage your phone in any way. Although there is no reason this script should do any permanent damage to any phone. Just be careful.

There are 2 ways to implement this script. One is to download Autostart from the market. It is the method suggested in the thread listed above. The other way is to add a line in one of your startup scripts that calls this script. To use with the Autostart application you must rename the file to autostart.sh and then copy it to the /data/opt/ directory. To do that, you can use the following instructions. Copy the file to the root of your sdcard and then type the following in terminal.

su
cp /sdcard/autstart.sh /data/opt/autostart.sh
chmod 755 /data/opt/autostart.sh

You must fix the permissions every time you copy the file to the phone if you are making changes to it. The app will look for it there by default and run it at every startup. If you want to know how to implement it in the startup script let me know. It is different for different ROMs.

Once the script is started it will update the priorities every 3 minutes. You may still see some delay the first time that a process is loaded but it won't take more than 3 minutes for it to be updated. Due to some problems with the script having problems after running for a long time, I made it restart itself every hour. So far it has worked great and has not put any extra drain on the battery. The update interval is short but it takes less than a second to execute. It even helps with .mp3 files because the mediaserver process has a higher priority too.

There are two tools that will help you know how this is working. One is to use the following command to view the log file I created for this. It will clear the file and start over everytime the script starts so that it doesn't grow out of control. It will show you when the priorities were updated last and when the script was restarted. The command to use for this is:

cat /sdcard/autostart.txt

The other tool was written by Devsk. This is an awesome script that was very helpful in my quest to figure this out. Please thank Devsk for writing it. http://xdaforums.com/showthread.php?p=4365912&highlight=printPriority#post4365912

I found a possible conflict with this method and BFS on xROM. If you are using a ROM with BFS and have problems with this, please remove it and let me know.