[MOD] Collin_ph battery tweak

KSmithInNY

#winning
Oct 7, 2009
3,538
1,441
0
Visit site
This script was originally created by Collin_ph of XDA for the HTC Hero. This is the port of that to the Optimus S.

[WARN]DO NOT RUN ANY KIND OF PROGRAM THAT CONTROLS THE CPU WHILE USING THIS MOD. NO SETCPU, NO CPU WIDGET, NONE OF THEM!!!!!![/WARN]

This is a tool for power users
If you don't consider yourself 'comfortable' with messing with your phone, then don't. This is not for the faint of heart!

So what does it do?:
  • This tweak creates a service that periodically checks the phone's power source.
  • If the power source changes, it reconfigures the device for maximum performace, battery and safety.
  • Tweaks memory settings for current power source
  • Re-clocks CPU based upon battery remaining or current power source
  • Reclocks for maximum performance if on AC power
  • Reclocks for maximum performance and charging safety if on USB
  • Reclocks for performance and battery if on Battery
  • As Battery life is diminished, Maximum CPU frequency is lowered
  • Tweaks scaling characteristics depending on power source
  • CPU Scales up less frequently on battery power
  • CPU Scales up more frequently on USB/AC power
  • The CPU is allowed to scale dynamically in all charging states based upon CPU usage
  • Includes a batt-cfg utility to configure the system
  • You may load 1 of 4 pre built profiles
  • Manually configure CPU Frequencies in all charging states
  • Determine the percentage of underclocking as the battery drains
  • Configure how often to poll the power state / battery status
  • Disable batt.sh service from running at startup
  • Includes a batt-rm.sh uninstall utility
  • Includes a batt-diag diagnostic utility
  • Includes optional Disk performance tweaks (enabled by default)
  • Includes overheating controls to lower your cpu if the phone starts to overheat

Please read post #2 prior to flashing otherwise you won't know how to use this.
DOWNLOAD FLASHABLE ZIP
Please read post #2 prior to flashing otherwise you won't know how to use this.

If you feel like buying me a coffee, you can do so by clicking below. Not expected but humbly accepted :)

Credit & Thanks:
- Collin_ph - Original author of the script
- Decad3nce - Worked with Collin to make the script even better
- jondevere - Thanks for being willing to be my crash test dummie
- Nick7 - Testing the mod and being willing to tweak RebornROM for all the users who may want to use this mod.
 

KSmithInNY

#winning
Oct 7, 2009
3,538
1,441
0
Visit site
re: [MOD] Collin_ph Battery Tweak

[TIP]
IMPORTANT INFORMATION:
The service doesn't start when i reboot?
It is the job of your kernel and ROM developer to ensure this service starts on boot. Until they have taken the proper actions, you will need to restart the service after each boot by
Code:
su
batt-cfg
and select the default setting you wish you have.

For ROM developers or kernel developers:
You need 2 things for the script to survive a reboot:
An overclockable kernel
An 'import' call for init.local.rc in init.rc in the ramdisk. Just paste this into init.rc after the "Define TCP buffer sizes" setprops
Code:
# Include extra init file so that the battery tweak will function
    import /system/etc/init.local.rc

How do i know it's working?:
Open terminal emulator and type
Code:
su
pidof batt.sh
If it shows a number, it's running

I didn't see a setting for screen off?
This mod doesn't control screen off profiles. Users of a kernel that has the smartass governor will benefit from a screen off profile via their kernel.

batt-cfg:
This is the 'main menu' of sorts, as it gives the user all the options and allows them to toggle tweaks/mods on the fly.
Code:
su
batt-cfg
snap20110711_185104.png


batt-diag:
It's a diagnostics utility, allowing you or someone knowledgeable to figure out any issues that you may be having with your device and be able to pinpoint exactly where the problem is.
Code:
su
batt-diag

batt-rm.sh:
t's a battery tweak removal script, follow the onscreen prompts and it should remove just about any trace of the battery tweak script. YOU MUST MOUNT /SYSTEM AS R/W FOR THE REMOVAL SCRIPT TO WORK
Code:
su
batt-rm.sh

The Presets:
The presets are just default configurations that I have set up that can make your phone more efficient without you, the user, having to manually set everything. The preset of 748 literally means that 74800 is the scaling_max_freq, or the max frequency, that your phone can achieve after you enable it.

Preset #1 is 748, #2 is 768, #3 is 787 and #4 is 806.

Customize Settings:
This is only for the experienced user, and it allows you to manipulate most/ifnotall the configurables on your device.
NOTE: You do not need to configure anything to enable this battery mod. Default settings will be assigned at 748MHz.
snap20110711_185129.png


Disk Boost:
Remounts via noatime and nodiratime. Look up what that means on your own, and why it benefits performance the way it does.

Will this work on (insert ROM)?
Probably. Try it and find out. Just make a nand backup and give it a go. If it doesn't survive a reboot contact your developer and tell them to adjust their ROM to support this mod.

This is a bit too complex for me.
Ok, well there's nothing I can do about that but you can not use this and use profiles in SetCPU to accomplish a similar thing but it requires an apk. Please see my thread here about this topic.

[/TIP]

If you feel like buying me a coffee, you can do so by clicking below. Not expected but humbly accepted :)
 
Last edited:
  • Like
Reactions: vee

KSmithInNY

#winning
Oct 7, 2009
3,538
1,441
0
Visit site
Here you go, this will work on stock (with OC kernel) and CM builds. Stock builds will need to have adjustments made for the batt.sh to survive a reboot but that's up to your developer. Enjoy.
 

Kreatur3

Well-known member
Mar 2, 2011
660
40
0
Visit site
Trying this out and so far have hit a couple of "random" reboots running all of the same stuff I was running before. Using the Ath3nos ROM with the S to OV flash and turned off the cpu option in the cyanogen settings.
 

KSmithInNY

#winning
Oct 7, 2009
3,538
1,441
0
Visit site
Trying this out and so far have hit a couple of "random" reboots running all of the same stuff I was running before. Using the Ath3nos ROM with the S to OV flash and turned off the cpu option in the cyanogen settings.

This boots at 748 so if you couldn't run at 748 before, you won't be able to now. Other than clocking too high, the script couldn't reboot your phone. What MHz did you run before?
 

Kreatur3

Well-known member
Mar 2, 2011
660
40
0
Visit site
This boots at 748 so if you couldn't run at 748 before, you won't be able to now. Other than clocking too high, the script couldn't reboot your phone. What MHz did you run before?

I was running 480/806 prior to trying this out. I don't mind, could have been something else causing the reboot and I was just blaming this. :p lol. If it continues to do it I'll resort back to cm7 OC option and see if it still happens to me.
 

mjs2011

Well-known member
Apr 30, 2011
1,059
73
0
Visit site
thanks for posting! this looks very interesting. i look forward to reading up a little more about the pros/cons vs. using programs like setcpu or using the "performance" menu in the CM7 settings.