How to manually trigger battery history reset

Search This thread

kyva1929

Senior Member
Jun 20, 2013
62
4
Android by default resets the battery history once battery is charged beyond 90% or when certain other conditions are met.

What I did which did not work:
Delete /data/system/batterystats.bin while android is running.
Battery history is still there

What I did that work:
Delete /data/system/batterystats.bin in adb while in recovery.
Battery history got reset.

But I am looking for an easier way to do this - the android system can reset the battery history on the fly without the need of going to recovery/reboot.

Before you say deleting this file won't help with the battery life - yes, I am very award of this myth. But all that I am looking to do is really just to reset battery history on the fly, because I often amass weeks of battery history that it becomes difficult for me to look at how the battery is doing in the past few days or so.

Charging battery above 90% would of course work, but this is not what I am looking for. I want a way to manually and instantly reset the battery history.

Thank you! I appreciate your input and help.
 
Android by default resets the battery history once battery is charged beyond 90% or when certain other conditions are met.

What I did which did not work:
Delete /data/system/batterystats.bin while android is running.
Battery history is still there

What I did that work:
Delete /data/system/batterystats.bin in adb while in recovery.
Battery history got reset.

But I am looking for an easier way to do this - the android system can reset the battery history on the fly without the need of going to recovery/reboot.

Before you say deleting this file won't help with the battery life - yes, I am very award of this myth. But all that I am looking to do is really just to reset battery history on the fly, because I often amass weeks of battery history that it becomes difficult for me to look at how the battery is doing in the past few days or so.

Charging battery above 90% would of course work, but this is not what I am looking for. I want a way to manually and instantly reset the battery history.

Thank you! I appreciate your input and help.

You tried deleting batterystats.bin which did not immediately take effect. You need to restart phone after deleting it when Android is running.

Immediate reset stats is only available in Android Kitkat 4.4.x.
Open battery history from settings and press that dustbin icon.

3 working solutions for pre-kikat

1) Delete batterystats.bin when android is running and reboot. (You can also do fast reboot from ROM Toolbox or Rebooter app.
Do not confuse with fastboot
Or type this in terminal
Code:
$ su
# busybox killall system-server
This reboots fast than normal reboot.

2) Delete batterystats.bin from recovery and reboot.

3) Make a script that will delete batterystats.bin and (fast) reboot phone and create its shortcut on home screen.

Press Thanks if helped.

Sent from my GT-I9001 Gadget of Mass Destruction with CM11 using XDA Developers App.
 
  • Like
Reactions: kyva1929

kyva1929

Senior Member
Jun 20, 2013
62
4
You tried deleting batterystats.bin which did not immediately take effect. You need to restart phone after deleting it when Android is running.

Immediate reset stats is only available in Android Kitkat 4.4.x.
Open battery history from settings and press that dustbin icon.

3 working solutions for pre-kikat

1) Delete batterystats.bin when android is running and reboot. (You can also do fast reboot from ROM Toolbox or Rebooter app.
Do not confuse with fastboot
Or type this in terminal
Code:
$ su
# busybox killall system-server
This reboots fast than normal reboot.

2) Delete batterystats.bin from recovery and reboot.

3) Make a script that will delete batterystats.bin and (fast) reboot phone and create its shortcut on home screen.

Press Thanks if helped.

Sent from my GT-I9001 Gadget of Mass Destruction with CM11 using XDA Developers App.

Thank you, that works.

I was looking at the logcat and see that

WriteUnpluggedReferenceService was called to reset the battery stats. Is there any way that we can manually call this service? I think people debugging the android system should probably have access to repeating these steps in order to replicate a problem?
 

heross

Senior Member
Oct 14, 2007
826
208
delete batterystats.bin works no more in Lollipop.
For testing Batterie life any time i need a clear history without charge to 100%.
Is there a way to reset the history on the fly in lollipop without charge to 100%?

In the Web i have found this: /com/android/internal/os/BatteryStatsImpl.java

// We will reset our status if we are unplugging after the
// battery was last full, or the level is at 100, or
// we have gone through a significant charge (from a very low
// level to a now very high level).
if (oldStatus == BatteryManager.BATTERY_STATUS_FULL
|| level >= 90
|| (mDischargeCurrentLevel < 20 && level >= 80)) {
doWrite = true;
resetAllStatsLocked();
mDischargeStartLevel = level;

with this info is there a developer that can write a little program which do the same as charge to 100% at any time?
 

DiamondJohn

Recognized Contributor
Aug 31, 2013
7,380
7,395
Sydney
I noticed my post from 2018 got a recent like, so it brought my attention to this question/thread again. Thumbs up on the search!

Since the above post, I have published a utility app (best if your rooted) that has the above as well as 500+ other shell commands enabled via a GUI. Its called TeMeFI

You can find the above command at Currently Running>Battery>Battery Reset and also its shortcut-ted from Current State>Reset Battery Stats

If yur interested in your battery stats, you may alsop be interested in the Battery History Graphs built within the app. As well as Doze history.

 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    Code:
    dumpsys batterystats --reset;
    1
    Android by default resets the battery history once battery is charged beyond 90% or when certain other conditions are met.

    What I did which did not work:
    Delete /data/system/batterystats.bin while android is running.
    Battery history is still there

    What I did that work:
    Delete /data/system/batterystats.bin in adb while in recovery.
    Battery history got reset.

    But I am looking for an easier way to do this - the android system can reset the battery history on the fly without the need of going to recovery/reboot.

    Before you say deleting this file won't help with the battery life - yes, I am very award of this myth. But all that I am looking to do is really just to reset battery history on the fly, because I often amass weeks of battery history that it becomes difficult for me to look at how the battery is doing in the past few days or so.

    Charging battery above 90% would of course work, but this is not what I am looking for. I want a way to manually and instantly reset the battery history.

    Thank you! I appreciate your input and help.

    You tried deleting batterystats.bin which did not immediately take effect. You need to restart phone after deleting it when Android is running.

    Immediate reset stats is only available in Android Kitkat 4.4.x.
    Open battery history from settings and press that dustbin icon.

    3 working solutions for pre-kikat

    1) Delete batterystats.bin when android is running and reboot. (You can also do fast reboot from ROM Toolbox or Rebooter app.
    Do not confuse with fastboot
    Or type this in terminal
    Code:
    $ su
    # busybox killall system-server
    This reboots fast than normal reboot.

    2) Delete batterystats.bin from recovery and reboot.

    3) Make a script that will delete batterystats.bin and (fast) reboot phone and create its shortcut on home screen.

    Press Thanks if helped.

    Sent from my GT-I9001 Gadget of Mass Destruction with CM11 using XDA Developers App.