battery_charge_counter

Post your questions and help other users.

Moderator: Martin

Post Reply
Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

battery_charge_counter

Post by Wibbly » 28 Jan 2020 14:32

There are some variables that are reported after a battery related trigger or condition

battery_charge_counter, which is "Battery capacity in microampere-hours. null when not available"
battery_level, which is "the charging level of the battery"
battery_percentage, "the charging percentage"

1. Both battery_level and battery_percentage seem to report the same (a number that changes each whole % change in battery level). Anyone know what the difference is?

2. Also, anyone know, do these take into account battery ageing? So a new battery at, say, 50% battery_level or battery_percentage will have a certain battery_charge_counter level. But will an old battery with depleted capacity be reported at a lower battery_charge_counter level at the same reported 50%?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: battery_charge_counter

Post by Desmanto » 28 Jan 2020 19:06

1. At mine, both the same. Difference is level show integer, example 50, while percentage show float with 1 decimal, 50.0

2. I don't know aging calculation. Charge_counter change as you charge the phone not in full cycle. My RN5 is 4000 mAh. At full, charge_counter is usually around 3900000 (it is shown in microAh). But because I seldom use it until below 50% and my charging pattern is random, sometimes charge_counter can show me minus. I ever get -4000000 when I try to use it until close to 0% (for measuring maximum SOT). So we can't relied on this.

Voltage won't help, as it can rise and fall depends on current ampere usage. When in high drain, voltage usually drop; and vice versa. Maybe sometimes we should just relied on android itself to report to us about current battery level. I usually just take it. But I know there are some aging happen already. Example 1,5 years ago, similar pattern usage only drain 5%/hour. Now it drains about 7%/hour. It is not exactly the same, as I have change the ROM, kernel and already maybe have different app version/more flows or other. But roughly I can say my battery capacity already decreased to about 80% of it original.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Re: battery_charge_counter

Post by Wibbly » 29 Jan 2020 11:13

Thanks

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: battery_charge_counter

Post by Desmanto » 30 Jan 2020 17:58

It seems you can pull the real capacity of the device using adb (or direct execute root command if you have root). At mine

Code: Select all

cat /sys/class/power_supply/battery/charge_full_design
gives me original battery capacity, which is 4000 (4000 mAh), unchanged.

Code: Select all

cat /sys/class/power_supply/battery/charge_full
gives me full charging mAh, which is now 3481000 (3481 mAh). This seems to show my battery aging capacity, after using it for more than 1,5 years, which is about 87% of the original capacity. This maybe can serve as my SOT calculation later. So if now I can get SOT for 8,7 hours; divided by 87%, I would expect the original SOT should be 10 hours.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Re: battery_charge_counter

Post by Wibbly » 30 Jan 2020 19:19

Are these commands that can be used from an AM script? Without root, by granting AM a permission via ADB?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: battery_charge_counter

Post by Desmanto » 31 Jan 2020 10:51

No, this must use execute root command. And I can't find any way to grant the permission necessary. Maybe dump/read log permission introduced in AM 1.38 (EAP) won't work neither.

But as I know, a lot of app can read battery status without root. So there must be some java code to do it without root access. But of course, it is outside of my current knowledge.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply