Generally, charge estimation based on voltage is very inaccurate if we are speaking about Li-Ion-like batteries but old phones used this prediction.
However, there are "battery fuel gauge" ICs which a modern phone should use and it measures incoming/outgoing charge of the battery (charge / discharge quantity). It may have a very good prediction based on charge/discharge current, voltage, elapsed time, predicted battery degradation, etc.
...so it is much more complicated than simply measuring battery voltage what would be very inacurate if we are speaking about accurate percents...