2

I wonder how is it exactly with the calculation of the battery percentage: from 100% down the software calculates which resources were used and for how long and thus it approximates the current battery state. But where is it stored - as logs, or as app data? I mean what happens with this information after hard reset or DFU mode - in DFU mode iOS is not loaded, but this software still runs? How does it know what is the percentage after switching it on again? Is charging in DFU mode still causing the software to calculate the approximate percentage?

14
  • I've updated my answer with more information including where the battery usage logs are stored. If my answer helped, please mark it as the correct answer (there's a checkmark you can click next to it). – Andrew Larsson Feb 14 '16 at 6:23
  • And if there's any information I can add or further explain, don't hesitate to provide feedback. – Andrew Larsson Feb 17 '16 at 23:23
  • Thanks for the answer and all, but how can I know it is good? In one of the podcasts I heard that Iphone is calculating the usage based on time and power of used resources, reportedly that's why there is a need for calibrating the battery to let the device know when it is really 0%. If it was based on the voltage, would it need the calibration? I will gladly accept your answer, but I counted on more answers to compare, or at least on some hints where to find it in official apple documents. I appreciate your help, but I would like to know if it is your guess or you know it from somewhere... – n-dru Feb 18 '16 at 5:20
  • There were pieces I knew and pieces that were deductions I made based on how these things are commonly done. I did a bunch more research, because I was curious, and I wanted to prove my answer for you. I have updated my answer below to reflect my new findings. Remember, though, most of this is just me referencing someone who referenced a disassembled version of iOS and Apple's code, so interpretations and misinformation can be present, and I can't prove any of it, because Apple's code is protected by copyright law, and thus cannot be published. – Andrew Larsson Feb 24 '16 at 1:00
  • As far as battery calibration is concerned, I do not believe Apple's code makes use of such a thing anywhere. I could be wrong, but there's no need for them to "re-calibrate" when they have science and known statistics at hand. Read the link on "more information about determining capacities" to see what I'm talking about. – Andrew Larsson Feb 24 '16 at 1:04
3

All of the battery and power usage information (including approximately how much power applications and certain system processes use over time) is stored in /var/mobile/Library/BatteryLife/CurrentPowerlog.PLSQL and /var/mobile/Library/BatteryLife/Archives/powerlog_*.PLSQL. This data is both used to aid in the calculation of battery percentage and to unmask power-hungry applications.

Apple's algorithm for battery percentage is based on a number of factors: the maximum capacity of the battery (known based on the battery that the iOS device was manufactured with), the remaining capacity of the battery (calculated based on Voltage), power usage over time (stored in CurrentPowerlog), and current power usage (calculated based on draw). This data is all put together to extrapolate an estimated remaining capacity which iOS displays as the battery percentage.

When the iOS device is in a different mode other than iOS (such as DFU Mode or Recovery Mode), it does not store or read any information from the CurrentPowerlog database; it uses the direct method of determining the capacity of its Lithium-Ion battery: simply the Voltage that the battery is currently outputting. Take a look at a Voltage over time chart for Li-Ion batteries, and you may wish to read more information about determining capacities for Li-Ion batteries.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .