From 1a2e4f5b55622c0fa3edd0061738c73899d1f9c3 Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Sat, 1 Apr 2017 08:14:06 -0700 Subject: [PATCH] Force Kobo to suspend (#2691) Without this change, the device resumed randomly. With this change, the device had not resumed randomly anymore. (Technically speaking, it still randomly resumed, but got suspended immediately.) --- frontend/ui/uimanager.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 889f09be6..18181a5f4 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -59,7 +59,20 @@ function UIManager:init() -- resume. self:_initAutoSuspend() self.event_handlers["Suspend"] = function() - self:_stopAutoSuspend() + if self._stopAutoSuspend then + -- TODO(Hzj-jie): Why _stopAutoSuspend could be nil in test cases. + --[[ + frontend/ui/uimanager.lua:62: attempt to call method _stopAutoSuspend (a nil value) + + stack traceback: + frontend/ui/uimanager.lua:62: in function Suspend + frontend/ui/uimanager.lua:119: in function __default__ + frontend/ui/uimanager.lua:662: in function handleInput + frontend/ui/uimanager.lua:707: in function run + spec/front/unit/readerui_spec.lua:32: in function + --]] + self:_stopAutoSuspend() + end self:broadcastEvent(Event:new("Suspend")) Device:onPowerEvent("Suspend") end @@ -116,7 +129,7 @@ function UIManager:init() -- Suspension in Kobo can be interrupted by screen updates. We -- ignore user touch input here so screen udpate won't be -- triggered in suspend mode - return + self.event_handlers["Suspend"]() else self:sendEvent(input_event) end