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:
Qingping Hou
2016-09-19 01:16:41 -07:00
parent 4036e2c460
commit 71afe3606c
3 changed files with 10 additions and 18 deletions

2
base

Submodule base updated: 3e9b63f5ca...2287aa8e75

View File

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

View File

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