up-device-battery: show support status for battery charging threshold

If the charging threshold is supported, the ChargeThresholdSupported will be
True.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
This commit is contained in:
Jelle van der Waa 2024-07-23 13:50:38 +08:00 committed by Kate Hsuan
parent 3df2599629
commit a955bae8c4
3 changed files with 8 additions and 3 deletions

View file

@ -224,10 +224,13 @@ up_device_supply_battery_refresh (UpDevice *device,
}
info.technology = up_convert_device_technology (get_sysfs_attr_uncached (native, "technology"));
if (up_device_supply_battery_get_charge_control_limits (native, &info))
info.charge_control_enabled = TRUE;
else
if (up_device_supply_battery_get_charge_control_limits (native, &info)) {
info.charge_control_supported = TRUE;
info.charge_control_enabled = FALSE;
} else {
info.charge_control_enabled = FALSE;
info.charge_control_supported = FALSE;
}
/* NOTE: We used to warn about full > design, but really that is prefectly fine to happen. */

View file

@ -445,6 +445,7 @@ up_device_battery_update_info (UpDeviceBattery *self, UpBatteryInfo *info)
"technology", info->technology,
"has-history", TRUE,
"has-statistics", TRUE,
"charge-threshold-supported", info->charge_control_supported,
NULL);
priv->present = TRUE;

View file

@ -87,6 +87,7 @@ typedef struct {
/* battery charging threshold */
gboolean charge_control_enabled;
gboolean charge_control_supported;
guint charge_control_start_threshold;
guint charge_control_end_threshold;
} UpBatteryInfo;