Commit graph

1535 commits

Author SHA1 Message Date
Benjamin Berg
ddb0ce87e7 po: Update translation files
They were horribly outdated and many strings are not even used anymore.

Closes: #186
2022-05-17 10:54:28 +02:00
Benjamin Berg
ab08a4188f linux: Add test verifying sibling tracking cleanup works
This tests that the code to track siblings is working correctly and that
it will clean up the entries stored in the cache when a device
disappears.
2022-05-17 10:40:58 +02:00
Benjamin Berg
8c53faac81 linux: Do not rely on parent ID lookup to work at removal time
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
2022-05-17 10:23:52 +02:00
Benjamin Berg
fa781e29da linux: Log debug message when siblings array becomes empty 2022-05-17 10:23:52 +02:00
Benjamin Berg
c2b7a53e71 linux: Track only first level of "input" entries for sibling matching
There is no need to track the children, as we'll already have the parent
in the lookup table and the parent will already have the correct tags.
2022-05-17 10:23:52 +02:00
Benjamin Berg
6db0627aaa linux: Add wacom tests 2022-05-16 16:42:30 +02:00
Benjamin Berg
76a99a7638 linux: Add helper to assert devices and properties
Just to make it a bit nicer to do assertions on devices and properties.
2022-05-16 16:40:00 +02:00
Benjamin Berg
ba728ee4eb linux: Update udev dumps to be usable with umockdev
This means adding appropriate attributes and removing some links that
appear to be duplicate.
2022-05-16 16:40:00 +02:00
Benjamin Berg
bbb3c07f56 linux: Add udev dumps for wacom devices
These are raw udev dumps, we'll need to update them so that they become
valid umockdev device descriptions.
2022-05-16 16:40:00 +02:00
Benjamin Berg
275db91afd linux: Do not create intermediate proxy to fetch properties
There is no need for an intermediate proxy object, adding it just
results in extra overhead that is not needed.
2022-05-16 16:40:00 +02:00
Benjamin Berg
4400ad0944 linux: Move udev device discovery into a separate class
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
2022-05-16 16:40:00 +02:00
Benjamin Berg
896c77dc7d enumerator: Add UpEnumerator class and udev implementation 2022-05-16 15:48:09 +02:00
Benjamin Berg
10290e0e6d rules: Update hwdb from upstream NUT 2022-05-16 14:00:52 +02:00
Alberts Muktupāvels
96bbea846b
linux: use correct object when emitting device-removed signal
TI:14:27:16	BlueZ disappeared
TI:14:27:16	emitting device-removed: /org/bluez/hci0/dev_00_11_67_2A_6D_7A
(upowerd:228434): GLib-GObject-WARNING **: 14:27:16.218: invalid cast from 'GDBusObjectProxy' to 'UpDevice'
TI:14:27:16	up_daemon_device_removed_cb: assertion 'UP_IS_DEVICE (device)' failed
2022-05-16 14:35:22 +03:00
Benjamin Berg
2151d7c0e4 linux: Test that line-power events don't cause battery polling
This verifies that we do not start polling the battery if we got a
spurious event related to a line-power supply.
2022-05-16 09:14:07 +00:00
Benjamin Berg
b4e9cd9739 daemon: Only refresh batteries when the "online" state changes
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
2022-05-16 09:14:07 +00:00
Benjamin Berg
4cccf81cad 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
2022-05-16 09:14:07 +00:00
Benjamin Berg
2d6080d253 supply: Drop is_power_supply attriute that never changes
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.
2022-05-16 09:14:07 +00:00
Benjamin Berg
6cfccef2ad device-supply: Assume USB type supplies the system
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
2022-05-16 09:07:57 +00:00
Benjamin Berg
b342964400 linux: Re-poll batteries after a line power change
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
2022-05-13 16:07:38 +02:00
Benjamin Berg
90c84ea95c linux: Ensure clean shutdown after tests
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.
2022-05-12 14:42:35 +02:00
Benjamin Berg
24917a4b66 main: Handle SIGTERM in addition to SIGINT
It is common to stop services using SIGTERM. Add an appropriate handler
that stops upower.
2022-05-12 14:39:16 +02:00
Benjamin Berg
76b4c31ee9 linux: Add non-hid parent to hidpp tests
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.
2022-05-12 11:16:42 +02:00
Benjamin Berg
4fca99a819 device-supply: Fix leak of serial_number string 2022-05-12 11:09:33 +02:00
Benjamin Berg
71f1908683 daemon: Fix reference counting at daemon shutdown
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>
2022-05-12 10:13:15 +02:00
Benjamin Berg
565b3531d6 linux: Test changes after BT HID power_supply subtree move
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.
2022-05-11 10:16:50 +02:00
Benjamin Berg
dac0e3bc11 linux: Remove/add device if the sysfs path changed 2022-05-11 10:16:50 +02:00
Benjamin Berg
b78a2ab980 daemon: Stop passing UpDevice reference to the daemon
There is no need to do so, in particular as the signal emission code
will keep a reference to the object internally.
2022-05-10 19:19:08 +02:00
Benjamin Berg
4651088391 device: Use modern macros for class declaration
This removes the priv member from the struct, but also means that
g_autoptr works with the class.
2022-05-10 17:14:09 +02:00
Benjamin Berg
d8eb09fba3 meson: Bump required glib version to 2.58 2022-05-10 15:45:27 +02:00
Benjamin Berg
baa14729a0 meson: Bump meson version and fix deprecations 2022-05-10 15:39:24 +02:00
Benjamin Berg
a87cb420cd linux: Store lid input device outside of device list
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")
2022-05-10 11:06:25 +02:00
Benjamin Berg
3c520fb590 linux: Use OutputChecker to inspect daemon log
This also means the daemon log is stored even when succeeding, making it
a bit easier to inspect tests overall.
2022-05-10 11:06:18 +02:00
Benjamin Berg
11fb06d8ae ci: Permit XML to be invalid to avoid issues with colored logs 2022-05-10 11:06:18 +02:00
Benjamin Berg
b0f1e28b42 linux/freebsd: Do not print invalid characters into log
Instead, just hex-encode them, they are invalid, it is not like having
them in raw in the log is helpful.
2022-05-10 11:06:18 +02:00
Benjamin Berg
26dee1fe3f daemon: Push internal refreshes into idle handler
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.
2022-05-10 11:06:18 +02:00
Benjamin Berg
b9bf475459 linux: Enable fatal-warnings for most tests 2022-05-10 11:06:18 +02:00
Benjamin Berg
7f846bcee6 linux: Provide temporary history directory in tests
This avoids a warning when history files need to be saved.
2022-05-10 11:06:18 +02:00
Benjamin Berg
f2da5678f3 linux: Create an empty configuration file for every test
This avoids a warning during startup, allowing enabling fatal-warnings
in more cases.
2022-05-10 11:06:18 +02:00
Benjamin Berg
0a1edd7916 history: Allow overriding history directory for testing
Read UP_HISTORY_DIR for the history directory so that it can be made
writeable during testing.
2022-05-10 11:06:18 +02:00
Benjamin Berg
5fd3c9988c linux: Always start logind during test
This avoids a warning on daemon startup and is a step towards turning on
fatal-warnings most of the time.
2022-05-10 11:06:18 +02:00
Benjamin Berg
dc252aba71 idevice: Simplify startup handling
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.
2022-05-10 11:06:18 +02:00
Benjamin Berg
a69c009748 wup: Use new polling infrastructure 2022-05-10 11:06:18 +02:00
Benjamin Berg
1cf7e32987 hid: Use new polling infrastructure 2022-05-10 11:06:18 +02:00
Benjamin Berg
df14a9bf72 linux: Remove duplicate refresh during initilization
The main coldplug routine already does an explicit refresh. Remove the
duplication in the WUP and power supply classes.
2022-05-10 11:06:18 +02:00
Benjamin Berg
3f6e621d96 freebsd: Use new polling infrastructure 2022-05-10 11:06:18 +02:00
Benjamin Berg
89c5630eaa daemon: Disconnect all signal handlers from devices
This is just so that we don't rely on the object being destroyed at the
time we remove it. Usually the call should not be needed.
2022-05-10 11:06:18 +02:00
Benjamin Berg
f753b7302f daemon: Remove old polling code
The new code is more concise and allows devices to configure the polling
frequency.
2022-05-10 11:06:18 +02:00
Benjamin Berg
37f8fa2699 linux: Test fast-polling stops after 5 seconds
In some cases we fast-poll for 5 seconds after a uevent. Check that this
type of fast-polling stops when appropriate.
2022-05-10 11:06:18 +02:00
Benjamin Berg
3243ff2a56 supply: Use new polling infrastructure
This means we do the fast-repoll and normal polling with the same method
(no timeout registrations within the supply code anymore).
2022-05-10 11:06:18 +02:00