Commit graph

1622 commits

Author SHA1 Message Date
Bastien Nocera
b3c439ab4a linux: Fix getting properties in assertDevs()
Now that device loop is fixed, we also need to fix the D-Bus object
path for the devices themselves to match what UPower generates so
we can get its properties.

As we iterate over the expected array, the elements are the basenames
of those object paths. Reconstruct the full object paths by prepending
/org/freedesktop/UPower/devices/
2023-04-14 13:50:49 +02:00
Bastien Nocera
32e2cd5eb9 linux: Fix broken assertDevs() device loop
The test uses a generator to get the list of basenames for the devices:
names = (n.split('/')[-1] for n in devs)

Unfortunately, using that "names" varible will consume the generator,
and our array will be lost.

When passing a device dictionary, this code:
print(sorted(names))
print(sorted(names))
will yield:
['battery_hidpp_battery_0']
[]

Save the sorted array, and use that to test for properties equality.
2023-04-14 13:50:19 +02:00
Bastien Nocera
a5acbad7f1 rules: Update hwdb from upstream NUT 2023-04-11 11:30:06 +02:00
Bastien Nocera
b42f4691d3 ci: Use detached pipelines
See https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/438#what-it-means-for-me-a-maintainer-of-a-project-part-of-gitlabfreedesktoporg
2023-03-15 11:48:49 +01:00
Bastien Nocera
810c1214a5 linux: Test fix for warning when a duplicate device appears
Make the Bluetooth device appear first.
2023-02-28 14:14:59 +01:00
Bastien Nocera
32b0e098a1 linux: Test adding Bluetooth devices after daemon start
As is usually the case in reality, as bluez must be started for
Bluetooth devices to be able to connect.
2023-02-28 14:14:59 +01:00
Bastien Nocera
b6143527ef linux: Fix dbusmock addition of fake battery
We need to send the InterfacesAdded signal in case upower is already
started, so it can properly keep track of the interesting bluez devices.
2023-02-28 13:42:36 +01:00
Bastien Nocera
46257ff36e linux: Fix warning when a duplicate device appears
When a kernel device appears after the Bluetooth device, we could be
trying to bind the model property onto itself on the Bluetooth device.
Avoid this possibility by always binding the property from the bluez
device to the non-bluez device.

GLib-GObject-WARNING **: 20:20:50.644: Unable to bind the same property on the same instance

Fixes: 778b93a336 ("linux: Hide duplicate Logitech Bluetooth devices")
2023-02-28 13:05:28 +01:00
Bastien Nocera
b7e406d9f9 linux: Add test for Logitech HID++/Bluetooth deduplication
This tests for the device-removed g_warning(), following the Alias
property on bluez devices, and the "Unhandled key" warnings.
2023-02-27 14:39:36 +01:00
Bastien Nocera
81c97eef9d main: Fix warning for hidden device
Some Bluetooth devices can be hidden if they also export their battery
info through the kernel, so make sure to not throw a warning when they
go away.

(upowerd:133931): UPower-WARNING **: 02:49:48.012: INTERNAL STATE CORRUPT (device-removed): not sending NULL, device:0x1f5dae0

Fixes: 778b93a336 ("linux: Hide duplicate Logitech Bluetooth devices")
2023-02-27 14:12:39 +01:00
Bastien Nocera
7df5f2907c linux: Demote warning to debug
Fixes warnings like:
(upowerd:133931): UPower-Linux-WARNING **: 02:49:48.011: Unhandled key: ServicesResolved value: false
(upowerd:133931): UPower-Linux-WARNING **: 02:49:48.012: Unhandled key: Connected value: false

