Commit bb8dec15 authored by Hisham's avatar Hisham
Browse files

Cap battery at 100%.

Apparently invalid results can be returned by buggy drivers in old laptops,
as reported by @thukydides. See #596.
parent 8af4d9f4
...@@ -310,6 +310,9 @@ void Battery_getData(double* level, ACPresence* isOnAC) { ...@@ -310,6 +310,9 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
*level = -1; *level = -1;
*isOnAC = AC_ERROR; *isOnAC = AC_ERROR;
} }
if (*level > 100.0) {
*level = 100.0;
}
Battery_cacheLevel = *level; Battery_cacheLevel = *level;
Battery_cacheIsOnAC = *isOnAC; Battery_cacheIsOnAC = *isOnAC;
Battery_cacheTime = now; Battery_cacheTime = now;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment