daemon: Mark read-only charge thresholds as unsupported (Linux)
Some systems will provide a start threshold value, but cannot set it because the firmware derives it from the end threshold. In this case, we're better off just marking it as unsupported altogether.
For a more in-depth explanation with Apple Macs as example, see: https://gitlab.freedesktop.org/upower/upower/-/merge_requests/208#note_2531122
This commit includes a subtle change to the getthresholds method: Instead of returning the lowest end threshold and the highest start threshold, it will now return the single start threshold that corresponds to the lowest end threshold. Whether or not that start threshold is supported by the given battery.
Bonus commit:
daemon: Stop supporting Linux kernel < 5.9 for charge thresholds
It's been long enough, we can assume that people running a brand-new Plasma desktop aren't staying on a 4+ year old kernel.
Test plan
- Check out branch, change
s_chargeStartThreshold
in daemon/chargethresholdhelper_linux.cpp from"charge_control_start_threshold"
to"capacity"
which is read-only (assuming you don't have a device with read-only start threshold file, same as me).- Build, make sure the build product is used instead of the distro's own KAuth helper.
- Open "Power Management" KCM in System Settings, verify that only the stop threshold is listed, change & apply to verify that it will also be written without trying to write the start threshold.
- Back out the
"capacity"
hack and test the vanilla MR.- Build, make sure the build product is used instead of the distro's own KAuth helper.
- Open "Power Management" KCM in System Settings, verify that both your stop and start thresholds are still listed just like before.