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.
pull/2245/head
Qingping Hou 8 years ago
parent 4036e2c460
commit 71afe3606c

@ -1 +1 @@
Subproject commit 3e9b63f5cafc12335e18ea8ed313aa01c004b745
Subproject commit 2287aa8e75b456d6e1a69d6cb16a5b372e24f248

@ -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

Loading…
Cancel
Save