[Galaxy S III General] danarama:
Note from the Author -

I am moving on to the N5 now and ditching my S3. I will continue to maintain this thread, however - please do PM me if you think that something needs to be changed or updated in this thread as I doubt I will be answering questions within the thread as much. Please don't PM support questions to me. Only PM updates that need to be made in the thread.

It's been a blast!

Regards

Dan

Who are you?

OK, firstly - I am simply a poweruser of the SGS3. I have spent many hours (of many days of many weeks of many months) over the last 3 years examining Google's Android source code. Compiling it, improving upon it, fixing it and developing it. Am I a professional developer? No. …But I enjoy it and spent a lot of time doing it. I don't develop for the S3. There are plenty of developers already. I feel I have nothing to bring to the table. There are no gaps that need to be filled (which was why I started developing in the first place).

Why did you write this?

I’m often seeing people ask where the “wipe battery stats” option has gone in recovery x, because they “need it”. I also see people offer up “wipe battery stats” as part of a resolution for poor battery life, sudden battery % drops and charging % issues. It is not.

It also requires root. I don’t want people running around rooting their phone to do something that they do not need to do. This “advice” is often offered without any explanation or guide to do it, leaving people who don’t really understand at the risk of doing something they do not feel comfortable with or worse, inadvertently and indirectly contributing to someone breaking their phone. You DO NOT need to wipe your battery stats.

So, down to business.

What are battery stats?

There is a battery stats UI compiled into Settings.apk (and Sec-settings.apk). When you go into Settings via the android menu, you can go into “battery” and see a basic usage report of what has been using your battery.

What does it show?

It shows you (for example – not exhasutive) how long you have been connected to WiFi, how long your screen has been on, what the estimated % of battery used by these elements are

What do you mean “estimated”?

Well it doesn’t know exactly. It uses calculations based on pre-determined values to calculate the results, but many environment and set-up variables mean these pre-determined values are never 100% accurate. They are an Average or a “best guess”.

OK, how does it work?

What the battery stats UI shows

1.	The overall battery state (present % + charging state)

2.	Time on battery

3.	Percentage of battery device elements are responsible for using

…is based on a few elements:

1.	The overall battery management system of android (not really relevant here)

2.	/data/system/batterystats.bin

3.	/system/frameworks/frameworks-res.apk/res/xml/power_profile.xml

...which contribute in the following way:

1.	Shows the current battery state. “Battery stats” does not individually hold this information.

2.	From the moment Android detects a close-to-full charge has completed, it records how long things are running here

3.	This is where the information about how much power, each device element “uses”

The battery stats UI looks at batterystats.bin to see how long each element has been running (and in what state) since the last charge, applies the value (in mV) for each element stored in power_profiles.xml and comes up with a calculation of the % of battery each element is using. It doesn’t factor in what the present battery level is.

It simply knows the total mV used by adding up all the element values and the time in state to work out the percentages.

Here is a really basic example…

power_profile.xml from the S3

<item name="screen.on">71</item>
<item name="bluetooth.active">17</item>
<item name="bluetooth.on">0.3</item>
<item name="screen.full">380</item>
<item name="wifi.on">0.3</item>
<item name="wifi.active">96</item>

batterystats.bin

screen.on = 2 h
bluetooth.active = 3 h
bluetooth.on = 7 h
wifi.on = 6 h
wifi.active = 4 h

So, if….

screen.on = 142
bluetooth.active = 51
bluetooth.on = 2.1
wifi.on = 1.8
wifi.active = 384
Total = 580.9

Then…

screen.on = 24%
bluetooth.active = 8.4%
bluetooth.on = 0.3%
wifi.on = 0.3%
wifi.active = 66%
Total = 100%

That was a basic example of how the Battery Stats UI makes it’s calculations.

What exactly does Wiping battery stats do?

It literally clears /data/system/batterystats.bin of:

screen.on = 2 h
bluetooth.active = 3 h
bluetooth.on = 7 h
wifi.on = 6 h
wifi.active = 4 h

That’s all it does.

How do you wipe battery stats?

There are 3 ways.

1.	Charge your phone to nearly full (This resets battery stats)

2.	Wipe via custom recovery with root (Most recoveries have started to remove this option though)

3.	Manually delete /data/system/batterystats.bin (also requires root)

How does this help with poor battery life, sudden battery % drops and charging % issues?

It really doesn’t help at all. It is not aware of the % of battery you have used or have left. It is not aware of any charging procedure other than when Android tells it to wipe itself due to a full charge. It is not linked to the actual battery in any way. All it does is store information on how long element x was in state y. Thinking that battery stats are linked to the battery performance in any way is a massive misconception, as described here by Diane Hackborn, one of Google’s Android developers:

Conclusion

Wiping battery stats will not help you with your battery life in ANY way. If anyone tells you to do this, please be aware it is pointless. They may say “It can’t harm anything”, and they would be right – unless you think it’s necessary and you decide that you must root in order to do this. Charging the phone close to full will wipe battery stats. No root method is ever required. It is a waste of time and a wild goose chase.

Wiping these stats cannot help rule out, identify or resolve any symptoms pertaining to your battery life.