Fixes: 29ecd92f9c ("linux: Fix BlueZ device names not synchronising")
2023-02-27 14:12:39 +01:00
Bastien Nocera
3bf5a095ac linux: Fix device paths in tests
add_device() doesn't need the full sysfs path if there's a parent,
otherwise this section of the path will be duplicated.
2023-02-27 14:12:39 +01:00
Bastien Nocera
b2cbf01090 linux: Test for "present" sysfs attribute handling 2023-02-21 15:19:46 +01:00
Mario Limonciello
0b7d7cfc08 linux: Fix is-present for devices at startup
As will be documented in the kernel through this patch:
https://patchwork.kernel.org/project/linux-pm/patch/20230220131018.1708991-1-hadess@hadess.net/
2023-02-21 15:19:46 +01:00
Bastien Nocera
6b7ffaaa16 rules: Update hwdb from upstream NUT 2023-02-21 15:16:29 +01:00
Bastien Nocera
d9fbf41dc9 ci: Fix docs getting wiped between stages
Same as previous commit, but for docs.
2023-02-21 15:00:19 +01:00
Bastien Nocera
8ddbb8e2eb ci: Fix tree getting wiped between stages
It's stopping us from being able to run tests.
2023-02-20 15:09:05 +01:00
Bastien Nocera
7f3a31447f rules: Update hwdb from upstream NUT 2022-11-16 16:16:34 +01:00
Bastien Nocera
4051aa8f80 idevice: Simplify setting the model 2022-11-16 16:14:40 +01:00
Kai Uwe Broulik
a795750a2e idevice: Prefer the user-chosen name when available
Use the device name as model name when the user-chosen device name is available.
This matches what the Bluez backend does.
2022-11-16 16:13:38 +01:00
Benjamin Berg
38a52894a3 ci: Fix paths included in build artifacts
Seems like using $(pwd) got broken with newer gitlab versions. Just use
the CI_PROJECT_DIR (though we could also just use '.' even).
2022-11-03 13:52:36 +01:00
Maciej S. Szmigiero
dcb4600b33 enumerator-udev: also check for an idevice on "usb" subsystem
Commit 1550d50f ("linux: Remove "usb" subsystem match") broke detection of
some idevices, since it left just the "usbmisc" subsystem match while some
idevice / kernel combinations (at least an iPhone 11 on a 6.0 kernel) don't
present any such udev usbmisc devices.
However, they do present "usb" subsystem ones, so add this match back.

Leave idevice detection also for the "usbmisc" match since that's what the
original (known working) code before aforementioned commit did - it is
possible that it is required for some kernel / idevice combinations.
2022-10-29 15:32:04 +02:00
Maciej S. Szmigiero
81a89385a4 enumerator-udev: actually check for an idevice
up-enumerator-udev.c forgot to include the build config file, resulting in
HAVE_IDEVICE macro always being undefined.

This meant that the idevice backend was never actually instantiated - as
evidenced by the file not even compiling when this was fixed, due to
missing "up-device-idevice.h" include.

Fix both of these issues.
2022-10-21 00:35:13 +02:00
Benjamin Berg
c2e48aa9c2 supply-battery: Assume battery is present if the attr is missing
Fixes: #208
2022-09-09 16:28:11 +02:00
Bastien Nocera
b1edcc7cbb linux: Test whether BT mice get de-duplicated 2022-09-05 17:47:08 +02:00
Bastien Nocera
7f28aa5525 linux: Make BT mouse export its serial number
As a real mouse would.
2022-09-05 17:47:08 +02:00
Bastien Nocera
3265ce3ca6 linux: Make BT mice use the same address in tests
So we can use, one, the other, or both, and still see a single device.
2022-09-05 17:47:08 +02:00
Bastien Nocera
778b93a336 linux: Hide duplicate Logitech Bluetooth devices
A lot of newer Logitech devices support both the BATT Bluetooth LE
service as well the HID++ protocol. This advertises 2 separate battery
interfaces, one HID++ one through the kernel, one BATT one through
BlueZ.

Avoid confusing UIs and hide the Bluetooth battery from the interface by
checking for duplicates each time a new device is added.

Closes: #166
2022-09-05 17:47:08 +02:00
Bastien Nocera
d998510753 daemon: Don't count hidden devices 2022-09-05 17:47:08 +02:00
Bastien Nocera
d532d2a230 daemon: Don't warn if a device gets unexported
Now that we can unregister devices from the bus, make sure that we don't
throw warnings doing that.
2022-09-05 17:47:08 +02:00
Bastien Nocera
b624a690a2 daemon: Don't add unexported devices to the array
Otherwise all the following devices will be ignored.
2022-09-05 17:47:08 +02:00
Bastien Nocera
f035ab12a5 device: Make it possible to remove devices from D-Bus
Add up_device_unregister() method to allow backends to hide particular
UpDevices from the D-Bus interface.

