How does a smart phone measure the battery power?
As mentioned in the comments, it uses fuel gauge. There are several algorithms for Li-Ion chemistry, and the gauge might use one or more of them.

The most basic one is the Columb counter. The fuel gauge has a current shunt with an amplifier and measures the consumed current, sums it over time and compares it to the programmed battery capacity.

An addition to the Columb counter is impedance tracking, in which the fuel gauge tries to measure the battery's impedance. A lithium ion cell has a specific impedance for each state of charge, so an estimate can be made regarding the amount of charge left.

The fuel gauge usually has its own temperature sensor to compensate for various temperature related effects.

It reports its status via I2C (SMbus in some cases) to the main processor.