diff options
author | Benjamin Berg <bberg@redhat.com> | 2021-09-16 15:39:34 +0200 |
---|---|---|
committer | Benjamin Berg <bberg@redhat.com> | 2021-09-16 15:40:45 +0200 |
commit | 70400366adb73a3af288ab97db3d6b3fd6232969 (patch) | |
tree | 290dfa9b8f798228e10d93dde74b728dea4b0611 | |
parent | 27709f6af47da035739846a33cbf2dbdebee7485 (diff) | |
download | upower-benzea/zero-cycles-unknown.tar.gz |
lib: Define zero charge cycles to mean unknownbenzea/zero-cycles-unknown
This matches the ACPI and linux kernel specifications.
-rw-r--r-- | dbus/org.freedesktop.UPower.Device.xml | 4 | ||||
-rw-r--r-- | libupower-glib/up-device.c | 10 | ||||
-rwxr-xr-x | src/linux/integration-test.py | 2 | ||||
-rw-r--r-- | src/linux/up-device-supply.c | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/dbus/org.freedesktop.UPower.Device.xml b/dbus/org.freedesktop.UPower.Device.xml index f286aa7..2e33832 100644 --- a/dbus/org.freedesktop.UPower.Device.xml +++ b/dbus/org.freedesktop.UPower.Device.xml @@ -477,11 +477,11 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2 </doc:doc> </property> - <property name="ChargeCycles" type="i" access="read"> + <property name="ChargeCycles" type="u" access="read"> <doc:doc> <doc:description> <doc:para> - The number of charge cycles as defined by the TCO certification, or -1 if + The number of charge cycles as defined by the TCO certification, or 0 if that value is unknown or not applicable. </doc:para> </doc:description> diff --git a/libupower-glib/up-device.c b/libupower-glib/up-device.c index db0149f..518af2d 100644 --- a/libupower-glib/up-device.c +++ b/libupower-glib/up-device.c @@ -689,7 +689,7 @@ up_device_set_property (GObject *object, guint prop_id, const GValue *value, GPa up_exported_device_set_icon_name (device->priv->proxy_device, g_value_get_string (value)); break; case PROP_CHARGE_CYCLES: - up_exported_device_set_charge_cycles (device->priv->proxy_device, g_value_get_int (value)); + up_exported_device_set_charge_cycles (device->priv->proxy_device, g_value_get_uint (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1214,16 +1214,16 @@ up_device_class_init (UpDeviceClass *klass) /** * UpDevice:charge-cycles: * - * The number of charge cycles for the battery, or -1 if unknown + * The number of charge cycles for the battery, or 0 if unknown * or non-applicable. * * Since: 1.0 **/ g_object_class_install_property (object_class, PROP_CHARGE_CYCLES, - g_param_spec_int ("charge-cycles", - NULL, NULL, - -1, G_MAXINT, -1, G_PARAM_READWRITE)); + g_param_spec_uint ("charge-cycles", + NULL, NULL, + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); } static void diff --git a/src/linux/integration-test.py b/src/linux/integration-test.py index ce9735e..5b1cb2e 100755 --- a/src/linux/integration-test.py +++ b/src/linux/integration-test.py @@ -1926,7 +1926,7 @@ class Tests(dbusmock.DBusTestCase): bat0_up = devs[0] bat1_up = devs[1] - self.assertEqual(self.get_dbus_dev_property(bat0_up, 'ChargeCycles'), -1) + self.assertEqual(self.get_dbus_dev_property(bat0_up, 'ChargeCycles'), 0) self.assertEqual(self.get_dbus_dev_property(bat1_up, 'ChargeCycles'), 2000) self.stop_daemon() diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index a2a657f..3316a5f 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -145,7 +145,7 @@ up_device_supply_reset_values (UpDeviceSupply *supply) "percentage", (gdouble) 0.0, "temperature", (gdouble) 0.0, "technology", UP_DEVICE_TECHNOLOGY_UNKNOWN, - "charge-cycles", -1, + "charge-cycles", 0, NULL); } @@ -566,7 +566,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply, gint64 time_to_empty; gint64 time_to_full; gdouble temp; - int charge_cycles = -1; + guint charge_cycles = 0; gchar *manufacturer = NULL; gchar *model_name = NULL; gchar *serial_number = NULL; |