It appears that the parent ID lookup may not properly work when devices
are removed. Likely, because corresponding sysfs entries may not exist
anymore.
Fix this by attaching the ID to the stored object, allowing us to remove
it without calling device_parent_id() again.
Fixes: #185
The only thing that is still discovered from the backend is the lid
switch. Though we could also handle that by having a separate signal
that is fired instead of a separate udev client.
This refactors the sibling detection to be event driven. Also changed is
that we jump certain device types when searching for a parent, which
fixes the discovery of wacom tablets for example.
Closes: #182
There is no need to refresh batteries if we just re-read the status of a
line power supply without actually seeing a change ("online" vs.
"update-time" property).
Fixes: #184
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
The class kept track of the power-supply property internally. However,
the value is static, and it is only needed to be queried in very few
cases.
Move the property setting to an earlier time and stop touching it when
it is not needed.
The USB device type for power supplies are always USB ports of the
system. As such, we should be able to assume that they are power
supplies.
Fixes: #183
When a change on a line power occurs, then re-poll all batteries
aggressively for a while. It is very common for batteries to take about
a second to refresh their state and many will not send appropriate
notifications in this case.
Closes: #179, #159
Instead of just killing upower, try to send SIGTERM for a clean
shut-down. Kill the process if it doesn't quit within two seconds, and
check that the service exits cleanly.
While not needed currently, there is a discussion to ignore the "hid"
subsystem parents when searching for siblings. Add in appropriate
parents to the tests so that such a change will not result in a failure.
Commit b78a2ab980 ("daemon: Stop passing UpDevice reference to the
daemon") fixed the fact that the signal passed a reference to the
daemon. This fix also implied that the UpDaemon object does not own a
reference to the device itself, instead relying on the UpDeviceList to
keep it alive.
With this change, there is no need to drop the extra reference when
clearing the device list, remove the code accordingly.
Reported-by: Alberts Muktupāvels <alberts.muktupavels@gmail.com>
This causes an add that we ignore, after that we should still see
updates from the device (and the add itself should trigger an update).
Verify that this works by setting the capacity to 20.
The device list class now assumes that contained objects are UpDevice
and we cannot store UpInput objects inside it anymore. Switch the lid
switch to be stored in the linux backend directly rather than allocating
a UpDeviceList just for that.
This fixes commit ddc739f38b ("device-list: Remove unnecessary native
argument")
As these are triggered by property changes, they may happen numerous
times for a single update. Avoid executing these (potentially expensive)
updates multiple times by pushing them into the next main loop
iteration.
The startup polling just creates the idevice_t. It is trivial to detect
that, so move it into the refresh handler and set the initial polling to
the shorter period, increasing the poll interval later on.