A smartphone (assume it to be an Android) usually displays the battery percentage from 0 to 100%. I am assuming that this is the usable capacity of the battery. I have several questions:
How exactly does it measure the remaining capacity? Assuming a battery is rated to be 3.2V, it might be providing 3.3 V when fully charged and the minimum required voltage of the phone might be 3V. Does the 0-100% refer to 3V to 3.3V? Is this calibration made only once during the time of manufacture?
How is the remaining capacity measured so accurately? Are the measurements averaged over a period? If so, what is the sampling frequency and how many reading are averaged to get the final?
How is the remaining capacity % measured when the phone is charging? I guess the output voltage might be different when it is charging.
How is calibration of battery percentage affected by ambient temperature? I am aware that batteries nowadays have temperature sensors. Is the temperature used to calculate the battery capacity remaining or the optimum charging rate?
Assuming battery consumption is not linear as the battery discharges... (intensive games, etc). How does the smartphone handle variable discharge rates? There exists multiple apps to re-calibrate batteries. How do they work?
How does the OS determine battery usage of each app? Is it just based on CPU cycles and screen time or is there some actual measurement of power dissipation?