IOS – Where does iPhone store information about current battery percentage

batterychargingiosiphonememory

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?

Best Answer

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.