Commit graph

1723 commits

Author SHA1 Message Date
Kate Hsuan
293e00e0f9 up-device-battery: Test the user authorization before setting the charging threshold 2024-08-22 14:20:33 +08:00
Kate Hsuan
b032ad7aa9 up-device: Accessing polkit service in UpDevice 2024-08-22 14:17:07 +08:00
Kate Hsuan
09aab8018f up-daemon: Testing the authorization is allowed through polkit
An function is used to test the user authorization through polkit.
2024-08-22 14:12:50 +08:00
Kate Hsuan
0c9ba8048f Revert "Remove polkit dependency"
This reverts commit 9a2b263309.

Revisions:
1. Drop autoconf and migrate to meson build.
2. Drop dbus-glib dependency
2024-08-20 17:04:12 +08:00
Jelle van der Waa
5b656780ff linux: integration-test: Test for battery charging threshold
Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-20 17:04:12 +08:00
Jelle van der Waa
aed03b0705 up-device-battery: Recover the charging threshold settings when restarting
The configuration file holds the enable status of the battery charging
threshold for individual batteries. If it is enabled, upower will recover
the settings when upower starts up. If the configuration file is not
present, the battery charging threshold is disabled by default.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-20 17:04:12 +08:00
Jelle van der Waa
16e373add0 up-device-battery: Enable and preserve the battery charging threshold config
It sets the battery start and end charging threshold to the kernel and also
saves the configuration in a file. If upower is restarted, upower
can recover the charging threshold setting through the configuration file.

The configuration file is based on the model name and serial number of the
battery so the battery can be configured individually.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-20 17:04:04 +08:00
Jelle van der Waa
dc28eccd1c dbus: Define EnableChargeLimit() dbus method
EnableChargeLimit() is used to enable/disable the battery charging threshold
feature.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-20 16:58:42 +08:00
Jelle van der Waa
d2c7e183c3 linux: up-device-supply-battery: write the charging threshold to kernel
Write the battery charging start and end threshold to the kernel through
sysfs.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-15 23:21:01 +08:00
Jelle van der Waa
f3a81a610f linux: up-device-supply: reset the values for battery charging threshold
Reset the value of the properties.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-02 13:58:48 +08:00
Jelle van der Waa
a955bae8c4 up-device-battery: show support status for battery charging threshold
If the charging threshold is supported, the ChargeThresholdSupported will be
True.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-02 13:58:48 +08:00
Jelle van der Waa
3df2599629 dbus: Define ChargeThresholdEnabled and ChargeThresholdSupported properties
ChargeThresholdSupported property is used to show if the battery supports
Charging threshold feature. ChargeThresholdEnabled is used to show the
configuration (enabled/disabled) status of the feature.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-02 13:58:48 +08:00
Jelle van der Waa
a12f7d7eef dbus: Define ChargeStartThreshold and ChargeEndThreshold properties
Define dbus interface for ChargeStartThreshold and ChargeEndThreshold.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-02 13:58:48 +08:00
Jelle van der Waa
3ff4d63cfc linux: up-device-supply-battery: Get default charging limit from udev
Get the default charge limit through udev.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-02 13:58:47 +08:00
Jelle van der Waa
16277c88c4 rules: add battery charge limit udev and hwdb files
Set per battery-specific start/stop charge limits in udev as environment
variable with the option to allow a user to override the default 60%
start and 80% stop charge limit.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-07-23 15:42:52 +08:00
Kate Hsuan
669a1c2a27 linux: test: test for Ignore as CriticalPowerAction 2024-06-11 09:38:08 +00:00
Kate Hsuan
7ca11d476d linux: up-backend: Ignore as CriticalPowerAction
If AllowRiskyCriticalPowerAction is set to true, upower will ignore
the CriticalPowerAction and does nothing when battery level is at
critical level.

