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'
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
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.
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.
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.
- 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)
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>
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
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)
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.
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.
Charge_types has to be "Long_Life" if charging threshold is enabled.
Charge_types has to be "Fast", "Standard", or "Adaptive" if charging
threshold is disabled.
If the charge threshold is enabled, the charge_types set "Long_Life". If
the charge threshold is disabled, the charge_types set to any of
charge_types for charging, such as "Fast", "Standard", and "Adaptive".
This commit is only for the system that only has the charge_types attribute
to control the battery behaviour.
We found some systems, such as Lenovo ideapad that don't support
charge_control_start_threshold and charge_control_end_threshold but it
provide the charge_types Long_Life and Standard. The chatre_types
Long_Life operate the battery in the conservation mode. That means
if Long_Life and Standard are found, the system supports the
charge threshold feature.
Co-work-with: Cursor
Reviewed-by: Kate Hsuan <hpa@redhat.com>
On a slow system like riscv64, the test_daemon_version and
test_daemon_restart tests sometimes failed. A delay was added after the
daemon starts to give it enough time to fully initialize, which has
reduced the chance of these tests failing.
Sometime we found the errors shows below when pipeline test was running.
379s ERROR: test_bluetooth_hidpp_mouse (__main__.Tests.test_bluetooth_hidpp_mouse)
379s Logitech Bluetooth LE mouse with HID++ kernel support
379s ----------------------------------------------------------------------
379s Traceback (most recent call last):
379s File "/usr/libexec/upower/integration-test.py", line 4380, in test_bluetooth_hidpp_mouse
379s self.assertEventually(
379s ~~~~~~~~~~~~~~~~~~~~~^
379s lambda: self.get_dbus_dev_property(bat0_up, "Model"), value=alias
379s ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
379s )
379s ^
379s File "/usr/libexec/upower/integration-test.py", line 399, in assertEventually
379s if condition() == value:
379s ~~~~~~~~~^^
379s File "/usr/libexec/upower/integration-test.py", line 4381, in <lambda>
379s lambda: self.get_dbus_dev_property(bat0_up, "Model"), value=alias
379s ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
379s File "/usr/libexec/upower/integration-test.py", line 316, in get_dbus_dev_property
379s return self.dbus.call_sync(
379s ~~~~~~~~~~~~~~~~~~~^
379s UP,
379s ^^^
379s ...<7 lines>...
379s None,
379s ^^^^^
379s ).unpack()[0]
379s ^
379s gi.repository.GLib.GError: g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/freedesktop/UPower/devices/mouse_dev_11_22_33_44_AA_BB” (19)
379s
The upower and bluez daemons were started after the udev was
initialized to avoid the random errors.
If the charge_types isn't set to "Custom" on a Dell laptop, the charging
threshold doesn't work. This commit sets the charge_types to "Custom" if
the charging threshold is enabled. Also, the charge_types will be set to
"Fast", "Standard", or "Adaptive" when the charging threshold is disabled.
This commit reads and writes the battery udev attribute "charge_types".
However, this attribute can't be found on some of the systems, so the error
on reading and writing charge_types attribute is ignored.