PowerD: Make sure we immediately display accurate battery capacity on

resume.

(MONOTONIC doesn't trick during suspend, so we could happily display the
pre-suspend capacity for a while).
This commit is contained in:
NiLuJe
2022-01-23 18:46:37 +01:00
committed by Frans de Jonge
parent 69718d6ee1
commit 2462c1c5c1
2 changed files with 9 additions and 0 deletions

View File

@@ -191,6 +191,11 @@ function BasePowerD:getAuxCapacity()
return self.aux_batt_capacity
end
function BasePowerD:invalidateCapacityCache()
self.last_capacity_pull_time = TimeVal:new{ sec = 0, usec = 0}
self.last_aux_capacity_pull_time = TimeVal:new{ sec = 0, usec = 0}
end
function BasePowerD:isAuxCharging()
return self:isAuxChargingHW()
end

View File

@@ -1792,6 +1792,10 @@ Executes all the operations of a resume (i.e., wakeup) request.
This function usually wakes up the device.
]]
function UIManager:resume()
-- MONOTONIC doesn't tick during suspend,
-- invalidate the last battery capacity pull time so that we get up to date data immediately.
Device:getPowerDevice():invalidateCapacityCache()
if Device:isCervantes() or Device:isKobo() or Device:isSDL() or Device:isRemarkable() or Device:isSonyPRSTUX() then
self.event_handlers["Resume"]()
elseif Device:isKindle() then