[MOD] Collin_ph Battery Tweak For EVO By Myn

Search This thread

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
Background

As many of you recently saw in my Warm TwoPointTwo RLS2 thread there was an optional download for Collin_ph's battery tweak ported to the EVO by me.

This mod was so large I figured It deserved it's own thread and at the same time I'd like to share it with the community so other ROM devs can incorporate this into their ROMs

This is really a tool for power users

If you don't consider yourself 'comfortable' with messing with your phone, then don't.

This is mostly the work of collin_ph, all the ideas are mostly his and I have only contributed in part to getting some things functioning correctly and some optimizations for the EVO and INCredible. The original thread from Collin_ph can be found here and the original documentation can be found here.


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 compcache (if enabled) for current power source
    • 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 charactaristics depending on power sourcee
      • 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 2 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 statys
    • Disable batt.sh service from running at startup
  • Includes a batt-rm.sh uninstall utility
  • Includes a batt-diag diagnostic utility
  • Includes an LED fix if your LED is stuck on
  • Includes optional experimental performance tweaks (disabled by default)
  • Includes optional Disk performance tweaks (enabled by default)
  • Includes optional froyo Audio quality fix (disables stagefright)


The Tools

The entire 'application' is written in shell code and was first written just to give a performance and battery boost, but since has evolved more and more.

All the tools mentioned will be utilized either through the terminal, or in adb shell.


batt.sh

This is the core of the entire script. Don't mess with it.
The one thing you should do after installing the script:

Code:
pidof batt.sh

If theres any number showing up after it, then it's working fine.



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.

batt-cfg.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.

batt-diag -v gives a more thorough output as you can see here; http://pastie.org/1162034

batt-rm.sh

It's a battery tweak removal script, follow the onscreen prompts and it should remove just about any trace of the battery tweak script.


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 998 literally means that 998400 is the scaling_max_freq, or the max frequency, that your phone can achieve after you enable it.

Just typing 1, and then enter, you'll be ready and set to go. Same with 2.



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.

customize.png


All the settings explain what each option does, so read them carefully.

Disk Boost

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

Audio 'Fix'

Disables stagefright for bettery audio quality, though it will hinder your benchmark scores only because it affects the AAC codec and how it behaves.

CFS Tweak

Currently not functional. Will evolve in time. What it will eventually do is Echo NO_NEW_FAIR_SLEEPERS to sched_features to change CFS into more of a traditional scheduler like BFS, which gives a noticeable benchmark performance boost, but hinders how gps behaves(kind of like the real BFS).


Prerequisites needed to run this

If you're running a version of CM6 or Warm TwoPointTwo RLS2 and above, this will work completely fine.

If you're running any other kind of rom, that developer will need to add an 'import' call in the init.rc(in the ramdisk) that imports the init.d script necessary for this application to function at boot. If you don't know how to do this, please see post #2.

This script will WORK even if you don't have the import call at boot, but it won't survive on the next reboot.

You can check via:

Code:
pidof batt.sh

NOTE: This script will also prompt you to try to run itself as root if you use it in terminal.


Contributors:
  • Collin_ph
  • Decad3nce
  • myn
  • onicrom
  • shabbypenguin

Download And Install:

Version 3 RC2 Download Herehttp://www.mediafire.com/?xmjdd797f6v2m90

A new guide is available: [GUIDE]* How to properly flash collin_ph battery tweak & have best battery life ever! *

  • Disable SetCPU or other overclocking programs as they will interfere with this tweak.
  • Kernels that manage and throttle CPU (ex HAVS) may interfere with the operation of this mod as they will fight and conflict with CPU deltas.
  • Download, the zip, copy to SD card.
  • Reboot into recovery and flash.
  • Reboot and run the batt-cfg configuration utility.
 
Last edited:
  • Like
Reactions: lithid-cm

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
Help us debug!

Having issues with this mod? Help us debug your issue by doing this:
Code:
adb shell batt-diag -v > battdiag.txt

and upload that txt file so that we can diagnose your problems more thoroughly.

For ROM Developers
You need 3 things for the script to survive a reboot:

  • A clockable 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
  • Proper file structuring/permissions(The update script in the update.zip really does all of this for you)



Future Development:

I'd love to have a bunch of developers contributing to this project. I maintain this project out on github branched from Collin_ph's base code. If you'd like to contribute let me know and I'll add you as a contributor to the project.

http://github.com/myn/battery-tweak-v3


Original Source: http://github.com/collinph/battery-tweak-v3
 
