[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!!!!!! This includes the built in CPU manager in CM. You need to make sure Menu>Settings>Cyanogenmod settings>Performance>CPU - "Set on boot" is not checked! If this is checked, please uncheck it, reboot the phone, then recovery and flash.[/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.
 
Last edited:

KSmithInNY

#winning
Oct 7, 2009
3,538
1,441
0
Visit site
[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: lerxst_x

basketthis

Well-known member
Nov 22, 2010
1,470
473
0
Visit site
Can't wait to give this a try!

EDIT: This works much better than cputuner for cm7 gingerbread. No lag. No superuser permissions. Works without editing. You've done it again ksmithand jondevere(testing). Thanks very much for both of your work.
 
Last edited:

Maxwellg15

Member
Mar 21, 2011
16
0
0
Visit site
would this be functional with cm7 even though cm7 has a program built in that controls cpu

not to sound rude but


WARNING:
DO NOT RUN ANY KIND OF PROGRAM THAT CONTROLS THE CPU WHILE USING THIS MOD. NO SETCPU, NO CPU WIDGET, NONE OF THEM!!!!!!

CM7 does control the cpu
 

KSmithInNY

#winning
Oct 7, 2009
3,538
1,441
0
Visit site
Try it. My guess is as long as you aren't using the cm CPU control agent to OC or UC, it will work. Nand backup, flash, test. Worst case scenario you nand restore but the way the script is written I'm pretty sure it will work.
 

arizanic

Well-known member
Jan 18, 2011
56
1
0
Visit site
Well i flashed booted ok started in terminal emulator configured settings and all seems to be going well i went back in to the cpu manager for cm7 and the speeds changed from stock to what i selected during the configuration of this tweak so im pretty sure its working perfectly
 

8616v

Well-known member
Dec 14, 2010
142
6
0
Visit site
it appears to remain enabled on boot with cm7
I power cycled went back to terminal entered pidof command and got 1622 back.
 

tmeader

Well-known member
Nov 23, 2010
238
26
0
Visit site
KSmithInNY, any idea which method (this or SetCPU profiles) will provide the better battery life with Reborn ROM 2.2.2? Thanks.

Sent from my LS670 using Tapatalk
 

KSmithInNY

#winning
Oct 7, 2009
3,538
1,441
0
Visit site
KSmithInNY, any idea which method (this or SetCPU profiles) will provide the better battery life with Reborn ROM 2.2.2? Thanks.

It's really subjective and theres no answer to it. Both are completely customizable/changeable based on what you want so if you had the one set for performance and ran it for a day. Then set another for battery and ran it for a day, then the one you set for battery is going to give better battery while the other will give better benchmarks at lower battery levels.

It's really a preference thing with the exception of CM users. They have to use this if they want to gain more control. Profiles don't work in CM so they don't have the SetCPU option.
 

8616v

Well-known member
Dec 14, 2010
142
6
0
Visit site
Just to confirm that I understand correctly ...by default everything gets remounted noatime correct? And there isn't anything I can do through the script to change that?

Also,...I have my on battery min set to 320 but when originally set this up I was on AC power and that min is 600...8 hours later batt .diag shows power source as battery but my min settting hasn't been changed from 600. Would having set on boot in cm7 checked cause this?
 
Last edited:

KSmithInNY

#winning
Oct 7, 2009
3,538
1,441
0
Visit site
Just to confirm that I understand correctly ...by default everything gets remounted noatime correct? And there isn't anything I can do through the script to change that?
Correct and no i dont think so. I'd have to look. Not currently using the tweak right now because I'm working on other stuff.

EDIT- just confirmed that's a non-configurable option.

Also,...I have my on battery min set to 320 but when originally set this up I was on AC power and that min is 600...8 hours later batt .diag shows power source as battery but my min settting hasn't been changed from 600. Would having set on boot in cm7 checked cause this?
Uncheck, reboot.
[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]
 
Last edited:

8616v

Well-known member
Dec 14, 2010
142
6
0
Visit site
for the next person who fails to heed the warning in the op....

so after i unchecked and rebooted the mod was still installed and i could run through the script but the changes weren't being applied. so i ran batt.rm-sh to remove the script. rebooted now the cm7 cpu setting were acting weird, i set it to over clock it wasn't(i set to 787 but it wouldn't run over 600 and current cpu setting was showing odd numbers that weren't even choices...622). rebooted again after setting set on boot(at this point i was just trying to get cm7 cpu settings to work again) still acting wierd rebooted again. cm7 cpu settings finally work normally, unchecked set on boot with default settings for speed. rebooted into recovery flashed script, booted, went into batt-cfg set everything up agian and it seems to be working.

long story short...heed the warning...
 

Forum statistics

Threads
943,006
Messages
6,916,851
Members
3,158,770
Latest member
jcl678