mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
kobo(fix): set suspend wait timeout to 15 seconds
Otherwise, suspend might fail and the device will ended up in a false sleep state and drain the battery.
This commit is contained in:
2
base
2
base
Submodule base updated: 3e9b63f5ca...2287aa8e75
@@ -14,6 +14,9 @@ local Device = {
|
||||
powerd = nil,
|
||||
screen = nil,
|
||||
input = nil,
|
||||
-- For Kobo, wait at least 15 seconds before calling suspend script. Otherwise, suspend might
|
||||
-- fail and the battery will be drained while we are in screensaver mode
|
||||
suspend_wait_timeout = 15,
|
||||
|
||||
-- hardware feature tests: (these are functions!)
|
||||
hasKeyboard = no,
|
||||
@@ -114,11 +117,10 @@ function Device:outofScreenSaver()
|
||||
self.screen_saver_mode = false
|
||||
end
|
||||
|
||||
function Device:scheduleSuspendIfNeeded()
|
||||
function Device:rescheduleSuspend()
|
||||
local UIManager = require("ui/uimanager")
|
||||
if not UIManager:hasScheduled(self.suspend) then
|
||||
UIManager:nextTick(self.suspend)
|
||||
end
|
||||
UIManager:unschedule(self.suspend)
|
||||
UIManager:scheduleIn(self.suspend_wait_timeout, self.suspend)
|
||||
end
|
||||
|
||||
-- ONLY used for Kobo and PocketBook devices
|
||||
@@ -127,7 +129,7 @@ function Device:onPowerEvent(ev)
|
||||
if ev == "Power" or ev == "Resume" then
|
||||
if self.is_cover_closed then
|
||||
-- don't let power key press wake up device when the cover is in closed state
|
||||
self:scheduleSuspendIfNeeded()
|
||||
self:rescheduleSuspend()
|
||||
else
|
||||
DEBUG("Resuming...")
|
||||
require("ui/uimanager"):unschedule(self.suspend)
|
||||
@@ -151,7 +153,7 @@ function Device:onPowerEvent(ev)
|
||||
-- suspending the hardware. This usually happens when sleep cover
|
||||
-- is closed after the device was sent to suspend state.
|
||||
DEBUG("Already in screen saver mode, suspending...")
|
||||
self:scheduleSuspendIfNeeded()
|
||||
self:rescheduleSuspend()
|
||||
end
|
||||
-- else we we not in screensaver mode
|
||||
elseif ev == "Power" or ev == "Suspend" then
|
||||
@@ -172,7 +174,7 @@ function Device:onPowerEvent(ev)
|
||||
require("ui/screensaver"):show()
|
||||
self.screen:refreshFull()
|
||||
self.screen_saver_mode = true
|
||||
UIManager:scheduleIn(10, self.suspend)
|
||||
UIManager:scheduleIn(self.suspend_wait_timeout, self.suspend)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -278,16 +278,6 @@ end
|
||||
dbg:guard(UIManager, 'unschedule',
|
||||
function(self, action) assert(action ~= nil) end)
|
||||
|
||||
-- Check to see if a task is already scheduled
|
||||
function UIManager:hasScheduled(action)
|
||||
for i = #self._task_queue, 1, -1 do
|
||||
if self._task_queue[i].action == action then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--[[
|
||||
register a widget to be repainted and enqueue a refresh
|
||||
|
||||
|
||||
Reference in New Issue
Block a user