From 0808560532eff82eb3495bd8b378d76802dec1fe Mon Sep 17 00:00:00 2001 From: zwim <36999612+zwim@users.noreply.github.com> Date: Mon, 11 Apr 2022 00:20:48 +0200 Subject: [PATCH] getElapsedTimeSinceBoot: Honor times in suspend, too (#8983) --- frontend/device/generic/powerd.lua | 6 ++++-- frontend/ui/uimanager.lua | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/device/generic/powerd.lua b/frontend/device/generic/powerd.lua index 2ea487a39..e765b9533 100644 --- a/frontend/device/generic/powerd.lua +++ b/frontend/device/generic/powerd.lua @@ -216,7 +216,8 @@ function BasePowerD:getCapacity() if UIManager then now_btv = UIManager:getElapsedTimeSinceBoot() else - now_btv = TimeVal:now() + self.device.total_standby_tv -- Add time the device was in standby + -- Add time the device was in standby and suspend + now_btv = TimeVal:now() + self.device.total_standby_tv + self.device.total_suspend_tv end if (now_btv - self.last_capacity_pull_time):tonumber() >= 60 then @@ -236,7 +237,8 @@ function BasePowerD:getAuxCapacity() if UIManager then now_btv = UIManager:getElapsedTimeSinceBoot() else - now_btv = TimeVal:now() + self.device.total_standby_tv -- Add time the device was in standby + -- Add time the device was in standby and suspend + now_btv = TimeVal:now() + self.device.total_standby_tv + self.device.total_suspend_tv end if (now_btv - self.last_aux_capacity_pull_time):tonumber() >= 60 then diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 8d1311049..03d6296db 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -1242,10 +1242,10 @@ function UIManager:getTime() end --[[-- -Returns a TimeVal object corresponding to the last UI tick plus the time in standby. +Returns a TimeVal object corresponding to the last UI tick plus the time in standby and suspend. ]] function UIManager:getElapsedTimeSinceBoot() - return self:getTime() + Device.total_standby_tv + return self:getTime() + Device.total_standby_tv + Device.total_suspend_tv end -- precedence of refresh modes: