As you know the li-ion batteries have flat voltage curve and it is not possible to detect battery state of charge (SOC) from voltage accurately. We use fual-guage which measures the accumulated charge. Since, this is integration method we correct the battery state of charge when the battery gets fully charged (battery voltage 4.2V). It is important to detect the battery capacity (mAH) to accurately measure battery SOC (battery %). But the battery capacity varies over time and from one battery to other. Battery needs to be calibrated over time and first time we connect. What is the standard technique followed by mobile/laptop manufacturer for the battery calibration?
There are multiple techniques with various tradeoffs between them. If you search the literature for "battery fuel gauge" you should come up with a number of techniques.
Note that you can actually estimate SOC from voltage, provided the load is zero and the battery has been allowed to rest in this state for a while (hours). This relationship is not linear though, so you need to characterize the particular battery you're using and use some sort of a lookup table. Your voltage measurements also need fairly high precision and accuracy.
A more reliable method is coulomb counting, during both the charge and discharge cycles. This will provide a very accurate assessment of the amount of stored energy, and you only need to subtract out any self-discharge (which should be very small). However, measuring the current is a bit more costly, in terms of size, power loss, and $. And due to the self-discharge rate being variable and unknown, this technique needs periodic calibration or it will start to drift off from the true reading. This is typically done by resetting the high and low points after a full charge or full discharge respectively.
You can also combine these techniques (and possibly others) for even more accuracy and to mitigate drift effects.
This is how one manufacturer of battery fuel gauge ICs implements it: https://www.maximintegrated.com/en/design/partners-and-technology/design-technology/modelgauge-battery-fuel-gauge-technology.html