From c28f1b3450b9db073a072255a247744b5afb20ed Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 11 Sep 2020 23:23:57 +0200 Subject: [PATCH] Only ask to start an USBMS session when plugged into a USB host on Kobo (#6645) * Only ask to start an USBMS session when plugged into a USB host on Kobo Also, fix a typo that broke plugout detection on cervantes * Bump base (necessary input/KoboUSBMS changes) https://github.com/koreader/koreader-base/pull/1183 --- base | 2 +- frontend/ui/uimanager.lua | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/base b/base index 8efd64995..7e52fff01 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 8efd649950d296fc79d8ce5ef50060ef815f6f5a +Subproject commit 7e52fff017742065ef5c99a251461622643dc7cb diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 7ff6ec7dc..77e6a9618 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -155,6 +155,20 @@ function UIManager:init() Device:getPowerDevice():toggleFrontlight() end self.event_handlers["Charging"] = function() + self:_beforeCharging() + -- NOTE: Plug/unplug events will wake the device up, which is why we put it back to sleep. + if Device.screen_saver_mode then + self:suspend() + end + end + self.event_handlers["NotCharging"] = function() + -- We need to put the device into suspension, other things need to be done before it. + self:_afterNotCharging() + if Device.screen_saver_mode then + self:suspend() + end + end + self.event_handlers["UsbPlugIn"] = function() self:_beforeCharging() -- NOTE: Plug/unplug events will wake the device up, which is why we put it back to sleep. if Device.screen_saver_mode then @@ -165,7 +179,7 @@ function UIManager:init() MassStorage:start() end end - self.event_handlers["NotCharging"] = function() + self.event_handlers["UsbPlugOut"] = function() -- We need to put the device into suspension, other things need to be done before it. self:_afterNotCharging() if Device.screen_saver_mode then @@ -322,7 +336,7 @@ function UIManager:init() MassStorage:start() end end - self.event_handlers["USbPlugOut"] = function() + self.event_handlers["UsbPlugOut"] = function() self:_afterNotCharging() if Device.screen_saver_mode then self:suspend()