[Google Pixel 3 XL Questions & Answers] ubergeek77:
Ever since the March update, my Pixel 3 XL's battery indicator in the status bar has been horrendously inaccurate. This is really annoying, as it always shows as having 10-12% less battery than the actual physical battery charge. If it ever reaches 0% and shuts down, if I were to, say, boot into TWRP, I'd see I still have about 11% battery remaining. Across all the phones I've owned over the years, I've never seen such a severe battery level mismatch before. I've never seen greater than a 2% difference in any phone I've owned.

I use the Advanced Charging Controller Magisk module to regulate how much my battery charges. Charging your phone too much is proven to damage your battery over time, so I like to set ACC up so that my phone never charges past 41%.

I first noticed this problem when my battery would stop charging past 31%. After digging deeper, I found that the battery level produced by "dumpsys battery" (used by the status bar indicator) does not match the actual battery level, which can be read from a kernel control file at "/sys/class/power_supply/capacity."

As a side note, is your battery indicator also incorrect? Try checking it running these commands as root, and compare the values. Maybe this affects you too:

cat /sys/class/power_supply/battery/capacity

dumpsys battery

(The number you're looking for in the "dumpsys" command is the number next to "level." If it doesn't match, and it's less than what's written to the capacity file, then you also suffer from this issue).

I've asked the ACC developer what can be done about this, and apparently not much, besides having ACC "pretend" the battery is offset by a user specified battery level. But in my case, I would just be charging my actual battery to 51%, even though it would display as 41%, and I don't want to do that. I tried fixing it by clearing my battery stats, charging to 100%, and etc, and it actually made matters worse for me - the status bar indicator now remains at 12% less than the actual battery level. No matter what, this value appears to be linear - it doesn't seem to be any more or less correct depending on how charged the battery is. It's always 12% less, unless you get beyond 88%. Then the statusbar pretends to charge, even though a voltage monitor will show that it is not charging.

I can "force" the statusbar to read as the most accurate battery level by running this command in the background in a root shell:

while sleep 15; do dumpsys battery set level $(cat /sys/class/power_supply/battery/capacity); done

This manually sets the battery level via dumpsys according to what the actual battery level is. But this has some limitations.

I'm using a while loop because setting a value like this is permanent - if I don't either continually set it or unset it, my phone will think my battery level hasn't dropped below the last set value.

However, more importantly, setting a value via dumpsys disables monitoring of other battery stats, such as voltage, temperature, current, whether or not the battery is charging, the charge counter, and etc. Just running a script like that isn't a good solution.

So since I have nowhere else to ask, is there any kind of root mod or something that can be made to force the phone to use the correct battery level? I don't know why this started happening since the March update, but it is extremely annoying, and I'd like to put an end to it as soon as possible.

Any insights to mods or tweaks that can be done to fix this would be greatly appreciated.