• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root 1% Battery Stats! - Circle Battery Widget

The inconsistencies are there because you are not wiping the battery stats every time you switch batteries. Either do it in CWR or download BatteryCalibration from the Market.

It's going to be difficult for you to get an accurate reading since you switch out batteries so often.


bouchigo,

So, what are you wiping in CWR...the cache/data? Or is there an actual battery stats wipe? Next, does this BatteryCalibration wipe out the stats as well?
 
Upvote 0
My quest continues for an understanding of battery reporting. I have done the battery calibration, both from the app and from CWR, with a full battery, followed by allowing it to fully drain until it shuts itself down and won't come back on, then replacing the battery with a fully charged one from the separate charger, but yet my same problems persist.

I'm looking for info on exactly what such battery reporting is really measuring. In my quest, I have found some other apps that others may find interesting.

One is called Battery Circle, which also gives 1% increment readings, but also shows the info in the notification/status bar instead of as a widget. The notification bar icon shows a colored circle indicator with a number inside.

The other is Battery Monitor Widget, which offers a plethora of information. This showed me that the phone still thinks I'm using a 1500 mAh battery, which is not correct. It also has a place to manually enter your battery's total capacity, and min and max voltages.

Also nice is the fact that I'm running SSX rom, which offers an option to hide the normal battery icon from the status bar, which only did 10% increments and is redundant with Battery Circle.

I hope someone finds this info useful, and if anyone can point me to info regarding what the battery reporting is actually measuring, I'm all ears.
 
Upvote 0
My quest continues for an understanding of battery reporting. I have done the battery calibration, both from the app and from CWR, with a full battery, followed by allowing it to fully drain until it shuts itself down and won't come back on, then replacing the battery with a fully charged one from the separate charger, but yet my same problems persist.

I'm looking for info on exactly what such battery reporting is really measuring. In my quest, I have found some other apps that others may find interesting.

One is called Battery Circle, which also gives 1% increment readings, but also shows the info in the notification/status bar instead of as a widget. The notification bar icon shows a colored circle indicator with a number inside.

The other is Battery Monitor Widget, which offers a plethora of information. This showed me that the phone still thinks I'm using a 1500 mAh battery, which is not correct. It also has a place to manually enter your battery's total capacity, and min and max voltages.

Also nice is the fact that I'm running SSX rom, which offers an option to hide the normal battery icon from the status bar, which only did 10% increments and is redundant with Battery Circle.

I hope someone finds this info useful, and if anyone can point me to info regarding what the battery reporting is actually measuring, I'm all ears.

3club,

I can tell you a little of what I know (or think I know ;)).

From how I think things work, you've got the information that the circuitry in the battery reports (voltage, temperature info, etc.) back to the Android operating system. Android records this information in the batterystats.bin file (located for the Droid X in /data/system/batterystats.bin -- that's the file that gets deleted when you do a "wipe battery stats").

Additionally, Android records this information in a set of files that are a little more palatable for external viewing (or more likely, various APIs) in the /sys/devices/platform/cpcap_battery/power_supply/battery directory (on the Droid X, at least--this directory varies by phone and manufacturer).

Here's an ls -al output of that directory:

Code:
# ls -a -l /sys/devices/platform/cpcap_battery/power_supply/battery
-rw-r--r-- root     root       4096 2011-08-19 21:05 uevent
lrwxrwxrwx root     root              2011-08-19 21:05 subsystem -> ../../../../../class/power_supply
lrwxrwxrwx root     root              2011-08-19 21:05 device -> ../../../cpcap_battery
drwxr-xr-x root     root              2011-08-19 21:05 power
-r--r--r-- root     root       4096 2011-08-19 21:05 type
-r--r--r-- root     root       4096 2011-08-19 21:05 status
-r--r--r-- root     root       4096 2011-08-19 21:05 health
-r--r--r-- root     root       4096 2011-08-19 21:05 present
-r--r--r-- root     root       4096 2011-08-19 21:05 technology
-r--r--r-- root     root       4096 2011-08-19 21:05 capacity
-r--r--r-- root     root       4096 2011-08-19 21:05 voltage_now
-r--r--r-- root     root       4096 2011-08-19 21:05 temp
-r--r--r-- root     root       4096 2011-08-19 21:05 charge_full_design
-r--r--r-- root     root       4096 2011-08-19 21:05 charge_counter

