Commit graph

1747 commits

Author SHA1 Message Date
Kate Hsuan
7d7bb84fde linux: up-enumerator-udev: Find the correct parent id for input devices
The parent id for the devices under "/sys/devices/virtual/misc/uhid/*"
points to /sys/devices/virtual/misc/uhid. It will cause the device
information to be updated incorrectly. For example, the type for a mouse is
updated to "keyboard". This patch makes sure the correct parent id for
each input device.

Resolves: #268 #286
2024-09-27 16:11:29 +08:00
Stuart Hayhurst
9ee76826bd Fix race condition in test_sibling_priority_no_overwrite 2024-09-25 16:56:11 +01:00
Kate Hsuan
94c91f93f1 NEWS: Update release date 2024-09-18 11:25:08 +08:00
Kate Hsuan
7fbc02e8af Release 1.90.6
- Fix g_object_weak_ref: assertion 'g_atomic_int_get (&object->ref_count) >= 1' failed (#281, !233)
- Fractional battery percentage (!226)
- CI enhancement. (!236)
- Tweak the default battery charging threshold to 75-80. (!234)
2024-09-18 02:39:43 +00:00
Jelle van der Waa
3390fa48ae linux: integration-test: correct unsupported test comment 2024-09-17 20:13:50 +02:00
Jelle van der Waa
23cf8c19f7 linux: integration-test: drop f-string without placeholder 2024-09-17 18:41:14 +02:00
Kate Hsuan
131ab3a9d5 up-polkit: Replace with G_DEFINE_TYPE_WITH_PRIVATE
Since no interface was inplemented in UpPolkit class so G_DEFINE_TYPE_WITH_PRIVATE
macro is batter.
2024-09-12 08:11:50 +00:00
Kate Hsuan
7db90b28d8 up-polkit: remove global variable and remove g_object_add_weak_pointer()
Since UpPolkit is only created in the daemon, so the global variable and
g_object_add_weak_pointer() can be removed.
2024-09-12 08:11:50 +00:00
Rogerio Alves
88031e563f Support fractional battery percent.
Make upower supports fractional battery percent
(e.g., 0.5% instead of 1%).

Signed-off-by: Rogerio Alves Cardoso <rogerio.cardoso@collabora.com>
2024-09-12 15:55:00 +08:00
Kate Hsuan
fda3a0b563 ci: Test on Debian system
We run the test on the Debian system to ensure upower can run on
different Linux distributions.
2024-09-12 15:10:15 +08:00
Kate Hsuan
cca76c8684 rules: 60-upower-battery.hwdb: Change the threshold value to 75-80
The CHARGE_LIMIT is set to 75-80 to increase the start threshold value.

Resolves: #282
2024-09-02 14:48:10 +08:00
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