Last edited:
  • Like
Reactions: lithid-cm

tonwarr.the.incredible

Senior Member
Jun 10, 2010
558
31
Quick question....is v3 the same that was included with rls2?? Another question that was asked in your ROM thread, does this need to be activated via ADB or does flashing activate? Thanks in advance and keep up the phenomenal work.:D
 

luckylui

Senior Member
Aug 14, 2010
4,556
555
Chi-Town
OnePlus 9 Pro
So far so good myn. I jumped right in and gave it a shot w the latest stock kernel.. Will report as i go :)
Thanx much man!!!

Sent from my phone... I think Tapatalk??
 

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
Quick question....is v3 the same that was included with rls2?? Another question that was asked in your ROM thread, does this need to be activated via ADB or does flashing activate? Thanks in advance and keep up the phenomenal work.:D

Yes. V3 is the same as what was included in RLS2. This mod is automatically activated as soon as you flash it.

I assume you use this OR SetCPU and can't use them both together as it sounds like they would clash...

Swyped from my supercharged Evo!

Can I use this AND keep setcpu a long as I don't use profiles?

Wouldn't this interfere with havs the same way that profiling in setcpu does?

Sent from my PC36100 using XDA App

Exactly. Anything that controls the CPU may conflict with this mod.

I'd love to hear feedback from people about what configurations work and what don't though. :)
 

lido

Senior Member
Nov 2, 2006
134
26
Yes. V3 is the same as what was included in RLS2. This mod is automatically activated as soon as you flash it.





Exactly. Anything that controls the CPU may conflict with this mod.

I'd love to hear feedback from people about what configurations work and what don't though. :)

Myn, what kernal do you recommend given the potential conflicts with the tweak?
 

locoboi187

Senior Member
Aug 5, 2010
2,053
253
I'm running king's aosp cfs kernel #1 and scared to run this script on my phone. Should I be fine?

Sent from my PC36100 using XDA App
 

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
I'm running king's aosp cfs kernel #1 and scared to run this script on my phone. Should I be fine?

Sent from my PC36100 using XDA App


Don't let the first post scare you hehe.

If you just flash it, it automatically is enabled and configured for your EVO. No configuration needed.

Give it a try. If it doesn't work, you can always remove it or turn it off.
 

mm55502003

Member
Apr 14, 2010
23
0
Sry, still quite new to the whole flashing rom and kernel thing.
I'm just wondering if im using the king's #11 CFS kernel, would it conflict with this tweak?

*PS i dont think i have setCPU install or enable. I just flashed the kernel to the rom that I'm using right now if that helps

thanks in advance!
 

casual864

Senior Member
Jun 8, 2010
225
2
San Francisco
How do I know if it's enabled or not? Using ADB shell after I flashed it won't show anything after I enter the pidof batt.sh. It brings me back to #. I am running a sense ui stock deodexed rom.
 

Tiffany84

Inactive Recognized Themer
Jul 27, 2010
6,280
3,323
So u dont need to enter batt-cfg in terminal to activate? Simply just flashing it activates it?
 

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
How do I know if it's enabled or not? Using ADB shell after I flashed it won't show anything after I enter the pidof batt.sh. It brings me back to #. I am running a sense ui stock deodexed rom.

Unfortunately the stock sense UI stock deodexed rom does not support the call to init.rc.

See below for prereqs:


Prerequisites needed to run this

If you're running a version of CM6 or Warm TwoPointTwo RLS2 and above, this will work completely fine.

If you're running any other kind of rom, that developer will need to add an 'import' call in the init.rc(in the ramdisk) that imports the init.d script necessary for this application to function at boot. If you don't know how to do this, please see post #2.

This script will WORK even if you don't have the import call at boot, but it won't survive on the next reboot.

You can check via:

Code:
pidof batt.sh
 

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985

Beejis

Senior Member
Nov 14, 2008
1,662
211
Washington
I'm having trouble finding the newest stock htc kernel, can someone help me/us with a link please since this doesn't play nice with havs?

Sent from my HTC Evo 4g
 

gotshores

Senior Member
Aug 4, 2010
613
59
San Antonio
I enabled the cfs tweak using terminal emulator and then flashed kings #11 cfs. I'm not getting high CPU usage and when I'm idle its staying around 245mhz. We will check battery results tomorrow.

