Commit graph

1499 commits

Author SHA1 Message Date
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
Benjamin Berg
ce15fa1507 idevice: Use new polling property 2022-05-10 09:31:46 +02:00
Benjamin Berg
2a3da575d1 daemon: Trigger device refresh based on new properties
This uses a GSource and a simple looping approach to trigger device
refresh when needed. We don't use the g_timeout_add_seconds rounding
again to synchronize with other applications, but we will eventually
poll everything at the same time. Also, we will not do wakeups if an
update happens regularily enough due to e.g. a uevent.
2022-05-10 09:31:46 +02:00
Benjamin Berg
3b287504ce device: Add polling related properties
Add last-refresh and poll-timeout properties. Update the last-refresh
property automatically from the internal refresh method. Note that it is
fine if we miss (some) updates for now, as the polling code which uses
the property will update it.
2022-05-09 22:59:17 +02:00
Benjamin Berg
8080119e02 device: Remove useless comments 2022-05-09 17:47:38 +02:00
Benjamin Berg
dc72b0cb00 daemon: Change start_poll API to refresh the device
There are two users, and both simply force a device refresh. We also
simply force-refresh devices after resume, which ties into
pausing/resuming polling.
2022-05-09 17:47:38 +02:00
Benjamin Berg
7f7839bdde device: Flag refresh reason
The reason of a refresh may be interesting to special case certain
situation (e.g. discontinuity of charge after wakeup, polling again
after an event). As such, add an enum parameter that signals the reason
for the refresh.
2022-05-09 17:47:38 +02:00
Benjamin Berg
5836099ad7 freebsd: Fix a few minor warnings 2022-04-20 14:30:01 +02:00
Benjamin Berg
25ddb11f08 device: Handle device coldplug using GInitable
There are only a few cases where we separate construction and coldplug.
Porting to GInitable is relatively natural here and makes the code a
little nicer overall. In the case that immediate coldplug/initialization
is not desired, we can still split the operations.
2022-04-20 14:30:00 +02:00
Benjamin Berg
20fed261f1 device: Register display device the same way as other devices
We can just assume that a device with a NULL native device is the
display device. Using this, we can special case the naming and rely on
the normal internal up_device_register_device function to register the
display device.
2022-04-20 14:26:50 +02:00
Benjamin Berg
388de9c1eb openbsd: Fix incorrect FD check
FD 0 is valid in principle, as such, we shouldn't use it as the default
for knowing whether the FD has been open'ed. Instead, use -2 so that -1
can still be used after open failed.
2022-04-20 14:26:50 +02:00
Benjamin Berg
ddc739f38b device-list: Remove unnecessary native argument
We can simply look it up from within the function.
2022-04-20 14:26:50 +02:00
Bastien Nocera
f961ec6154 linux: Detect drawing tablets correctly
See discussion at:
https://patchwork.kernel.org/project/linux-input/patch/20220407115406.115112-1-hadess@hadess.net/
2022-04-20 10:50:19 +02:00
Bastien Nocera
d0ebbe32bb device: Only handle Refresh() method if in debug mode
The Refresh D-Bus method could be used by clients to force re-reading
the state of batteries in the upower backends. This is not needed as
all the backends should be sending events when their states changes,
removing the need for an explicit refresh.

This is also a potential security problem if applications keep on
refreshing their data.

We now only allow access to the Refresh() method if the daemon was
started in debugging mode. This should make it clearer that it is a
debug tool.

