Commit graph

1864 commits

Author SHA1 Message Date
Kate Hsuan
09a8e63bae libupower-glib: up-client: Verify the UpClient pointer when invoking the API
Passing a NULL UpClient to up_client_get_devices2() led to the following
error message and crash since up_client_get_devices_full() returned
immediately, without properly setting up a GError with an error message.

The input UpClient pointer verification was moved from the internal
function to the API entry to ensure only a valid UpClient is passed
to the internal function. Moreover, GError will be properly set by the
GLib dbus APIs and the internal function.

(upower:21076): libupower-glib-CRITICAL **: 16:33:53.919: up_client_get_devices_full: assertion 'UP_IS_CLIENT (client)' failed
Segmentation fault         (core dumped) ./upower -d

Related: https://gitlab.freedesktop.org/upower/upower/-/merge_requests/296

Reported-by: Mathias Krause <minipli@grsecurity.net>
Signed-off-by: Kate Hsuan <hpa@redhat.com>
2026-02-03 21:42:03 +08:00
Kate Hsuan
f61735aa6d rules: 95-upower-hid: Update to the latest hwdb
Update NUT hwdb rules.
2026-01-21 12:11:32 +08:00
Kate Hsuan
eff769c65f Revert "lib: Mark lid related functions and properties as deprecated"
This reverts commit 4e962fdc8d.

