AutoSuspend: Handle standby scheduling in the same manner as suspend/shutdown (#8985)

Specifically, don't forcibly unschedule/schedule on every input event, instead, let the scheduled task figure out if the deadline came to pass or not ;).

c.f., https://github.com/koreader/koreader/pull/8970#issuecomment-1092775830

Besides getting rid of some overhead, this allows proper scheduling after a task that would have blocked for longer than the standby timeout.
This commit is contained in:
NiLuJe
2022-04-12 23:08:48 +02:00
committed by GitHub
parent 2c25181644
commit 087b97457d
2 changed files with 102 additions and 73 deletions

View File

@@ -776,12 +776,13 @@ function Kobo:standby(max_duration)
local TimeVal = require("ui/timeval")
local standby_time_tv = TimeVal:boottime_or_realtime_coarse()
logger.info("Kobo suspend: asking to enter standby . . .")
local ret = writeToSys("standby", "/sys/power/state")
self.last_standby_tv = TimeVal:boottime_or_realtime_coarse() - standby_time_tv
self.total_standby_tv = self.total_standby_tv + self.last_standby_tv
logger.info("Kobo suspend: asked the kernel to put subsystems to standby, ret:", ret)
logger.info("Kobo suspend: zZz zZz zZz zZz? Write syscall returned: ", ret)
if max_duration then
self.wakeup_mgr:removeTask(nil, nil, dummy)