Commit graph

1567 commits

Author SHA1 Message Date
Benjamin Berg
3f2eabb4d1 Release 0.99.20 2022-07-13 17:18:50 +02:00
Benjamin Berg
f64210df4a daemon: Reevaluate polling timeout after resume
When polling is resumed the timeout needs to be reevaluated. This
requires running the polling handler once (in the next mainloop
iteration).

Set the ready time to zero to ensure this is happening. Without this, we
would be stuck without actually polling until we get a uevent from the
kernel on one of the power supplies.

Fixes: #198
2022-07-12 16:53:53 +02:00
Benjamin Berg
5fea66f411 doc: Remove website
It now has its own repository.
2022-07-12 16:53:53 +02:00
Benjamin Berg
246acd27f3 test: Fix flaky battery aggregation test
It seems that the test was still flaky, the reason for that would be
that we did not explicitly wait for the log line saying that the
aggregate state was calculated.

The only reason that it did not consistently fail appears to be that
searching for the state conflict caused messages to be skipped. That is
wrong, we should account for every "Calculating percentage" message to
ensure that upowerd and the test is in sync.
2022-07-12 16:51:24 +02:00
Benjamin Berg
c6cd9beff3 daemon: Iterate mainloop during coldplug
This ensures that all idle handlers have run and we report a consistent
state on the bus.
2022-06-15 16:29:28 +02:00
Benjamin Berg
54e396e7ae test: Disable battery polling to make test more stable
Otherwise the fast repolling can get in-between, cause extra logging and
trigger a failure.
2022-06-15 14:09:14 +02:00
Benjamin Berg
1a9541814e Add some debugging information to the README
We keep giving people these commands for bug triaging. So, lets hope
that adding them to the README removes some of the overhead and can be
helpful to users.
2022-06-15 11:54:24 +00:00
Benjamin Berg
4dac45e53a test: Test state guessing for one and two batteries
The state guessing code based on the AC state was not tested well.
Improve the test by testing both 1 and 2 batteries and checking the
reported state in more detail.
2022-06-14 17:51:06 +02:00
Benjamin Berg
e6d4b8cd4a daemon: Guess state for multiple batteries without AC
There is no reason to not guess the state if the device has no AC power
and there is more than one battery. Remove the corresponding constraint.

Related: #146
2022-06-14 17:50:54 +02:00
Benjamin Berg
2a1ab444e8 daemon: Move state guessing after percentage calculation
Otherwise we may not have the percentage to work with, rendering the
guessing useless. This also moves the time estimation down (after the
state guessing) and does it unconditionally. This is, however, not an
issue, as the calculation matches with other places.

Related: #146
2022-06-14 17:32:36 +02:00
Benjamin Berg
ce24787165 supply: Use percentage to guess empty STATE
Using energy is broken as the value might be zero if it is not provided.
However, either energy or percentage ("capacity") should have been read
from the sysfs. And, in both cases the percentage should reflect
something reasonable.

Related: #146
2022-06-14 17:02:45 +02:00
Benjamin Berg
a78ee60390 test: Properly wait for idle handler after uevents
The state aggregation test requires an idle handler to run, which can be
a bit unreliable as it may or may not run twice.

Force running it twice and add code to wait for it to complete. Do so
properly by waiting for the correct log messages rather than sleeping so
that everything is ordered nicely while not slowing down the test a lot.

Closes: #193
2022-06-09 12:38:34 +02:00
Benjamin Berg
e9d73a3115 Release 0.99.19 2022-06-08 14:16:46 +02:00
Benjamin Berg
c6a851d798 test: Add test for mice that have keys
These should not be detected as keyboards.
2022-06-08 12:55:59 +02:00
Benjamin Berg
a57c2b1e1e supply: Use differing priority within input node and between them
If we have an input node with both a keyboard and a mouse in one node,
then prefer the mouse. However, if we have separate mouse and keyboard
device nodes, prefer the keyboard.

Closes: #189
2022-06-08 12:55:34 +02:00
Benjamin Berg
115b756eaf supply: Remove ID_INPUT_TABLET_PAD check as it implies ID_INPUT_TABLET
No need to test for ID_INPUT_TABLET_PAD separately.
2022-06-08 12:38:02 +02:00
Benjamin Berg
68d4f3702d Move battery type decoding into common file 2022-06-07 16:07:03 +02:00
Benjamin Berg
1587b37707 test: Test all possible inputs for daemon state aggregation
This adds a test that checks all possible inputs for the battery state
aggregation. Not all states are actually tested in this case, as some
states may be handled through state inference and others might not be
well defined.
2022-06-07 16:07:03 +02:00
Benjamin Berg
13f7cc7bb5 daemon: Update aggregate state matching and handle UNKNOWN state
Stop trying to guess a battery state based on the AC information for a
single battery. Instead, just do the guessing in the display device.

This means that cases with more than one battery work fine. It also
means that we still report an UNKNOWN state for the battery itself.

Also get the on_battery information from the display devices discharging
state, there is no need to iterate all of the batteries to figure that
out.

Note that we don't really have a well defined state for the display
device in all cases. We'll add a test in the next step, marking those
cases as TBD or ANY to show where the issues are. AFAICT we do not have
a regression though, so this should be fine for now.

Fixes: #146
2022-06-07 15:35:03 +02:00
Benjamin Berg
792fc7bb1b supply: Consistently use 90% threshold to consider a battery full 2022-06-03 10:36:02 +02:00
Benjamin Berg
7ed8d0e9ef freebsd: Use correct up_make_safe_string definition 2022-06-03 10:35:58 +02:00
Benjamin Berg
e61bed3b90 common: Return original pointer from up_make_safe_string
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
2022-05-27 11:05:07 +02:00
Benjamin Berg
c330351937 test: Disable systemd v251 sysfs verification
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.
2022-05-25 16:57:21 +02:00
Benjamin Berg
190d12e292 common: Add a file with common helper
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.
2022-05-25 15:32:29 +02:00
Benjamin Berg
66eb9b9d7a test: Stop processes using cleanup function
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.
2022-05-20 14:41:52 +02:00
Benjamin Berg
41bceac6ef test: Only assert daemon log is closed if daemon is started 2022-05-20 14:37:23 +02:00
Benjamin Berg
6d947c0532 test: Do not redirect helper stdout
There is no need to do so, so drop the redirection.
2022-05-20 14:37:02 +02:00
Benjamin Berg
f1c00e50c2 test: Allow daemon to take 5 seconds for shutdown
It seems like shutdown can take more than 2 seconds on some slow
systems. So increase to 5 seconds which hopefully is long enough.

Closes: #188
2022-05-20 14:35:23 +02:00
Benjamin Berg
c64b020f99 test: Turn off buffering when executing directly
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.
2022-05-20 14:35:11 +02:00
Benjamin Berg
267f5ea8d3 linux: Fix exception check when on test daemon shutdown
subprocess.Popen.wait throws subprocess.TimeoutExpired not TimeoutError.

Related: #188
2022-05-19 11:45:55 +02:00
Benjamin Berg
aa646fa0ca meson: Allow unittest inspector to fail
It is only used to make the test output nicer, and it is completely fine
to fail.

Closes: #187
2022-05-17 16:02:49 +02:00
Benjamin Berg
017ac33d58 Release 0.99.18 2022-05-17 10:54:28 +02:00
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