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.
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.
- 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)
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)
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
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>
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>
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>
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>
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
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>
- 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)
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>
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