Wrong Battery Charge Level Displayed - How to Fix
#1
Bug 
I've been playing with flashing different versions of the PinePhone OSes and noticed that when I use versions updated in the last few months, the charge level displayed on the battery icon is now incorrect. I've seen this on both Mobian and PostmarketOS with Plasma mobile and Phosh.

More specifically, on my PinePhone it displays a quarter of the battery percentage it used to show.

I haven't found much discussion of this (though there was this: https://forum.pine64.org/showthread.php?tid=17056). Who else is seeing this?

In frustration, I took a look at the code and Phosh just pulls the charge level from upowerd for the "display" device which seems to be the right way to do it.

So, I went looking at the documentation and then the source code for the UPower daemon. Sure enough, the way the battery percentage is calculated was changed in July this year:

https://gitlab.freedesktop.org/upower/up...4d_236_242

Code:
    /* use percentage weighted for each battery capacity
     * fall back to averaging the batteries.
     * ASSUMPTION: If one battery has energy data, then all batteries do
     */
    if (energy_full_total > 0.0)
        percentage_total = 100.0 * energy_total / energy_full_total;
    else
        percentage_total = percentage_total / num_batteries;

That code after the "else" didn't used to be there, so it's probably what's dividing up the charge level to a fraction of what it should be on the PinePhone. The PinePhone seems to report multiple battery devices that have no charge, in addition to one that corresponds to what I would expect.

I'm not too sure what or who are at fault here - whether the PinePhone is reporting battery data in a non-standard or incomplete way, or if there's a bug in UPower, so not sure where to raise the issue.

I think I'm going to see how easy it is to compile a patched version of the UPower daemon, with that line after the "else" removed, to solve the issue on my PinePhone.
  Reply


Messages In This Thread
Wrong Battery Charge Level Displayed - How to Fix - by acid andy - 12-22-2022, 07:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Increasing battery life slondr 8 4,717 03-19-2024, 02:15 PM
Last Post: aular
  Genode OS Now Live (finally a battery friendly PP OS?) PineFone 0 1,734 02-04-2023, 09:38 AM
Last Post: PineFone
  Interested in learning OS-level programming 8453sixtyfour 6 7,397 04-30-2022, 05:10 PM
Last Post: TRS-80
  Megapixels 1.3.0 - colors feels wrong hashfactory 0 1,324 09-11-2021, 09:26 AM
Last Post: hashfactory
  Pine phone Battery life vs operating system bcnaz 19 23,924 08-27-2021, 09:35 PM
Last Post: bcnaz
  Battery Charge Status not reporting correctly? (KDE Community Edition) Gregorius Techneticies 11 10,478 02-12-2021, 01:01 PM
Last Post: Giddyup
  Battery life for various OS & UI lat 8 11,094 12-21-2020, 08:20 PM
Last Post: ryo
  Low Battery indication (Manjaro/PostmarketOS with phosh) MamlinAV 3 5,171 12-16-2020, 03:44 AM
Last Post: dukla2000
  theoretical battery life on Pinephone hiimtye 6 7,647 12-12-2020, 01:48 AM
Last Post: jmorris

Forum Jump:


Users browsing this thread: 2 Guest(s)