Commit graph

1787 commits

Author SHA1 Message Date
Kate Hsuan
30449acecc linux: integration-test: determining a low power charger based on battery percenatge change
If the line power is attached and the battery percentage drops 3% within
300 seconds, upower determines the attached line power is a low-power
charger.
2025-04-07 15:11:34 +08:00
Kate Hsuan
c0750c5dd9 up-daemon: determining a low-efficiency charger through monitoring the battery percentage
Some of the battery controller discharges the battery when the percentage
reaches the charge_control_end_threshold. It discharges the battery to a certain
percentage and then starts to charge the battery to the end threshold. Therefore,
the charging status is frequently changed.

If the battery percentage drops 3% in a period (300 secs), upower sets the
on_battery to yes to reflect the real battery charging status and upower
assumes a low-efficiency charger is attached. If not, the counter will be
reset.
2025-04-07 15:08:11 +08:00
Kate Hsuan
707af75194 Release 1.90.8
- Fix the incorrect percentage value of a removed battery. (#292) (!246)
- Fix device type for the gaming device. (#296 #295) (!247)
- Determine the battery discharging status when connecting a low-power
  charger. (#276) (!244)
- Fix memory leak when refreshing battery info. (#305) (!261)
- Fix memory leak when getting device id. (!261)
2025-03-31 14:58:25 +08:00
Kate Hsuan
51550b912f up-device: Fix mem leak when get device id
The up_device_get_id() returns a string, and the caller has to free it.
A comment is also left in the code to inform the behavior.

...
<snip>
...
=229301== 1,280 bytes in 10 blocks are definitely lost in loss record 1,837 of 1,852
==229301==    at 0x4849347: realloc (vg_replace_malloc.c:1801)
==229301==    by 0x48E7D6A: g_realloc (gmem.c:171)
==229301==    by 0x4907239: g_string_expand (gstring.c:82)
==229301==    by 0x49072B0: g_string_sized_new (gstring.c:113)
==229301==    by 0x10E287: up_device_get_id (up-device.c:347)
==229301==    by 0x10ED55: up_device_notify (up-device.c:241)
==229301==    by 0x49F67D9: g_closure_invoke (gclosure.c:833)
==229301==    by 0x4A26A1F: signal_emit_unlocked_R.isra.0 (gsignal.c:3720)
==229301==    by 0x4A173E8: signal_emit_valist_unlocked (gsignal.c:3519)
==229301==    by 0x4A17670: g_signal_emit_valist (gsignal.c:3262)
==229301==    by 0x4A17732: g_signal_emit (gsignal.c:3582)
==229301==    by 0x4A02973: g_object_dispatch_properties_changed.lto_priv.0 (gobject.c:1819)
2025-03-28 16:00:59 +08:00
Kate Hsuan
2ebaa01347 linux: up-device-supply-battery: Fix mem leak when refreshing battery info
The AC was plugged and unplugged repeatedly, and hit this leak in
up_device_supply_battery_refresh(). Four variables in UpBatteryInfo
need to be free.

...
<snip>
...
==2825085== 1,152 bytes in 9 blocks are definitely lost in loss record 1,851 of 1,865
==2825085==    at 0x484CE40: realloc (vg_replace_malloc.c:1801)
==2825085==    by 0x4916ADA: g_realloc (gmem.c:171)
==2825085==    by 0x4939E06: g_string_expand (gstring.c:82)
==2825085==    by 0x4939EA1: g_string_sized_new (gstring.c:113)
==2825085==    by 0x11262C: up_device_get_id (up-device.c:347)
==2825085==    by 0x113136: up_device_notify (up-device.c:241)
==2825085==    by 0x4A1B811: g_closure_invoke (gclosure.c:833)
==2825085==    by 0x4A4C0C1: signal_emit_unlocked_R.isra.0 (gsignal.c:3735)
==2825085==    by 0x4A3CCE8: signal_emit_valist_unlocked (gsignal.c:3534)
==2825085==    by 0x4A3CF71: g_signal_emit_valist (gsignal.c:3277)
==2825085==    by 0x4A3D033: g_signal_emit (gsignal.c:3597)
==2825085==    by 0x4A27C75: g_object_dispatch_properties_changed.lto_priv.0 (gobject.c:1827)
==2825085==
==2825085== LEAK SUMMARY:
==2825085==    definitely lost: 3,663 bytes in 333 blocks
==2825085==    indirectly lost: 0 bytes in 0 blocks
==2825085==      possibly lost: 960 bytes in 3 blocks
==2825085==    still reachable: 172,351 bytes in 2,205 blocks
==2825085==         suppressed: 0 bytes in 0 blocks
==2825085== Reachable blocks (those to which a pointer was found) are not shown.
==2825085== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==2825085==
==2825085== For lists of detected and suppressed errors, rerun with: -s
==2825085== ERROR SUMMARY: 20 errors from 20 contexts (suppressed: 0 from 0)

Resolves: #305
2025-03-28 16:00:26 +08:00
Kate Hsuan
df51aef98a rules: 95-upower-hid.hwdb: update hwdb for HID devices
Update HID hwdb.
2025-03-25 17:08:40 +08:00
Kate Hsuan
71e473902f linux: integration-test: Handle connecting the low-power charger
Add a scenario for connecting a low-power charger.
1. The AC is online.
2. The battery is discharging.
3. The percentage drops to 2.5%.
4. The warning level will become UP_DEVICE_LEVEL_CRITICAL.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2025-02-24 06:13:47 +00:00
Kate Hsuan
d7ff457784 linux: up-device-supply-battery: reset the status to discharging when current_now is negative
For some USB battery solutions, the kernel reports charging when
connecting a charger but in reality, the battery discharges and
current_now is negative. This work reset the battery status to
"Discharging" when current_now is negative and line power is
online.

Resolves: #276

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2025-02-24 06:13:47 +00:00
Kate Hsuan
9d754d8b2f up-daemon: Handle the AC is online but the battery is discharging
If a low-power charger connects to the system, the battery still reports
discharging since the AC charger can't provide enough power to make      
the system runs and charges the battery at the same time. In this situation,
we estimate the warning level to trigger the CriticalPowerAction until
the battery status is changed to charging.

Resolves: #276

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2025-02-24 06:13:47 +00:00
Jelle van der Waa
6f9d84694d linux: rules: fix warnings from udevadm verify
rules/60-upower-battery.rules:5 style: whitespace after comma is expected.
rules/60-upower-battery.rules:5 style: a comma between tokens is expected.
2025-02-22 15:20:12 +01:00
Kate Hsuan
4f1ef04475 linux: integration-test: a test case for Dualshock4 with a headphone jack 2025-02-08 07:58:03 +00:00
Kate Hsuan
f17d3bfcd0 linux: up-device-supply: Update the model name after changing the device type
The model name of a device component may be different. For example,
Dualshock joystick owns "Sony Interactive Entertainment DualSense
Wireless Controller" for the joystick and "Sony Interactive
Entertainment DualSense Wireless Controller Motion Sensors" for the
accelerometer. If the device type is changed based on the device
priority, the corresponding model name have to be changed.

Resolves: #295

Tested-by: Mateus Rodrigues Costa <mateusrodcosta@gmail.com>
Signed-off-by: Kate Hsuan <hpa@redhat.com>
2025-02-08 07:58:03 +00:00
Mateus Rodrigues Costa
351affe12f linux: device_supply: Prioritize Gaming Input
The DualSense and DualShock 4 have 3 main components: the gamepad proper,
a touchpad and motion sensors. They also have an extra component in the
form of a headphone jack, which is only available via BT on the
PlayStation consoles but can be used on other devices via USB.

Commit 00eb31a63c increased the priority of
Gaming Input so the controllers weren't accidentally identified as only
the Touchpad, which works on BT. This commit prioritizes Gaming Input over
Audio Device, fixing an issue that only happens on USB.

Resolves: #296
2025-02-08 07:58:03 +00:00
Sicelo A. Mhlongo
a16c752e85 dbus: UPower.xml: Update GetCriticalAction Values
UPower now supports Suspend and Ignore as possible actions. Update the
documentation accordingly.
2025-02-06 10:46:33 +02:00
Kate Hsuan
478c51e4ea linux: integration-test: test case for the removable battery 2025-01-24 17:39:54 +08:00
Kate Hsuan
3452140a6c src: up-device-battery: Reset values when the battery is not present
If the battery is not present, reset the attribute values.

Resolves: #292
2025-01-24 17:39:37 +08:00
Kate Hsuan
6bd8cd90b3 src: up-daemon: skip the battery if present = 0
If the battery is not present, skip it when estimating the battery
percentage.

Resolves: #292
2025-01-24 17:39:03 +08:00
NorwayFun
eb5a327127 Update LINGUAS 2025-01-17 02:11:22 +00:00
Kate Hsuan
319650c145 pre-commit-config: Remove deprecated default_stages "commit"
The new stage name "pre-commit" was used to update the pre-commit
configuration.
2025-01-13 08:55:18 +00:00
Kate Hsuan
003c251fdc contrib: setup: Install and setup pre-commit 2025-01-13 08:55:18 +00:00
fossdd
3731b03553 Fix test race in test_bluetooth_hidpp_mouse
We ship the proposed patch already since Oct 2024 in Alpine Linux and is
working for us correctly and fixes the test.

Closes https://gitlab.freedesktop.org/upower/upower/-/issues/228

Co-Authored-By: Bastien Nocera <hadess@hadess.net>
2025-01-13 06:28:36 +00:00
Marcus B Spencer
83eecbab65 etc/UPower.conf: fix "riscky" typo
Fix the typo on line 86 where it says "riscky", when it should say
"risky"
2025-01-13 13:30:11 +08:00
Kate Hsuan
08bfb29f37 Bump the version for the next release 2025-01-09 13:55:45 +08:00
Kate Hsuan
70a5026662 Release 1.90.7
- Find the correct parent id for input devices (#268 #286)
- Fix race condition in test_sibling_priority_no_overwrite (!240)
- Show charge-threshold-* status as yes/no (!242)
- Add zsh-completions for CLI (!241)
- Wait 10 seconds for stopping the daemon (#290)
- Added pre-commit test and fixed code spelling, markdown, and code style issues. (!248)
2025-01-09 13:47:51 +08:00
Kate Hsuan
0f9bdf1d1c Ignore commits for tree wide changes 2025-01-08 16:54:58 +08:00
Kate Hsuan
7d64c232dc HACKING.md: Rename HACKING to HACKING.md and fix markdown with markdownlint 2025-01-08 15:08:04 +08:00
Kate Hsuan
99de6c9744 README: Rename to README.md and fix markdown with markdownlint 2025-01-08 14:25:55 +08:00
Kate Hsuan
d11300fac6 ci: Add a pre-commit stage 2025-01-08 14:01:34 +08:00
Kate Hsuan
bab81e5e44 Fix spelling issues with codespell 2025-01-08 14:01:34 +08:00
Kate Hsuan
17e5903670 Reformat python code style with black 2025-01-08 14:01:34 +08:00
Kate Hsuan
2678cb00d4 Fix trailing white space and end of file 2025-01-08 14:01:34 +08:00
Kate Hsuan
52bfd8d924 ci: Add python code style check to the pre-commit test 2025-01-08 14:01:29 +08:00
Kate Hsuan
2b371cc290 Update README.md and HACK to match markdown.lint style 2025-01-08 13:59:50 +08:00
Kate Hsuan
9c3b678d7f ci: markdownlint: Add markdownlint to the pre-commit check 2025-01-08 13:59:50 +08:00
Kate Hsuan
2cfc6f625f ci: Add codespell test to the pre-commit test 2025-01-08 13:59:50 +08:00
Kate Hsuan
9fac8f2ae2 pre-commit-config: Add pre-commit test 2025-01-08 13:59:43 +08:00
Kate Hsuan
1a64550dad rules: 95-upower-hid.hwdb: Update hwdb for HID devices 2024-12-31 13:39:50 +08:00
Kate Hsuan
a038b237fb linux: integration-test: wait 10 seconds for stopping the daemon
Some slow systems take more than 5 seconds to stop the daemon.  The
waiting time was extended to 10 seconds to ensure the daemon
shutdowns properly.

Resolves: #290

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-12-06 06:30:03 +00:00
Natalie Clarius
422ac4be74 add completions for CLI 2024-10-26 19:56:28 +00:00
Jelle van der Waa
faa6d8a6b3 dbus: show charge-threshold-* status as yes/no
Previously shown as a boolean integer and not properly aligned.
2024-10-11 16:40:13 +02:00
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