hal/hald/linux2 acpi.c,1.22,1.23
David Zeuthen
david at freedesktop.org
Wed Jul 27 18:37:03 PDT 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv17086/hald/linux2
Modified Files:
acpi.c
Log Message:
2005-07-27 David Zeuthen <davidz at redhat.com>
Patch from Richard Hughes <richard at hughsie.com>.
* hald/util.c (util_compute_percentage_charge): New function used
to calculate the percentage charge, initially for ACPI batteries,
but could be used by all devices as contains lots of error checks.
* hald/linux2/acpi.c (battery_refresh_poll): Call
util_compute_percentage_charge so we can populate
battery.charge_level.percentage
Index: acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- acpi.c 21 Jul 2005 14:12:45 -0000 1.22
+++ acpi.c 28 Jul 2005 01:37:01 -0000 1.23
@@ -60,6 +60,7 @@
battery_refresh_poll (HalDevice *d)
{
const char *path;
+ int current, last_full;
path = hal_device_property_get_string (d, "linux.acpi_path");
if (path == NULL)
@@ -80,14 +81,23 @@
hal_util_set_int_elem_from_file (d, "battery.voltage.current", path,
"state", "present voltage", 0, 10, TRUE);
+ current = hal_device_property_get_int (d, "battery.charge_level.current");
+ last_full = hal_device_property_get_int (d, "battery.charge_level.last_full");
+
hal_device_property_set_int (d, "battery.remaining_time",
util_compute_time_remaining (
d->udi,
hal_device_property_get_int (d, "battery.charge_level.rate"),
- hal_device_property_get_int (d, "battery.charge_level.current"),
- hal_device_property_get_int (d, "battery.charge_level.last_full"),
+ current,
+ last_full,
hal_device_property_get_bool (d, "battery.rechargeable.is_discharging"),
hal_device_property_get_bool (d, "battery.rechargeable.is_charging")));
+
+ hal_device_property_set_int (d, "battery.charge_level.percentage",
+ util_compute_percentage_charge (
+ d->udi,
+ current,
+ last_full));
}
static gboolean
@@ -120,6 +130,7 @@
hal_device_property_remove (d, "battery.vendor");
hal_device_property_remove (d, "battery.charge_level.unit");
hal_device_property_remove (d, "battery.charge_level.current");
+ hal_device_property_remove (d, "battery.charge_level.percentage");
hal_device_property_remove (d, "battery.charge_level.last_full");
hal_device_property_remove (d, "battery.charge_level.design");
hal_device_property_remove (d, "battery.charge_level.capacity_state");
More information about the hal-commit
mailing list