From 834ff9a1fb2b76223e756a14af0bbcc26f914b37 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 05:16:28 +0200 Subject: [PATCH] Don't fake the swipe to unlock if not needed. Re: #695 --- frontend/ui/device.lua | 23 +++++++++++++++++++++++ reader.lua | 18 ++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index ad449f002..10e36c949 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -11,6 +11,7 @@ local Device = { screen_saver_mode = false, charging_mode = false, survive_screen_saver = false, + is_special_offers = nil, touch_dev = nil, model = nil, firmware_rev = nil, @@ -265,4 +266,26 @@ function Device:getPowerDevice() return self.powerd end +function Device:isSpecialOffers() + if self.is_special_offers ~= nil then return self.is_special_offers end + -- K5 only + if self:isTouchDevice() and self:isKindle() then + -- Look at the current blanket modules to see if the SO screensavers are enabled... + local lipc = require("liblipclua") + local lipc_handle = nil + if lipc then + lipc_handle = lipc.init("com.github.koreader.device") + end + if lipc_handle then + local loaded_blanket_modules = lipc_handle:get_string_property("com.lab126.blanket", "load") + if string.find(loaded_blanket_modules, "ad_screensaver") then + self.is_special_offers = true + end + lipc_handle:close() + else + end + end + return self.is_special_offers +end + return Device diff --git a/reader.lua b/reader.lua index 64ae72c1e..035cf5e58 100755 --- a/reader.lua +++ b/reader.lua @@ -48,14 +48,16 @@ function exitReader() os.execute("echo 'send 139' > /proc/keypad;echo 'send 139' > /proc/keypad") end if Device:isTouchDevice() and Device.survive_screen_saver then - -- hack the swipe to unlock screen - local dev = Device:getTouchInputDev() - if dev then - local width, height = Screen:getWidth(), Screen:getHeight() - input.fakeTapInput(dev, - math.min(width, height)/2, - math.max(width, height)-30 - ) + -- If needed, hack the swipe to unlock screen + if Device:isSpecialOffers() then + local dev = Device:getTouchInputDev() + if dev then + local width, height = Screen:getWidth(), Screen:getHeight() + input.fakeTapInput(dev, + math.min(width, height)/2, + math.max(width, height)-30 + ) + end end end end