mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-05 18:08:02 +02:00
supply: Avoid emitting notification for line power changes
Setting the property will create a notification, which in turn causes the daemon code to trigger a battery refresh. As such, avoid actually setting the property if it still has the same value. Note that we shouldn't usually get spurious notifications, but it is good to be safe here in case e.g. a bad firmware just sends out notifications when the battery capacity changes. Related: #184
This commit is contained in:
parent
2d6080d253
commit
4cccf81cad
1 changed files with 10 additions and 2 deletions
|
|
@ -79,12 +79,20 @@ up_device_supply_refresh_line_power (UpDeviceSupply *supply,
|
|||
{
|
||||
UpDevice *device = UP_DEVICE (supply);
|
||||
GUdevDevice *native;
|
||||
gboolean online_old, online_new;
|
||||
|
||||
/* get new AC value */
|
||||
native = G_UDEV_DEVICE (up_device_get_native (device));
|
||||
g_object_set (device,
|
||||
"online", g_udev_device_get_sysfs_attr_as_int_uncached (native, "online"),
|
||||
|
||||
g_object_get (device,
|
||||
"online", &online_old,
|
||||
NULL);
|
||||
online_new = g_udev_device_get_sysfs_attr_as_int_uncached (native, "online");
|
||||
/* Avoid notification if the value did not change. */
|
||||
if (online_old != online_new)
|
||||
g_object_set (device,
|
||||
"online", online_new,
|
||||
NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue