This fixes the previous commmit to 190d12e292 ("common: Add a file
with common helper") which broke the string handling for the freebsd
backend.
Related: !144
The umockdev code to disable it by setting the variable does not
propagate through python. Set the variable here until there is a more
permament solution available.
This removes some code duplication between the linux and freebsd
backend. And, this file could become home to other small helper
functions in the future.
Using tearDown is brittle, as an assertion will stop it from running
through completely. So move cleanup into a helper that is called via
addCleanup for logind and bluez.
It can be a bit unepxected if results are not printed immediately, so
turn off buffering. We could possibly also reopen sys.stdout, but this
is good enough in many cases.
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.