LiIon batteries keep their voltage pretty stable so remaining capacity is mostly derived by keeping track of usage and charging. The only well known states are that the battery is 80% full when reaching 4.2 Volt during charging, completely full when drawing no more charging current at 4.2 Volt...