Undeprecate lid APIs since upower continues to support lid DBus APIs.
2026-01-06 14:26:16 +08:00
Sicelo A. Mhlongo
37f7086983 up-self-test: Add historical voltage data support 2026-01-05 12:39:22 +02:00
Sicelo A. Mhlongo
8e424217f5 lib: up-device: Expose historical voltage data
Enable library users to access stored voltage data.
2026-01-05 12:39:13 +02:00
Sicelo A. Mhlongo
7d486c500c up-device: Implement storage and retrieval of historical voltage data 2026-01-05 12:34:44 +02:00
Sicelo A. Mhlongo
09c8bbb0f7 up-history: Store and retrieve historical data for voltage
Extend the history implementation to store and retrieve data about voltage
information for batteries.
2026-01-05 12:34:44 +02:00
Sicelo A. Mhlongo
1c052a378f dbus: Add voltage as a supported history item
In certain applications, access to historical voltage data might be useful, for
example to plot voltage curves. Add support for this property.
2026-01-05 12:34:26 +02:00
Kate Hsuan
bf3d20378f contrib: add a tartan static analysis script and description 2025-12-29 17:02:31 +08:00
Sicelo A. Mhlongo
f6e63cfc40 upower: deprecate luminosity property
Since d2053eff ("linux: Remove user-space support for Logitech Unifying
devices"), the luminosity property is no longer in use and no code for it
exists except in the lib. Deprecate and eventually drop it.
2025-12-17 16:46:28 +08:00
Kate Hsuan
0f57b6bf73 Drop the incorrect "since version" and mark the capacity_level property as deprecated
Fix: 09ada72 (dbus: org.freedesktop.UPower.Device: deprecate CapacityLevel property)
2025-12-17 16:19:55 +08:00
Kate Hsuan
38ab5417b7 linux: integration-test: test for the battery recalibration
Test case for ignoring the CriticalPowerAction when performing the battery
recalibration.
2025-12-15 14:19:13 +08:00
Kate Hsuan
d9f42cfc9d up-daemon: Report UP_DEVICE_LEVEL_NONE when battery is performing recalibration
If the battery is performing recalibration and AC is online,
UP_DEVICE_LEVEL_NONE is considered.
2025-12-15 14:19:13 +08:00
Kate Hsuan
4722fcfaac up-config: introduce the ExpectBatteryReCalibration for battery recalibration
ExpectBatteryReCalibration allows the user to ignore the
CriticalPowerAction when performing the battery recalibration.
2025-12-15 14:19:13 +08:00
Kate Hsuan
1ba5f3a55e linux: up-device-supply-battery: Fix assigning an error to a non-NULL GError pointer
As some systems only allow for one charge threshold setting, the overall
process is treated as a success as long as one of the values is set
correctly. We only treat it as an error (and return FALSE) if both the
start and end threshold settings fail. For this reason, we don't need
to track specific errors for every write, so the GError parameter in
g_file_set_contents_full() is set to NULL.

Fedora upowerd[1326]: g_file_set_contents_full: assertion 'error == NULL || *error == NULL' failed
Fedora upowerd[1326]: GError set over the top of a previous GError or uninitialized memory.
                      This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
                      The overwriting error message was: Failed to set charge control thresholds

Resolves: #331
2025-12-12 20:14:04 +08:00
Kate Hsuan
c5df437cc1 linux: up-device-supply: fix the resource leak
1. free the udev parent node automatically.
2. free new_model_name variable in the same scope.
2025-11-28 15:00:22 +08:00
Kate Hsuan
d79841fe40 meson: Release 1.91.0
The major change includes:
1. Support multiple keyboard backlight LED control.
2025-11-25 16:39:56 +08:00
Kate Hsuan
a4d0d469f3 meson: so relase bump up due to recent property changes 2025-11-25 15:25:06 +08:00
Kate Hsuan
09ada726f7 dbus: org.freedesktop.UPower.Device: deprecate CapacityLevel property
This property is duplicated from BatteryLevel and confuses the user.
2025-11-25 14:33:55 +08:00
Kate Hsuan
391e3323f0 etc: UPower.conf.d: add UPower.conf.d
The configuration files in the UPower.conf.d will override the primary
configuration.
2025-11-12 15:46:00 +08:00
Manuel A. Fernandez Montecelo
46bbc8a602 Add support for conf.d style dirs (UPower.conf.d)
This change adds the feature to read config from conf.d style
directories (UPower.conf.d), commonly supported by other tools, as an
extension of the main config file.

This is useful and convenient in several situations, for example:

- distributions can set different values from the defaults shipped
  upstream without having to modify the main UPower.conf

- different packages or config-management tools can change config just
  by adding, removing or modifying files in that directory

The main config file, e.g. '/etc/UPower/UPower.conf', will be
processed first, and then files in the UPower.conf.d dir, if existing.

The directory to use is derived automatically, e.g.
'/etc/UPower/UPower.conf.d/' if the main config file is
'/etc/UPower/UPower.conf'.  Only files within that directory are
considered, and only those with valid config-group 'UPower' and with
the filename format: starting with '00-' to '99-', ending in '.conf'
and with alphanumeric characters, dash or underscore in between.

The candidate files within the given directory are sorted (with
g_strcmp0(), so the ordering will be as with strcmp()).  The
configuration in the files being processed later will override
previous config, in particular the main config, but also the one from
previous files processed, if the Group and Key coincide.

Add also relevant integration test: 'test_conf_d_support'
2025-11-12 15:45:56 +08:00
Luca Boccassi
5f572ffd9a polkit: fix config syntax
These fields do not start with an underscore. polkitd complains
about them:

 polkitd[2017783]: skipping unknown tag <_description> at line 18
 polkitd[2017783]: skipping unknown tag <_message> at line 19
2025-10-21 16:59:38 +08:00
Kate Hsuan
9c8769d7df ci: fix pre-commit test
Resolve the libatomic dependency issue.
2025-10-21 16:51:40 +08:00
Kate Hsuan
8ce78b7f9e meson_options: replace deprecated boolean variable 2025-09-17 12:27:42 +08:00
Kate Hsuan
f26409e925 rules: 95-upower-hid: update hwdb from upstream NUT
Update to the latest hwdb from NUT.

Link: https://networkupstools.org
Link: https://raw.githubusercontent.com/networkupstools/nut/master/scripts/upower/95-upower-hid.hwdb
2025-09-16 15:51:36 +08:00
Luciano Santos
5bf9cac60d build: Make installation of tests optional
Default to installing them, while letting people/distributors decide
what they want.
2025-09-16 15:25:49 +08:00
Sicelo A. Mhlongo
84aab7aefa linux: up-enumerator-udev: also permit lp5523:kb name
While common keyboard backlight devices use 'kbd_backlight' in the name, per
linux kernel include/dt-bindings/leds/common.h, there are a few legacy names,
including 'lp5523:kbN'. They cannot be easily changed now because it would
break userspace, hence the names are still provided in the kernel.  Support
them in upower as well. The lp5523 as used on the Nokia N900 exposes six
independent keyboard backlight LEDs, and UPower is able to manage them with
this patch in place.
2025-09-05 17:22:08 +08:00
Kate Hsuan
afb346cf77 linux: integration-test: Multiple keyboard backlight LED support
The integration test for multiple keyboard backlight support.
2025-09-05 17:22:08 +08:00
Kate Hsuan
e0baa3fdcb up-daemon: The implementation of EnumerateKbdBacklight
The implementation for enumerating all keyboard backlight LED objects
on the system.
2025-09-05 17:22:08 +08:00
Kate Hsuan
d316a111f7 dbus: org.freedesktop.UPower: Enumerate kbd backlight LEDs
Enumerate all keyboard backlight LED objects on the system.
2025-09-05 17:22:08 +08:00
Kate Hsuan
4ba78c54a9 linux: up-enumerator-udev: enumerate the LED subsystem
The LED udev subsystem was added to the list to watch the
keyboard backlight LED device events.
2025-09-05 17:22:08 +08:00
Kate Hsuan
6bfc3d6100 up-daemon: device-added and device-removed keyboard backlight device
The keyboard backlight device will be added to or removed from DeviceList
when receiving the "device-added" and "device-removed" signal.
2025-09-05 17:22:08 +08:00
Kate Hsuan
796ce9e579 up-daemon: DeviceList for keyboard backlight LED devices
The DeviceList was created to store the keyboard backlight LED devices.
2025-09-05 17:22:08 +08:00
Kate Hsuan
fd6eebb397 linux: up-enumerator-udev: Process add, change, and remove udev events for keyboard backlight device
Add, update, and remove the keyboard backlight LED device when receiving
add, change, and remove udev events.
2025-09-05 17:18:17 +08:00
Kate Hsuan
e01aa7c903 linux: up-kbd-backlight-led: the keyboard backlight control implementation for Linux
The implementation for Linux included:
1. Set and get brightness.
2. Get max brightness.
3. Signal if the brightness was changed by the device.
2025-09-05 16:47:11 +08:00
Kate Hsuan
1d40bc2027 linux: up-backend: Add and remove keyboard backlight LED device
These are the callback functions for the signals "device-added" and
"device-removed" to add and remove keyboard backlight devices.
2025-09-05 11:49:38 +08:00
Kate Hsuan
9f9b8478bd up-device-list: Introduce the UpDeviceKbdBacklight object
This commit makes UpDeviceList store the UpDeviceKbdBacklight objects and
sets the udev native path property of UpDevice and UpDeviceKbdBacklight.
2025-09-05 11:49:38 +08:00
Kate Hsuan
aaf52de8dc up-device-kbd-backlight: The parent class for keyboard backlight control
This parent class can be used for multiple implementations, such as freebsd
and Linux. The child class inherits it to register the device to upower
and access the dbus services.
2025-09-05 11:49:38 +08:00
Kate Hsuan
0dcb46475f dbus: org.freedesktop.UPower.KbdBacklight: Description for deprecating the KbdBacklight object path
The object path /org/freedesktop/UPower/KbdBacklight is going to be deprecated in the future.
The upper-layer app should migrate to the new API instead.
2025-09-05 11:49:38 +08:00
Kate Hsuan
40a4498454 dbus: KbdBacklight: Add a native path attribute
The DBus property shows the udev native path.
2025-09-05 11:49:38 +08:00
Kate Hsuan
c56ff5f207 Release 1.90.10
- Fix wrong model name of the devices (!267, #309)
- Switch charge_types to "Custom" when charging threshold is enabled (!268, #275)
- Fix invalid command line arguments (!269)
- Fix leak when reporting daemon usage error (!270)
- OpenBSD: support battery status from qcpas (!272)
- Fix history progression (!274, #316)
- Add a battery filter to the upower command line (!275)
- Change the charging behaviors using charge_types (!276, !46, #275)
- Fix integration tests issues, including floating point value and race between umockdev and upower (!277, !278)
- Rework upower command (!280)
- Propagate charge-threshold-enabled to display device (!281)
2025-08-26 16:04:24 +08:00
Josh Triplett
3369d31472 upower: Add a -b/--battery option to dump only battery information
This is useful when asking people to give information about battery
health. It avoids having to give two-step instructions of first
enumerating devices with `upower -e`, then looking for a device whose
name starts with `/org/freedesktop/UPower/devices/battery_`, then
running `upower -i` on that device.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
2025-08-26 13:29:52 +08:00
Florian Müllner
ff605e51c1
up-daemon: Propagate charge-threshold-enabled to display device
The property indicates that a device is plugged-in but not charging
because of the charging threshold. Desktops may want to indicate
that state, but the property is currently only exposed on actual
devices, not the virtual display device that is usually exposed
in the interface.

To address this, propagate the property to the display device
if at least one device has charge thresholds enabled.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5228
2025-08-21 14:30:45 +02:00
Kate Hsuan
4d6da1bb0f tools: up-tool: rework upower dump and enumerate
1. Move dump and enumerate to the separated functions.
2. Introduce an output filter.

Co-work-with: Cursor
Reviewed-by: Kate Hsuan <hpa@redhat.com>
2025-08-20 14:25:37 +08:00
Kate Hsuan
e1d25fa549 linux: integration-test: The type of percentage property is double
The data type of the "Percentage" property is double, so the value is a
floating point number, ex, 100.0
2025-08-12 16:10:52 +08:00
Michael Biebl
12a165e153 linux: integration-test: fix comparison of floating point values
Use assertAlmostEqual for all values that are floating point numbers:

https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertAlmostEqual

This avoids issues with excessive precision on i386.
More information https://wiki.debian.org/ArchitectureSpecificsMemo#i386

See also the corresponding downstream bug report
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050436

The patch was generated using:

for i in Capacity Energy EnergyEmpty EnergyFull EnergyFullDesign EnergyRate Luminosity Percentage Temperature Voltage ; do
    sed -i -r "s/(assertEqual)(.*$i)/assertAlmostEqual\2/g" src/linux/integration-test.py
done

Fixes: #251
2025-08-12 15:46:23 +08:00
Kate Hsuan
903a8278f8 linux: integration-test: the settings discovery for charge threshold
The test case for settings discovery for charge threshold.
The test cases include:
1. only charge_types (4)
2. charge_control_start_threshold + charge_control_end_threshold +
   charge_types (7)
3. charge_control_end_threshold + charge_types (6)
2025-08-11 15:05:10 +08:00
Kate Hsuan
3a2fe524d0 linux: up-device-supply-battery: Discover the settings of charge threshold
This commit discovers the settings, including charge_control_start_threshold,
charge_control_end_threshold, and charge_types and update the results to
the battery information.
2025-08-11 15:05:10 +08:00
Kate Hsuan
1bf86b5483 up-device-battery: set up charge-threshold-settings-supported property
Setup and update the charge-threshold-settings-supported property.
2025-08-11 15:05:10 +08:00
Kate Hsuan
1c7b9d8bae dbus: org.freedesktop.UPower.Device: the ChargeThresholdSettingsSupported property
The types of settings for charge thresholds that are supported. The value
is a bitmask value and it is the sum of the supported types.

1: The system supports charge start threshold. The battery discharges to a
   percentage, then starts charging.
2: The system supports charge end threshold. The battery charges to a
   percentage, then stops charging.
4: The system supports optimized charging behaviors controlled by the
   system firmware.

Examples:

If the system supports charge start threshold and charge end threshold,
the value is 3.

If the system supports charge end threshold and the battery charging
behavior is controlled by the system firmware, the value is 6.
2025-08-11 15:05:10 +08:00