mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 06:40:04 +01:00
linux: up-device-supply-battery: Set charge_types to enable/disable the charge threshold
If the charge threshold is enabled, the charge_types set "Long_Life". If the charge threshold is disabled, the charge_types set to any of charge_types for charging, such as "Fast", "Standard", and "Adaptive". This commit is only for the system that only has the charge_types attribute to control the battery behaviour.
This commit is contained in:
parent
a97c3ceaf5
commit
33efe441f6
1 changed files with 21 additions and 2 deletions
|
|
@ -661,6 +661,7 @@ static gboolean
|
||||||
up_device_supply_battery_set_battery_charge_thresholds(UpDevice *device, guint start, guint end, GError **error) {
|
up_device_supply_battery_set_battery_charge_thresholds(UpDevice *device, guint start, guint end, GError **error) {
|
||||||
guint err_count = 0;
|
guint err_count = 0;
|
||||||
GUdevDevice *native;
|
GUdevDevice *native;
|
||||||
|
UpDeviceSupplyBattery *self = UP_DEVICE_SUPPLY_BATTERY (device);
|
||||||
g_autofree gchar *native_path = NULL;
|
g_autofree gchar *native_path = NULL;
|
||||||
g_autofree gchar *start_filename = NULL;
|
g_autofree gchar *start_filename = NULL;
|
||||||
g_autofree gchar *end_filename = NULL;
|
g_autofree gchar *end_filename = NULL;
|
||||||
|
|
@ -673,6 +674,24 @@ up_device_supply_battery_set_battery_charge_thresholds(UpDevice *device, guint s
|
||||||
start_filename = g_build_filename (native_path, "charge_control_start_threshold", NULL);
|
start_filename = g_build_filename (native_path, "charge_control_start_threshold", NULL);
|
||||||
end_filename = g_build_filename (native_path, "charge_control_end_threshold", NULL);
|
end_filename = g_build_filename (native_path, "charge_control_end_threshold", NULL);
|
||||||
|
|
||||||
|
/* if the charge threshold is controlled by charge_types,
|
||||||
|
* the charge_types will be set to Long_life when enabling the charge threshold.
|
||||||
|
* the charge_types will be set to Standard/Adaptive/Fast when disabling the charge threshold. */
|
||||||
|
if (self->charge_threshold_by_charge_type) {
|
||||||
|
if (start == 0 && end == 100) {
|
||||||
|
charge_type_enum = up_device_battery_charge_find_available_charge_types_for_charging (device);
|
||||||
|
up_device_supply_battery_set_battery_charge_types (device,
|
||||||
|
charge_type_enum,
|
||||||
|
NULL);
|
||||||
|
} else {
|
||||||
|
up_device_supply_battery_set_battery_charge_types (device,
|
||||||
|
UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_LONG_LIFE,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (start != G_MAXUINT) {
|
if (start != G_MAXUINT) {
|
||||||
g_string_printf (start_str, "%d", CLAMP (start, 0, 100));
|
g_string_printf (start_str, "%d", CLAMP (start, 0, 100));
|
||||||
if (!g_file_set_contents_full (start_filename, start_str->str, start_str->len,
|
if (!g_file_set_contents_full (start_filename, start_str->str, start_str->len,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue