mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-28 13:00:06 +01:00
linux: Set update-time for BlueZ devices
When the battery percentage for a BlueZ device changes, change the update-time so that the charge history is somewhat useful.
This commit is contained in:
parent
67eefa17dd
commit
dde6f714ea
2 changed files with 6 additions and 1 deletions
|
|
@ -1643,6 +1643,7 @@ class Tests(dbusmock.DBusTestCase):
|
|||
self.assertEqual(self.get_dbus_dev_property(mouse_bat0_up, 'Percentage'), 99)
|
||||
self.assertEqual(self.get_dbus_dev_property(mouse_bat0_up, 'PowerSupply'), False)
|
||||
self.assertEqual(self.get_dbus_dev_property(mouse_bat0_up, 'Type'), UP_DEVICE_KIND_MOUSE)
|
||||
self.assertEqual(self.get_dbus_dev_property(mouse_bat0_up, 'UpdateTime') != 0, True)
|
||||
self.stop_daemon()
|
||||
|
||||
def test_bluetooth_le_device(self):
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ up_device_bluez_coldplug (UpDevice *device)
|
|||
g_object_set (device,
|
||||
"is-present", TRUE,
|
||||
"percentage", (gdouble) percentage,
|
||||
"update-time", (guint64) g_get_real_time () / G_USEC_PER_SEC,
|
||||
NULL);
|
||||
|
||||
g_object_unref (proxy);
|
||||
|
|
@ -171,7 +172,10 @@ up_device_bluez_update (UpDeviceBluez *bluez,
|
|||
g_variant_iter_init (&iter, properties);
|
||||
while (g_variant_iter_next (&iter, "{&sv}", &key, &value)) {
|
||||
if (g_str_equal (key, "Percentage")) {
|
||||
g_object_set (device, "percentage", (gdouble) g_variant_get_byte (value), NULL);
|
||||
g_object_set (device,
|
||||
"percentage", (gdouble) g_variant_get_byte (value),
|
||||
"update-time", (guint64) g_get_real_time () / G_USEC_PER_SEC,
|
||||
NULL);
|
||||
} else {
|
||||
char *str = g_variant_print (value, TRUE);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue