Commit graph

1788 commits

Author SHA1 Message Date
Kate Hsuan
6ef7fcd1bd rules: Update hwdb from upstream NUT
Include:
Liebert
usb:v10AFp0000*
usb:v10AFp0002*

Link: https://github.com/networkupstools/nut
Link: https://raw.githubusercontent.com/networkupstools/nut/master/scripts/upower/95-upower-hid.hwdb
2024-03-05 15:32:48 +08:00
Kate Hsuan
efc8ac61af rules: Update hwdb from NUT
Link: https://github.com/networkupstools/nut
Link: https://raw.githubusercontent.com/networkupstools/nut/master/scripts/upower/95-upower-hid.hwdb
2024-02-27 10:56:40 +08:00
Kate Hsuan
be82397367 Revert "ci: Update last ABI break"
This reverts commit 520939242e.

Revert the last ABI break since API has been reverted.
2024-02-09 15:07:21 +08:00
Kate Hsuan
b6fb567824 Revert "build: Bump the library soname after recent changes"
This reverts commit a94c94fe6b.

Revert so verion bump up since the API has been reverted.

Resolves: https://gitlab.freedesktop.org/upower/upower/-/issues/261
2024-02-09 14:22:01 +08:00
Jelle van der Waa
17c14cc63f Revert "all: Remove Lid handling"
This reverts commit 07565ef6a1.

In the current systemd stable release 255 org.freedesktop.login1 does
not emit a LidisClosed event, this has added in systemd `main` and will
be availble in the next release.

As GNOME control panel still uses UPower's `LidIsclosed` property and
many other DE's such as Xfce/LXQt/Deepin as well revert this until the
systemd changes are available in all Distributions.

https://github.com/systemd/systemd/pull/30706

Resolve: https://gitlab.freedesktop.org/upower/upower/-/issues/260
2024-01-26 14:57:27 +00:00
Jelle van der Waa
18d550a555 Revert "lib: Remove deprecated up_client_get_devices()"
This reverts commit 6766602954.

Removing this and renaming up_client_get_devices2 to
up_client_get_devices means consumers have to support three cases to
support older UPower versions. So for example GNOME Control center now
uses up_client_get_devices2 and would have to now check if UPower
version > 0.92.
2024-01-26 10:20:50 +01:00
Kate Hsuan
b21cec4c11 dbus: org.freedesktop.UPower: EnergyRate is a positive value
The EnergyRate is a positive value since most of the laptops are ACPI
based system and report the power status through power_now sysfs
attribute. Moreover, the ACPI specification mention that the battery
power status is a positive value, measured in watt.

https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/acpi-battery-and-power-subsystem-firmware-implementation

Fix: https://gitlab.freedesktop.org/upower/upower/-/issues/252

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-01-15 07:36:53 +00:00
Martin Pitt
bd1e4698f4 linux: Adjust test_bluetooth_le_device for dbusmock 0.30.1
dbusmock 0.30.1 changed the BlueZ template to set the default "Class"
property to `MOCK_PHONE_CLASS` right away instead of in PairDevice() [1].

test_bluetooth_le_device() relied on the previous implicit default of a
"0" Class value. Set this explicitly to expect a "generic" device. This
makes the test work with old and current dbusmock versions.

https://bugs.debian.org/1059467

[1] https://github.com/martinpitt/python-dbusmock/pull/192
2023-12-28 21:13:15 +01:00
Ratchanan Srirattanamet
dfde9e2274 linux: stop assuming power supply of unknown type as battery
Some vendor kernel (most notably Android devices) expose various types
of BMS (battery management system) as power supplies. This is something
UPower has never designed to deal with, and thus UPower should not
represent or consider it to be a battery.

Fortunately, most of the time the actual "battery" power supply has the
correct type, so we can safely ignore those devices which have unknown
type. Also, the code that assumes power supply of unknown type seems
pretty dated and probably doesn't make sense anymore. So, let's remove
this assumption altogether.
2023-11-09 15:51:14 +07:00
Jelle van der Waa
4baf9b8903 linux: drop f-literals without format string 2023-11-03 15:26:26 +01:00
Jelle van der Waa
d3a1d17d59 linux: prefer is not None over !=
Compare on object identity not equality.
2023-11-03 15:18:09 +01:00
Pino Toscano
029651a96d build: make 'udevrulesdir' and 'udevhwdbdir' as Linux-only
udev is available only on Linux, so limit their usage when the backend
is 'linux'.

This fixes the build when the backend is different than 'linux', i.e.
typically on non-Linux OSes.
2023-07-07 06:50:31 +00:00
Bastien Nocera
aee533e517 ci: Work-around dnf builddep not being installable
Work-around rawhide being broken:
Problem: The operation would result in removing the following protected packages: dnf
2023-07-07 08:43:08 +02:00
Bastien Nocera
520939242e ci: Update last ABI break 2023-07-06 11:18:58 +02:00
Bastien Nocera
a94c94fe6b build: Bump the library soname after recent changes 2023-07-06 11:18:30 +02:00
Bastien Nocera
6766602954 lib: Remove deprecated up_client_get_devices()
And rename up_client_get_devices2() to up_client_get_devices().
2023-07-06 11:15:02 +02:00
Bastien Nocera
07565ef6a1 all: Remove Lid handling
It is now handled solely in logind to take power management decisions,
and in the compositor for making decisions related to available
displays.

See:
https://www.freedesktop.org/software/systemd/man/org.freedesktop.login1.html
2023-07-06 11:09:42 +02:00
Bastien Nocera
8dcf54440d 1.90.2 2023-07-06 10:52:27 +02:00
Bastien Nocera
bdc5638627 linux: Add installed-tests manifest
This will allow running the tests to target installed binaries.
2023-07-06 10:31:46 +02:00
Bastien Nocera
e4e498e198 linux: Fix integration test to work under jhbuild
Fixes: 648abe9c27 ("tests: Test a client running while daemon restarts")
2023-07-06 10:07:08 +02:00
Bastien Nocera
f8fe036331 linux: Work-around potential race in test_headset_hotplug 2023-07-05 17:39:19 +02:00
Bastien Nocera
38576a9bd7 linux: Emit added/removed signals when duplicates change 2023-07-05 17:39:19 +02:00
Bastien Nocera
53ccc01be9 linux: Add test for device signals with wireless_status 2023-07-05 17:39:19 +02:00
Bastien Nocera
4d3d8759db linux: Add wait_for_mainloop() test helper 2023-07-05 17:39:19 +02:00
Bastien Nocera
faa5a560f9 linux: Emit added/removed signals when wireless_status changes
Closes: #240
2023-07-05 17:39:19 +02:00
Bastien Nocera
8dd86689fa device: Add up_device_is_registered()
So we can know whether a device was registered when hiding it and
eventually send the appropriate "device-removed" signal.
2023-07-05 17:39:19 +02:00
Bastien Nocera
0ed632daab device: Return success after up_device_register
Return whether up_device_register() registered a device, so we can
announce it through a device-added signal.
2023-07-05 15:33:20 +00:00
Michael Biebl
dec9468136 linux: Fix integration test to work with system installed upower binary
Fixes: 648abe9c27 ("tests: Test a client running while daemon restarts")
Closes: #241
2023-07-05 15:30:47 +00:00
Bastien Nocera
72183b6e04 build: Require a newer libgudev
Some of the functionality will be broken with older versions, in
particular when it comes to newline stripping when reading sysfs
attributes.
2023-07-05 17:16:52 +02:00
Bastien Nocera
744c49eaac ci: Install newer libgudev
Until the image creation CI job can run all the way through:
https://gitlab.freedesktop.org/upower/upower/-/issues/242
install a newer libgudev by hand.
2023-07-05 17:16:52 +02:00
Bastien Nocera
e8d8417023 ci: Also run on 'schedule' pipelines 2023-07-05 16:22:48 +02:00
Bastien Nocera
96c34a3bb9 1.90.1 2023-07-04 15:51:22 +02:00
Bastien Nocera
95de7181dd linux: Add test for is-present changes at runtime 2023-07-04 15:20:20 +02:00
Stuart Hayhurst
d74536fa0e linux: Update present property on refresh
Some devices change the 'present' sysfs attribute after upower
registers them. This should be updated in upower, otherwise
applications will ignore present devices, or listen to absent devices.

Fixes: 0b7d7cfc08 ("linux: Fix is-present for devices at startup")
2023-07-04 15:18:31 +02:00
Bastien Nocera
648abe9c27 tests: Test a client running while daemon restarts 2023-07-04 10:25:44 +02:00
Bastien Nocera
a0c7b16aff lib: Avoid possible crash on daemon restart
#0  0x00007f40eb3e43a6 g_type_check_class_is_a (libgobject-2.0.so.0 + 0x3b3a6)
 #1  0x00007f40eb3c5253 g_object_class_find_property (libgobject-2.0.so.0 + 0x1c253)
 #2  0x00007f40bffcc668 up_device_changed_cb (libupower-glib.so.3 + 0xc668)
 #3  0x00007f40eb3bd4ea g_closure_invoke (libgobject-2.0.so.0 + 0x144ea)
 #4  0x00007f40eb3ebe16 signal_emit_unlocked_R.isra.0 (libgobject-2.0.so.0 + 0x42e16)
 #5  0x00007f40eb3dccbd g_signal_emit_valist (libgobject-2.0.so.0 + 0x33cbd)
 #6  0x00007f40eb3dcf33 g_signal_emit (libgobject-2.0.so.0 + 0x33f33)
 #7  0x00007f40eb3c86b4 g_object_dispatch_properties_changed.lto_priv.0 (libgobject-2.0.so.0 + 0x1f6b4)
 #8  0x00007f40eb3cef1f g_object_notify (libgobject-2.0.so.0 + 0x25f1f)
 #9  0x00007f40bffd5f1c up_exported_device_proxy_g_properties_changed (libupower-glib.so.3 + 0x15f1c)
 #10 0x00007f40eb3bd4ea g_closure_invoke (libgobject-2.0.so.0 + 0x144ea)
 #11 0x00007f40eb3ec315 signal_emit_unlocked_R.isra.0 (libgobject-2.0.so.0 + 0x43315)
 #12 0x00007f40eb3dccbd g_signal_emit_valist (libgobject-2.0.so.0 + 0x33cbd)
 #13 0x00007f40eb3dcf33 g_signal_emit (libgobject-2.0.so.0 + 0x33f33)
 #14 0x00007f40eb526fff process_get_all_reply (libgio-2.0.so.0 + 0x11dfff)
 #15 0x00007f40eb52a749 on_name_owner_changed_get_all_cb (libgio-2.0.so.0 + 0x121749)