Also remove a mention of the never implemented refresh-power-source
polkit authorisation.
2022-04-19 15:27:36 +02:00
Bastien Nocera
2f3ccee059 main: Add debug flag
This will be used to restrict some D-Bus methods to when debugging is
enabled.
2022-04-19 15:27:36 +02:00
Benjamin Berg
380e974d75 ci: Compile all backends in the CI
The BSD backends are still compiled in linux, and platform specific code
is mostly disabled using a special define. However, this way we can at
least compile tests code refactorings.
2022-04-01 18:36:50 +02:00
Benjamin Berg
eeaaddbcdd bsd*: Allow building on linux
Guard platform specific code and add in a few extra definitions so that
the backends can at least be partially compiled on linux. This is for
testing purposes, if we could build against a proper image that would
also be acceptable.
2022-04-01 18:36:50 +02:00
Benjamin Berg
8be73b986a openbsd: Fix compilation and compiler warnings
It didn't even compile, and one warning about an uninitialised variable
was actually relevant.
2022-04-01 18:29:20 +02:00
Benjamin Berg
65f2aa5c24 freebsd: Remove unused swap detection code 2022-04-01 18:28:01 +02:00
Benjamin Berg
08e693a6cf ci: Improve test setup using images and add NUT hwdb test 2022-04-01 18:27:28 +02:00
Benjamin Berg
bd488facf1 device: Move daemon/native object into construct only properties
Rather than this weird situation where they are immediately passed in
through the "coldplug" method. Doing this is the first step to make
UpDevice into an initable object (removing the "coldplug" method).
2022-04-01 18:25:20 +02:00
Benjamin Berg
77a20b84e4 device: Remove unplug, moving cycle breaking into dispose
Might as well use g_object_run_dispose to break the cycle to the display
device.
2022-04-01 18:25:20 +02:00
Benjamin Berg
51b4a39a81 native: Remove unused up_native_test declaration 2022-04-01 11:47:41 +02:00
Benjamin Berg
e995ebddc4 linux: Remove unused RefreshResult enum
The refresh functions only ever returned whether data was successfully
fetched or not. The failure return code was unused and the corresponding
code can be removed.
2022-04-01 11:47:41 +02:00
Benjamin Berg
f09a6e209d linux: Fix initial enumeration of Whats Up! device
We would not scan the TTY subsystem during coldplug, which means that
the device would not be detected if it is plugged in at daemon startup
time.
i
2022-04-01 11:47:41 +02:00
Benjamin Berg
1550d50f20 linux: Remove "usb" subsystem match
The hiddev driver has been in the "usbmisc" subsystem since kernel 3.7.0
or so. As such, we can simply drop the "usb" subsystem from our matches
at this point.
2022-04-01 11:47:41 +02:00
Benjamin Berg
90c25b4fd1 rules: Update udev rules and migrate to use hwdb
This makes rule matching more efficient. We just need to copy the
variables over into the hiddev device so that there is no need to change
the C code to match the parent USB device. That said, the change in C
wouldn't be that hard either.

See https://github.com/networkupstools/nut/pull/1342
2022-04-01 11:47:17 +02:00
Benjamin Berg
888b1afc6d freebsd: Drop TODO referencing battery recall feature
The feature was removed a long time ago. So the TODO is obsolete.
2022-03-28 15:30:05 +02:00
Benjamin Berg
70a1a59efa ci: API changed, update commit and check-abi build 2022-03-24 17:02:53 +01:00
Benjamin Berg
9058d45685 Remove Wakeups API
The API relied on /proc/timer_stats which has been removed from the
kernel in 2017. Since then, the API has been non-functional (yet
incorrectly reporting support because the support test was buggy).

Just remove it completely. The debian codesearch does not uncover any
API users. Also, I doubt that any new API (based on tracing scheduler
events as perf would do) would map well to what exists now. i.e. if
something like this is re-implemented in UPower or elsewhere, then the
API should likely look different.

And, realistically, if this does need root privileges (i.e. can't be
moved to use BPF programs or so on user units), then we can also create
a new small daemon that is launched on-demand just for that.
2022-03-24 17:02:27 +01:00
Matt Turner
1003d5c2a6 meson: Don't search for gtk-doc if disabled 2022-03-20 15:33:56 -07:00
Benjamin Berg
c889154ec8 Release 0.99.17 2022-03-09 18:46:34 +01:00
Pierre Labastie
9cca8a244b meson.build: Output correct paths for sbindir and datadir 2022-03-05 11:09:14 +01:00
Benjamin Berg
2f81d69014 daemon: Initialize FD to -1 to avoid incorrect close
Also add an assert that the FD is -1 when we are about to grab the
inhibitor. Previously, we would just set the value early enough before
trying to close the FD, overwriting the incorrect initialization.
2022-02-25 10:27:33 +01:00
Benjamin Berg
72469426b7 input: Fix FD handling and let input stream close it
The open() call needs to check against the FD being <0 for error
detection. Also, add a missing close in one of the error paths and
change the code to let the input stream close the FD when it is not
needed anymore.

We still open() it manually just because we need to do an ioctl once.
2022-02-25 10:27:33 +01:00
Benjamin Berg
7192ff481b linux: Set FD to -1 rather than 0 when closing delay inhibitor 2022-02-25 10:08:19 +01:00
Benjamin Berg
2e5ba3ef80 Release 0.99.16 2022-02-23 17:46:51 +01:00