From 07a76b3dec662f32f883a119a339333c523f7eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Bi=C8=99oc?= Date: Mon, 12 Aug 2024 14:08:12 +0200 Subject: [PATCH] [STOBJECT] Do not report the remaining battery capacity if it is unknown Support for system batteries in ReactOS is really minimal to the point of non-existing. We are detecting the presence of any upcoming battery but since there's lacking in critical code that deals with communication between PO and the battery class driver as the battery systray icon uses GetSystemPowerStatus to gather battery info which in turn inquires the power manager via NtPowerInformation(SystemBatteryState), we have to report to the user that the remaining capacity is unknown rather than returning a pseudo capacity value. Technically this so called "pesudo" value is just a construct denoted as BATTERY_PERCENTAGE_UNKNOWN. Not reporting the actual remaining capacity makes sense, as there could be a scenario where the battery may not properly report its real datum, therefore it's best to be honest to the user what's really going on. CORE-19452 CORE-18969 --- dll/shellext/stobject/power.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dll/shellext/stobject/power.cpp b/dll/shellext/stobject/power.cpp index 9d80665dc87..ecae456b66e 100644 --- a/dll/shellext/stobject/power.cpp +++ b/dll/shellext/stobject/power.cpp @@ -90,6 +90,12 @@ static HICON DynamicLoadIcon(HINSTANCE hinst) } if (((PowerStatus.BatteryFlag & BATTERY_FLAG_NO_BATTERY) == 0) && + (PowerStatus.BatteryLifePercent == BATTERY_PERCENTAGE_UNKNOWN)) + { + hBatIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_BATTCAP_ERR)); + g_strTooltip.LoadStringW(IDS_PWR_UNKNOWN_REMAINING); + } + else if (((PowerStatus.BatteryFlag & BATTERY_FLAG_NO_BATTERY) == 0) && ((PowerStatus.BatteryFlag & BATTERY_FLAG_CHARGING) == BATTERY_FLAG_CHARGING)) { index = Quantize(PowerStatus.BatteryLifePercent);