Sent from my PC36100 using XDA App
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Background

    As many of you recently saw in my Warm TwoPointTwo RLS2 thread there was an optional download for Collin_ph's battery tweak ported to the EVO by me.

    This mod was so large I figured It deserved it's own thread and at the same time I'd like to share it with the community so other ROM devs can incorporate this into their ROMs

    This is really a tool for power users

    If you don't consider yourself 'comfortable' with messing with your phone, then don't.

    This is mostly the work of collin_ph, all the ideas are mostly his and I have only contributed in part to getting some things functioning correctly and some optimizations for the EVO and INCredible. The original thread from Collin_ph can be found here and the original documentation can be found here.


    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 compcache (if enabled) for current power source
      • 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 charactaristics depending on power sourcee
        • 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 2 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 statys
      • Disable batt.sh service from running at startup
    • Includes a batt-rm.sh uninstall utility
    • Includes a batt-diag diagnostic utility
    • Includes an LED fix if your LED is stuck on
    • Includes optional experimental performance tweaks (disabled by default)
    • Includes optional Disk performance tweaks (enabled by default)
    • Includes optional froyo Audio quality fix (disables stagefright)


    The Tools

    The entire 'application' is written in shell code and was first written just to give a performance and battery boost, but since has evolved more and more.

    All the tools mentioned will be utilized either through the terminal, or in adb shell.


    batt.sh

    This is the core of the entire script. Don't mess with it.
    The one thing you should do after installing the script:

    Code:
    pidof batt.sh

    If theres any number showing up after it, then it's working fine.



    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.

    batt-cfg.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.

    batt-diag -v gives a more thorough output as you can see here; http://pastie.org/1162034

    batt-rm.sh

    It's a battery tweak removal script, follow the onscreen prompts and it should remove just about any trace of the battery tweak script.


    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 998 literally means that 998400 is the scaling_max_freq, or the max frequency, that your phone can achieve after you enable it.

    Just typing 1, and then enter, you'll be ready and set to go. Same with 2.



    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.

    customize.png


    All the settings explain what each option does, so read them carefully.

    Disk Boost

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

    Audio 'Fix'

    Disables stagefright for bettery audio quality, though it will hinder your benchmark scores only because it affects the AAC codec and how it behaves.

    CFS Tweak

    Currently not functional. Will evolve in time. What it will eventually do is Echo NO_NEW_FAIR_SLEEPERS to sched_features to change CFS into more of a traditional scheduler like BFS, which gives a noticeable benchmark performance boost, but hinders how gps behaves(kind of like the real BFS).


    Prerequisites needed to run this

    If you're running a version of CM6 or Warm TwoPointTwo RLS2 and above, this will work completely fine.

    If you're running any other kind of rom, that developer will need to add an 'import' call in the init.rc(in the ramdisk) that imports the init.d script necessary for this application to function at boot. If you don't know how to do this, please see post #2.

    This script will WORK even if you don't have the import call at boot, but it won't survive on the next reboot.

    You can check via:

    Code:
    pidof batt.sh

    NOTE: This script will also prompt you to try to run itself as root if you use it in terminal.


    Contributors:
    • Collin_ph
    • Decad3nce
    • myn
    • onicrom
    • shabbypenguin

    Download And Install:

    Version 3 RC2 Download Herehttp://www.mediafire.com/?xmjdd797f6v2m90

    A new guide is available: [GUIDE]* How to properly flash collin_ph battery tweak & have best battery life ever! *

    • Disable SetCPU or other overclocking programs as they will interfere with this tweak.
    • Kernels that manage and throttle CPU (ex HAVS) may interfere with the operation of this mod as they will fight and conflict with CPU deltas.
    • Download, the zip, copy to SD card.
    • Reboot into recovery and flash.
    • Reboot and run the batt-cfg configuration utility.
    1
    Help us debug!

    Having issues with this mod? Help us debug your issue by doing this:
    Code:
    adb shell batt-diag -v > battdiag.txt

    and upload that txt file so that we can diagnose your problems more thoroughly.

    For ROM Developers
    You need 3 things for the script to survive a reboot:

    • A clockable 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
    • Proper file structuring/permissions(The update script in the update.zip really does all of this for you)



    Future Development:

    I'd love to have a bunch of developers contributing to this project. I maintain this project out on github branched from Collin_ph's base code. If you'd like to contribute let me know and I'll add you as a contributor to the project.

    http://github.com/myn/battery-tweak-v3


    Original Source: http://github.com/collinph/battery-tweak-v3
    1
    with the disabling and removal of the tweak these flush problems are gone

    dont know what they are, how they got there, or why they are involved with the tweak. but i gotta move on....sorry tweak