Post
by Desmanto » 10 Dec 2019 18:30
It depends on too many variable : the charger used, the cable, phone condition, temperature, app running at the time, quick/fast charging, charging throttling, display on slowdown, near full slow down, battery age, battery calibration and many others. I just wonder if the accuracy can be trustworthy.
The simplest way of course is to minus the current percent from 100%, times the battery capacity and divided by the incoming current. But as the current in varies during the charging, the estimate also change and can be misleading. I know you don't mind some error/deviation, but it is just I don't know yet the typical method to get a good estimate for it.
I ever thought about creating a similar flow but I have put it down so long. Maybe the closest and easy to do calculation is still using the current. But use at least 5-10 past current to estimate the trend of the usage. Example get a 5 seconds period of the current at 5 samples; average them. If it is minus (at mine, minus mean charging), then calculate toward 100%. If it is plus, calculate remaining torward 0% as it is being used.
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.