2023-07-03 17:21:17 +02:00
Bastien Nocera
f82c55b416 linux: Lower debug severity 2023-07-03 17:15:24 +02:00
Bastien Nocera
80bc0d7c79 linux: Add test for "wireless_status" sysfs attribute 2023-07-03 17:15:07 +02:00
Bastien Nocera
5ddc7c8bc5 linux: Set the "disconnected" property on events
When a sibling device has its "wireless_status" attribute changing,
change the "disconnected" property appropriately.
2023-07-03 16:10:13 +02:00
Bastien Nocera
570d6cdf27 linux: Track "disconnected" property to hide devices
Hide "disconnected" devices.
2023-07-03 16:10:13 +02:00
Bastien Nocera
20c5e83f12 device: Add disconnected property
The property will be FALSE and stay FALSE for all devices, except for
the Linux ones that have a "wireless_status" attribute set to
"disconnected". This will then be used by the backend to hide the device
until the wireless device is turned on again.
2023-07-03 16:10:13 +02:00
Bastien Nocera
f7142fe567 daemon: Don't prepare a poll for a hidden device
We don't need to poll a device that's not registered to be visible on
the bus, so check the visibility before setting that poll.
2023-07-03 16:10:13 +02:00
Bastien Nocera
babe81a871 linux: Add headset hotplug test 2023-07-03 16:07:46 +02:00
Bastien Nocera
3487e804af linux: Add debug to audio sub-type detection 2023-07-03 16:07:46 +02:00
Bastien Nocera
5656939590 linux: Add debug to uevent handler 2023-07-03 16:07:46 +02:00
Bastien Nocera
801463a630 linux: Don't overwrite detected type with another less precise one
Fix a problem where if the input node of a headset appears after the
headset type has been detected, the type would get overwritten to be a
keyboard.
2023-07-03 16:07:46 +02:00
Bastien Nocera
ffe33934ae linux: Another fix for headsets type detection when hotplugged
Also handle the case where the sibling device changes after the main
battery device has been created.
2023-07-03 16:07:46 +02:00
Bastien Nocera
ac68136b41 linux: Fix headsets type detection when hotplugged
When a UpDevice is finally created, it's possible that we've seen "add"
events as well as "change" events for siblings. But as the "change"
events don't create new unknown siblings to store, we have GUdevDevices
from the original "add" event in that store.

As the GUdevDevice documentation mentions:
"By design, GUdevDevice will not react to changes for a device – it
only contains a snapshot of information when the GUdevDevice object
was created. To work with changes, you typically connect to the
“uevent” signal on a GUdevClient and get a new GUdevDevice
whenever an event happens."

To avoid having to try and update the siblings store, fetch an updated
GUdevDevice for the sibling we want to tell the core about, with the
properties all updated.

This fixes headsets plugged in after the daemon start being detected as
keyboards when the sound card device is tagged with the form factor
in a change event before the battery is exported.

Closes: https://gitlab.freedesktop.org/upower/upower/-/issues/239
2023-07-03 15:54:51 +02:00
Bastien Nocera
ab116cda4a linux: Remove unused variable
../src/linux/up-backend.c:158:19: warning: unused variable 'name' [-Wunused-variable]
        g_autofree char *name = NULL;
                         ^
2023-04-18 16:39:07 +02:00
Landry Breuil
99d2659efc battery: Fix some warnings
building natively on OpenBSD with clang 13, i get those warnings:

../src/up-device-battery.c:128:53: warning: absolute value function 'abs' given an argument of type 'gint64' (aka 'long long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
                if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td))
                                                                  ^
../src/up-device-battery.c:128:53: note: use function 'llabs' instead
                if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td))
                                                                  ^~~
                                                                  llabs

../src/up-device-battery.c:128:65: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
                if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td))
                                                                              ^
../src/up-device-battery.c:128:65: note: use function 'llabs' instead
                if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td))
                                                                              ^~~
                                                                              llabs
2023-04-18 16:38:59 +02:00