Link: https://aur.archlinux.org/cgit/aur.git/tree/0001-Add-a-critical-action-Ignore.patch?h=upower-nocritical-nosystemd-git
2024-06-11 09:38:08 +00:00
Kate Hsuan
d756a7d512 up-config: A config and warning message for Ignore as the CriticalPowerAction
Action "Ignore" is one of the CriticalPowerAction. It is a risky action
so AllowRiskyCriticalPowerAction should be set to true to enable it.
2024-06-11 09:38:08 +00:00
Kate Hsuan
00eb31a63c linux: device_supply: The new priority of device kind
Give a new priority for device type since the gaming_input may include
a keyboard, a touchpad... etc, for example, a Sony DualShock4 joypad.
A mouse and a touchpad may include a mouse and a keyboard.
Therefore, the priority is:
1. Audio
2. Gaming_input
3. Keyboard
4. Tablet
5. Touchpad
6. Mouse
2024-06-03 14:18:17 +08:00
Kate Hsuan
544eba5543 test: the test for CriticalPowerAction=Suspend
The test cases for AllowRiskyCriticalPowerAction=true and false when
CriticalPowerAction=Suspend.
2024-04-25 16:07:11 +08:00
Kate Hsuan
69436647c5 linux: up-backend: A safeguard for the risky CriticalPowerAction
If AllowRiskyCriticalPowerAction is true and the CriticalPowerAction
is "Suspend", The "Suspend" can be the CriticalPowerAction.
Otherwise, "HybridSleep" will be the CriticalPowerAction.
2024-04-25 16:07:11 +08:00
Kate Hsuan
469346b6bf up-config: set filename variable with g_autofree 2024-04-25 16:07:11 +08:00
Kate Hsuan
8cb9fb0231 up-config: The warning message for the risky CriticalPowerAction
The warning message will be shown when CriticalPowerAction is "Suspend".
One iwarning message is for enabling the risky CriticalPowerAction and
the other is to show the potential risk when
AllowRiskyCriticalPowerAction is true.
2024-04-25 16:07:11 +08:00
Alexander Couzens
18b4748435 linux: allow Suspend as CriticalPowerAction
When using UPower in a non-hybernate setup, the result of a
CriticalPowerAction would be PowerOff. Certain users prefer
Suspend instead, because this is the only way to recover
graceful from that state.
Suspend action will only used, when explicit configured.

Closes: #23
Closes: #59
Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-04-25 16:07:11 +08:00
Kate Hsuan
1146047df9 ci: replace compiling umockdev with a package
Test is based on umockdev package without compile it
during runner creation step.
2024-04-25 15:35:30 +08:00
Kate Hsuan
c8385cb08a Release 1.90.4
- Update change information to NEWS
2024-04-08 23:36:47 +08:00
Kate Hsuan
c970a1a1b9 Update release 1.90.3 information to NEWS 2024-04-08 23:04:42 +08:00
Kate Hsuan
a9fb6d5fa0 Release upower 1.90.3
1. Resolved high disk and CPU rate.
2. Update glib2 requirement to 2.66.0.
3. Stop guessing the unknown battery as a power supply.
4. Continue to support lid handling.
5. Document fixes and bug fixes.
2024-04-08 13:27:51 +08:00
Jelle van der Waa
1e58e8218a Stop using deprecated g_get_current_time
g_get_current_time was deprecated in 2.62 and can be directly replaced with
g_get_real_time.
2024-03-13 08:59:46 +01:00
Jelle van der Waa
dffb485a15 Bump glib2 requirement
Bump glib2 to 2.66 so we can use g_file_set_contents_full
2024-03-13 08:59:46 +01:00
Jelle van der Waa
3e808424b3 build: use install_emptydir for installing the history dir
This resolves the following deprecation warning, meson these days has a
special function for installing an empty directory:

* 0.60.0: {'install_subdir with empty directory'}
2024-03-11 14:53:53 +01:00
Kenny Levinsen
d8c22cf085 docs: Document all current device types
We only had documentation for the first 9 device types, ending with
Phone. Document all the current 29 device types.
2024-03-05 22:36:39 +01:00
Kate Hsuan
bbb593d306 up-device: Remove history only on device id change
Remove the history when the device id was changed.
2024-03-05 16:27:16 +08:00
Kate Hsuan
76e2b9e571 up-device: a filter to ignore the unknown status from the devices
Ignore all the unknown events from the devices.
2024-03-05 16:27:16 +08:00
Kate Hsuan
ab50a2bb3e up-history: Compare the history id with a given string
up_history_is_device_id_equal() is used to compare the history device_id
with a given string.
2024-03-05 16:27:16 +08:00
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