These files correspond to the values reported when an app listens/subscribes for the BATTERY_CHANGED / ACTION_BATTERY_CHANGEDsystem intent.

Most of the files' purpose is self-evident, but you should know that the charge_counter file is the one that contains the 1% battery percentage delta values (note: the values in this file can exceed 100, probably due to the variation in a battery's actual capacity).

The capacity file is what is referenced by the system in reporting and showing the percentage charge on the notification bar's battery icon on your phone. Of course, its values are reported in 10% increments vs. the 1% values recorded in the charge_counter file. I suspect that this is primarily done by Moto given, again, the variability between batteries and the imprecise nature of what a battery's actual reported charge.

Having an app (like my BattMonX app) report the 1% percent charged delta requires directly reading the charge_counter file.

For more details on what and the format reported by the aforementioned system intent, see this page:

BatteryManager | Android Developers.

Also, you might gain some insight on your particular problems from here:

http://androidforums.com/droid-x-support-troubleshooting/383790-phone-not-charging-when-dead-unable-find-help-anywhere.html

Do You Know Everything There Is To Know About Lithium Ion Batteries? If Not, Read This… | xda-developers

Things You Should Know About Lithium Ion Battery - xda-developers

Hope that helps.

Cheers!
 
Upvote 0
Thanks Scary, that's all good info. I'll try your app out too.

So if I understand what you've taught me, it seems like all the programs either read the capacity or charge_counter file, and the capacity file is really just the rounded off value from charge_counter. So none of these programs are really measuring or calculating the remaining battery life, just reporting what the phone itself puts into that file, right?

So I guess I'm still wondering how the value in the charge_counter file gets figured.
 
Upvote 0
Thanks Scary, that's all good info. I'll try your app out too.

So if I understand what you've taught me, it seems like all the programs either read the capacity or charge_counter file, and the capacity file is really just the rounded off value from charge_counter. So none of these programs are really measuring or calculating the remaining battery life, just reporting what the phone itself puts into that file, right?

So I guess I'm still wondering how the value in the charge_counter file gets figured.

Well, I would actually guess that most apps actually use the system intents to get these corresponding values vs. reading the files directly. The early versions of my app actually did read these files directly before I realized I could use the system intent (although I still have to read the charge_counter file directly in order to get the 1% charge delta value).

From what I understand, the charge_counter file is actually populated by the kernel in the ../kernel/drivers/power/cpcap-battery.c source file. Some devs have tried to re-direct the value of this file over to the capacity file, but doing this temporarily "breaks" the reporting of the capacity file (the source code shows that this can happen) until a reboot is performed (I can't find my link to the above source at the moment, but if you want, I'll track it down).

So, its really the kernel that is doing the communication with the battery and reporting that back to the rest of the Android operating system. Unfortunately, we can't replace the kernel on the Droid X, so we're stuck with these work-arounds at this point.

Cheers!
 
Upvote 0
From what I understand, the charge_counter file is actually populated by the kernel in the ../kernel/drivers/power/cpcap-battery.c source file. Some devs have tried to re-direct the value of this file over to the capacity file, but doing this temporarily "breaks" the reporting of the capacity file (the source code shows that this can happen) until a reboot is performed (I can't find my link to the above source at the moment, but if you want, I'll track it down).

So, its really the kernel that is doing the communication with the battery and reporting that back to the rest of the Android operating system. Unfortunately, we can't replace the kernel on the Droid X, so we're stuck with these work-arounds at this point.

Cheers!

Well, I think I found the source here [C] cpcap-battery.c - Pastebin.com

lol, too bad I'm not a programmer who can read what it says! lol

It doesn't look much like the BASIC programming we did in school 25 years ago!
 
  • Like
Reactions: scary alien
Upvote 0
lol, you type faster than I do!

LOL right back at cha! ;).

Yeah, I was busy answering Introduction threads and I took a break and did a quick search for it...it was the original thread that I saw this in a while back. I've downloaded the Moto source, too, but I'm assuming its the same or similar code to what's in the pastebin (the source is massive, LOL, haven't unpacked it yet).

Anyway, like I said, its interesting reading, but is a academic exercise at this point :).

Cheers!
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones