https://bugs.kde.org/show_bug.cgi?id=529006
Bug ID: 529006
Summary: Battery with "IsPresent=false" displayed as
"battery-missing" with error marking when it should be
absent
Classification: Plasma
Product: plasmashell
Version First 6.6.6
Reported In:
Platform: Kubuntu
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: Power and Battery widget
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Target Milestone: 1.0
DESCRIPTION
The battery list keeps a row for a battery that reports `IsPresent=false`. Any
device whose driver registers a power supply for a battery that may show up
later gets a permanent row, stamped with the *battery-missing* icon — which
reads as hardware failure, not as "nothing here". On this laptop it is the pen
battery of the built-in ELAN touchscreen, on a machine that has never had a
stylus paired to it.
STEPS TO REPRODUCE
Needs a machine with such a device, so there is no software-only reproducer.
To look for one — every power supply that reports itself as not present is a
candidate, and on most laptops there are none besides these:
```
$ grep . /sys/class/power_supply/*/present
/sys/class/power_supply/BAT0/present:1
/sys/class/power_supply/hid-0018:04F3:2F71.0002-battery/present:0
```
1. Boot such a machine. Here it is an HP Elite Dragonfly Chromebook with the
ELAN touchscreen/stylus over I2C (`ELAN2513:00 04F3:2F71`, driver
`hid-multitouch`): `drivers/hid/hid-input.c` gives every Elan device
`HID_BATTERY_QUIRK_DYNAMIC`, which registers the power supply with
`bat->present = false` and only flips it to true once the pen reports
anything. So the kernel's own answer to "is there a battery here?" is "no",
and UPower agrees (measurements below).
2. Open the battery applet in the system tray and look at the list of
batteries.
OBSERVED RESULT
A row `ELAN2513:00 04F3:2F71 Stylus` with the *battery-missing* icon and no
meaningful percentage. It is indistinguishable from "a battery is installed and
something is wrong with it", which is alarming enough that I went looking for
failing hardware.
EXPECTED RESULT
No row while UPower says the battery is not present. If a pen is paired and
starts reporting a battery, the row should appear then.
SOFTWARE/OS VERSIONS
Operating System: Kubuntu 26.04 LTS
KDE Plasma Version: 6.6.6
KDE Frameworks Version: 6.24.0
Qt Version: 6.10.2
Kernel Version: 7.0.0-43-generic (64-bit)
ADDITIONAL INFORMATION
## Measurements
The power supply, from udev — note `POWER_SUPPLY_PRESENT=0`:
```
$ udevadm info /sys/class/power_supply/hid-0018:04F3:2F71.0002-battery
P:
/devices/pci0000:00/0000:00:15.3/i2c_designware.3/i2c-3/i2c-ELAN2513:00/0018:04F3:2F71.0002/power_supply/hid-0018:04F3:2F71.0002-battery
U: power_supply
E: POWER_SUPPLY_NAME=hid-0018:04F3:2F71.0002-battery
E: POWER_SUPPLY_TYPE=Battery
E: POWER_SUPPLY_STATUS=Unknown
E: POWER_SUPPLY_PRESENT=0
E: POWER_SUPPLY_ONLINE=1
E: POWER_SUPPLY_CAPACITY=0
E: POWER_SUPPLY_SCOPE=Device
E: POWER_SUPPLY_MODEL_NAME=ELAN2513:00 04F3:2F71
E: SUBSYSTEM=power_supply
# parent HID device: DRIVER=hid-multitouch HID_ID=0018:000004F3:00002F71
# HID_PHYS=i2c-ELAN2513:00
```
UPower reports it honestly, including the right icon:
```
$ upower -i
/org/freedesktop/UPower/devices/battery_hid_0018o04F3o2F71x0002_battery
native-path: hid-0018:04F3:2F71.0002-battery
model: ELAN2513:00 04F3:2F71 Stylus
power supply: no
updated: Wed 31 Dec 1969 04:00:00 PM PST # UpdateTime = 0,
never updated
tablet
warning-level: none
percentage: 0%
icon-name: 'battery-missing-symbolic'
```
```
$ busctl --system get-property org.freedesktop.UPower \
/org/freedesktop/UPower/devices/battery_hid_0018o04F3o2F71x0002_battery \
org.freedesktop.UPower.Device
readonly s NativePath = 'hid-0018:04F3:2F71.0002-battery';
readonly s Model = 'ELAN2513:00 04F3:2F71 Stylus';
readonly t UpdateTime = 0;
readonly u Type = 10; # UP_DEVICE_KIND_TABLET
readonly b PowerSupply = false;
readonly d Percentage = 0.0;
readonly b IsPresent = false;
readonly u State = 0; # UP_DEVICE_STATE_UNKNOWN
readonly d Capacity = 0.0;
readonly s IconName = 'battery-missing-symbolic';
```
`Type=10` (`Tablet`) is itself a guess by UPower: `up-device-supply.c` refines
the kind of a `power_supply` device by looking for `ID_INPUT_*` properties on
sibling input nodes, and this HID device also creates `… Stylus` input nodes.
## Where it goes wrong
UPower and powerdevil's own daemon both handle this device correctly; only the
list keeps it.
* **UPower** — exports `IsPresent=false`, `PowerSupply=false`,
`IconName=battery-missing-symbolic`, and keeps it out of `DisplayDevice`
(not a power supply). Correct.
* **powerdevil daemon** — `daemon/controllers/batterycontroller.cpp:111`
skips it for the low-battery / remaining-time logic:
```cpp
if (!upowerDevice->isPowerSupply() || !upowerDevice->isPresent()) {
continue;
}
```
* **plasma-workspace `BatteryControlModel`** — this is the gap. In 6.6.6,
`components/batterycontrol/batterycontrol.cpp:255 deviceAdded()` inserts
*every* device that has a `Solid::Battery` interface, with no present-ness
check. On git master the gate is `isBattery(kind)`
(`components/batterycontrol/upowerbattery_p.cpp`), reached from
`BatteryControlModel::onBatteryLoadFinished()` — that switch lists
`UP_DEVICE_KIND_TABLET` among the kinds to show, and still never looks at
`IsPresent`. So this is not fixed on master.
* Present-ness does reach QML, but only under a misleading name —
`batterycontrol.cpp` maps it to the `PluggedIn` role (6.6.6 line 228, master
line 269):
```cpp
case PluggedIn:
return QVariant::fromValue(battery->isPresent());
```
* The applet then uses that value only to pick an icon.
powerdevil `applets/batterymonitor/BatteryItem.qml` (master line 76; in 6.6.6
it is `hasBattery: root.batteryPluggedIn`):
```qml
WorkspaceComponents.BatteryIcon {
hasBattery: root.batteryPluggedIn && root.batteryPercentKnown
```
and `plasma-workspace/components/workspace/BatteryIcon.qml:29`:
```qml
source: (root.hasBattery ? fillElement(root.percent) : "battery-missing") + …
```
Net effect: the model knows the battery is absent, the row stays, and the row
is stamped "battery missing" forever.
## Proposal
Filter by present-ness in the model rather than in the delegate:
* Treat `IsPresent=false` like a device that is not a battery: don't insert the
row, insert it when present-ness turns true, remove it when it turns false.
The plumbing is already there — `UPowerBattery` tracks `Change::Present`
(`overallBatteryChanges` includes it on master) and 6.6.6 already connects
`Solid::Battery::presentStateChanged`.
* Hiding the delegate instead (`visible: model.PluggedIn`) could work but
leaves invisible rows in the `ListView` count and in the tab/focus chain, and
perhaps needs a clearer role name.
Either way, a role named `PluggedIn` that returns `isPresent()` could create
confusion; a `Present` role (or a `Present` flag alongside `PluggedIn`) might
make the applet's intent clearer.
--
You are receiving this mail because:
You are watching all bug changes.