Commit graph

1736 commits

Author SHA1 Message Date
Jan Alexander Steffens (heftig)
b4697dbc62
up-polkit: Add G_ADD_PRIVATE (UpPolkit)
Without this, accesses to `UpPolkitPrivate` are actually out of bounds
and writing to it will cause heap corruption.

Fixes: https://gitlab.freedesktop.org/upower/upower/-/issues/281
2024-08-31 11:05:54 +02:00
Kate Hsuan
b71996a526 linux: integration-test: Add polkit test
Test action is allowed and not allowed when calling EnableChargeThreshold
dbus API.
2024-08-29 06:31:37 +00:00
Kate Hsuan
f55641cd43 Revert "Remove polkit tests"
This reverts commit bddc559713.

Changes:
- Removed Makefile
- Removed test for UpWakeups
2024-08-29 06:31:37 +00:00
Kate Hsuan
b26c8c79c9 ci: Add polkit dependency 2024-08-29 13:55:02 +08:00
Kate Hsuan
12d1b7ec43 Release 1.90.5
- Suspend and Ignore as the CriticalPowerActions (!218 and !218)
- Support for battery charging threshold (!208)
- Tweak the device priority to make sure the device kind joystick can be correctly shown. (#267)
2024-08-26 09:19:37 +00:00
Kate Hsuan
9449cb5831 dbus: G_MAXUINT means ignore ChargeStartThreshold or ChargeEndThreshold
If the value is G_MAXUINT, it means charge_control_start_threshold or
charge_control_end_threshold will be skipped.
2024-08-23 22:21:52 +08:00
Michael Biebl
d7005f618d Fix typo: deamon -> daemon 2024-08-23 08:30:22 +02:00
Kate Hsuan
399ec5d1ec linux: up-device-supply-battery: Don't report error when one of the start/stop charge threshold isn't writable
One of the charge_control_start|end_threshold isn't writable for some
systems, for example, Macbook Air. Therefore, if both files can't be
written, the error is returned.
2024-08-22 14:20:33 +08:00
Kate Hsuan
5882721f19 linux: up-device-supply-battery: Allow skipping start or end charging threshold setting
This allows the one of charge_control_start|end_threshold can be ignored
by a "_" character.
The udev hwdb can be set in the following format.

- Skip charging start limit
CHARGE_LIMIT=_,80
- Skip charging end limit
CHARGE_LIMIT=30,_
2024-08-22 14:20:33 +08:00
Kate Hsuan
4e8e8b43f8 daemon: Get and store env override configurations in the deamon 2024-08-22 14:20:33 +08:00
Kate Hsuan
b604a297be meson: Enable/disable polkit through an option
The user can enable and disable polkit using -Dpolkit.
2024-08-22 14:20:33 +08:00
Kate Hsuan
bfde9fefb7 build: Enbale/disable polkit based on HAVE_POLKIT 2024-08-22 14:20:33 +08:00
Kate Hsuan
7011b93c28 Revert "policy: Remove policy for removed features"
This reverts commit ababfa2aaf.

Changes:
1. Drop the policy for the old APIs.
2. Add a policy for enableChargeLimit.
2024-08-22 14:20:33 +08:00
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