Device::Battery: add UPower charge limit getter API
This introduces the following getter functions to Battery:
bool chargeLimitSupported()bool chargeLimitEnabled()bool chargeStartThresholdSupported()int chargeStartThreshold()bool chargeEndThresholdSupported()int chargeEndThreshold()
The upower backend implements these functions accordingly.
Importantly, this implementation ignores the actual threshold values exposed by the kernel directly. UPower doesn't try to read these from sysfs like Plasma has traditionally done; instead, it reads thresholds from hwdb (with reasonable 75%/80% default start/end threshold values) and applies these to the kernel indiscriminately.
This means whatever Plasma's Power Management KCM has previously configured thus far will be ignored, always returning UPower's defaults (or externally configured state) until we eventually switch over Plasma/PowerDevil to rely on UPower API as well.
Note that UPower names the first two methods
ChargeThresholdSupported and ChargeThresholdEnabled in its
D-Bus API. I believe this was an oversight in naming, as the API is
also meant to enable limits without setting particular thresholds.
Using "limits" in Solid API increases clarity, encourages good
UI strings, and is easier to tell from the actual threshold getters.
UPower provides a setter D-Bus method as well (EnableChargeLimit)
but this commit does not add Solid API for it. Given the requirement
for privileged write access, and the potential for PolicyKit to
wait for user confirmation, it seemed more straightforward to punt
the responsibility for setting the charge limit to applications
themselves.
For where & how this is going to be used, see MR plasma/powerdevil!574 and the associated plasma/plasma-workspace!5733.