I am trying to make my device stop charging (
echo 0 > /sys/class/power_supply/battery/charging_enabled, the easy part) when the battery's voltage reaches 3920000 µV.
cat /sys/class/power_supply/battery/voltage_now or
dumpsys battery, I can also tell that the battery is at a certain voltage, like
3916000 (in µV). When the device is not charging, this number is the battery's charge voltage, the number I want. However, when the device is connected to a charger (DC out is normally 5V), this value is neither the battery's voltage, nor the input voltage, but some value in between, because of how charging works.
voltage_now does not reflect the battery's rest voltage when charging, and this number is dependent on which charger I use, I cannot obtain the number I need (
3920000) whenever the device should stop charging. So apart from pulse charging and sampling, how should I get the battery's non-charging voltage from the shell while charging?
Note: "manually calculating the battery percentage when the voltage is 3.92V, and then stopping charging when
/sys/class/power_supply/battery/capacity reaches that number" is not a satisfactory answer or workaround.