Also rename the private up_device_register_device() function, no need to
say "device" twice there, we're registering the only device passed as an
argument.
2022-09-05 16:22:11 +02:00
Bastien Nocera
6d78c4ab11 battery: Quiet debug message
This might end up spamming users. Best leave those messages to folks who
are interested in root-causing those problems.
2022-09-05 13:18:13 +02:00
Bastien Nocera
4be148688f ci: Run upower inside catchsegv 2022-09-05 13:18:13 +02:00
Bastien Nocera
f2f5e45345 ci: Build catchsegv in CI
Build crash catcher "catchsegv"[1] in CI.

[1]: https://github.com/zatrazz/glibc-tools
2022-09-05 13:17:58 +02:00
Bastien Nocera
6bfe66a390 linux: Fix reading capacity_level with newer libgudev
Newer development versions of libgudev now strip the linefeeds by
themselves, so fix our naive linefeed-stripping which munched on the
last character of the string if there was no linefeed.

Could not find a percentage for capacity level 'Ful'

See https://gitlab.gnome.org/GNOME/libgudev/-/merge_requests/26
2022-09-05 10:34:36 +02:00
Bastien Nocera
5c8e74b76b linux: Allow filling only the serial from sibling
This fixes the serial number not being set on Bluetooth devices which
might not have a serial number but should always have a Bluetooth
address to differentiate them.
2022-09-05 10:34:03 +02:00
Bastien Nocera
29ecd92f9c linux: Fix BlueZ device names not synchronising
We were correctly handling an "Alias" property changing, but never
passed the property to that code as we were dropping anything that
wasn't a battery related update.
2022-09-02 11:38:39 +02:00
Landry Breuil
cb4193ff9d openbsd: initialize new_state with a default value before using it
otherwise the native build on openbsd complains:

../src/openbsd/up-backend.c:278:23: warning: variable 'new_state' is uninitialized when used here [-Wuninitialized]
        new_time_to_empty = (new_state == UP_DEVICE_STATE_DISCHARGING && a.minutes_left > 0 ? a.minutes_left : 0);
                             ^~~~~~~~~

regression from 8be73b98 ?
2022-08-25 11:43:05 +00:00
Landry Breuil
b643f272a7 openbsd: move most initialization code from _init to _coldplug (fixes #201)
regression from the refactoring in bd488fac
2022-08-10 09:02:47 +02:00
Benjamin Berg
d4259c009b Release 1.90.0 with larger refactorings
The version number has been bumped to be able to maintain multiple
branches without conflict. This version bump is not associated with a
API/ABI break.
2022-07-21 11:06:49 +02:00
Benjamin Berg
c2d77ae251 battery: User power/current reading from battery
This switches to always use the power/current reading if we had a
sensible reading at some point in the past.

In contrast to the older UPower code, will will however ignore the
reading for 10 seconds after a discontinuity (power plug/unplug or
resume) unless we read an explicit zero value after the event happened.

We do this under the assumption that the readings may be wildly off, and
it is better to not show an estimate rather than one that is wildly
incorrect.

Note that this commit also normalises negative power readings while
discharging to be positive.

Closes: #199
2022-07-21 11:06:49 +02:00
Benjamin Berg
1ab1b70d4a battery: Make repolling more explicit
Estimation code can request a battery poll if the value is not good
enough at the point. Make this a little bit more explicit by renaming
the intenral variable to "repoll_needed" and automatically resetting it
to FALSE.
2022-07-21 11:06:49 +02:00
Benjamin Berg
9dd78a74dd battery: Better separate power usage estimation code
The up_device_battery_estimate function did more than just estimating
the current power consumption (and doing some state guessing). Move the
time to full/empty checking out of the function. Also, let it directly
modify the reported state before it is pushed into the ring-buffer.
2022-07-21 11:06:49 +02:00
NorwayFun
e6a5d9a7f5 Add Georgian translaton 2022-07-21 08:01:24 +00:00
Benjamin Berg
e88e90fafa 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 14:15:22 +02:00
Benjamin Berg
54166e86a8 doc: Remove website
It now has its own repository.
2022-07-11 17:12:10 +02:00
Benjamin Berg
204fa25488 ci: Expose documentation as artifact 2022-07-08 15:26:06 +02:00
Benjamin Berg
3c4f902fbd test: Add battery ID changing test for history loading/saving 2022-06-22 18:38:49 +02:00
Benjamin Berg
46b5eb5fe7 device: Reload history when the ID changes
When a battery is swapped the old history needs to be saved and the
other history should be loaded.

Change the code to load the history lazily when needed. Then, to reload,
we purely need to clear the history object and it'll be loaded again
when required.
2022-06-22 18:37:46 +02:00