From ea3a5dabc9cee52ef7a1ea78969f35eb4ef56366 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 19:55:15 +0200 Subject: [PATCH 1/5] Wheee, more Kindle startup script tweaks... Unfortunately, it appears that we do eed to sleep some more when started from KUAL, because the framework schedules a refresh that risks popin up over us if we start too early/fast... :/. I tried to be tricky (by stopping awesome, and s cheduling a resume later) to avoid sleeping, but that didn't work :'(. We just end up with the scheduled refresh as soon as awesome resumes... --- kindle/koreader.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kindle/koreader.sh b/kindle/koreader.sh index efc34cbe8..8eb750311 100755 --- a/kindle/koreader.sh +++ b/kindle/koreader.sh @@ -34,8 +34,12 @@ logmsg() # Keep track of what we do with pillow... PILLOW_DISABLED="no" +# Keep track of if we were started through KUAL +FROM_KUAL="no" + # Detect if we were started by KUAL by checking our nice value... if [ "$(nice)" == "5" ] ; then + FROM_KUAL="yes" # Yield a bit to let stuff stop properly... logmsg "Hush now . . ." # NOTE: This may or may not be terribly useful... @@ -120,8 +124,14 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then # NOTE: One more great find from eureka (http://www.mobileread.com/forums/showpost.php?p=2454141&postcount=34) lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.hideMe();"}' PILLOW_DISABLED="yes" - # NOTE: Leave the framework time to refresh the screen, so we don't start before it has finished redrawing after collapsing pillow/the chrome bar + # NOTE: Leave the framework time to refresh the screen, so we don't start before it has finished redrawing after collapsing the title bar usleep 250000 + # NOTE: If we were started from KUAL, we risk getting a list item to popup right over us, so, wait some more... + # The culprit appears to be a I WindowManager:flashTimeoutExpired:window=Root 0 0 600x30 + if [ "${FROM_KUAL}" == "yes" ] ; then + logmsg "Playing possum to wait for the window manager . . ." + usleep 2500000 + fi fi fi From f1cc984cbf919abfe7d0300793fab8e5b5fde26f Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 20:10:38 +0200 Subject: [PATCH 2/5] Close lipc handles on exit. No idea if bad things happen if we don't, but at least this sounds more correct. (re #696) --- .../apps/reader/modules/readeractivityindicator.lua | 6 ++++++ frontend/ui/device/kindlepowerd.lua | 12 +++++++++--- reader.lua | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/frontend/apps/reader/modules/readeractivityindicator.lua b/frontend/apps/reader/modules/readeractivityindicator.lua index 2b4175224..035aacecc 100644 --- a/frontend/apps/reader/modules/readeractivityindicator.lua +++ b/frontend/apps/reader/modules/readeractivityindicator.lua @@ -45,4 +45,10 @@ function ReaderActivityIndicator:onStopActivityIndicator() return true end +function ReaderActivityIndicator:coda() + if self.lipc_handle then + self.lipc_handle:close() + end +end + return ReaderActivityIndicator diff --git a/frontend/ui/device/kindlepowerd.lua b/frontend/ui/device/kindlepowerd.lua index 9cfe8fa2d..18397f828 100644 --- a/frontend/ui/device/kindlepowerd.lua +++ b/frontend/ui/device/kindlepowerd.lua @@ -8,7 +8,7 @@ local KindlePowerD = BasePowerD:new{ kt_kpw_capacity = "/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity", kpw_charging = "/sys/devices/platform/aplite_charger.0/charging", kt_charging = "/sys/devices/platform/fsl-usb2-udc/charging", - + flIntensity = nil, battCapacity = nil, is_charging = nil, @@ -26,9 +26,9 @@ end function KindlePowerD:init(model) local lipc = require("liblipclua") if lipc then - self.lipc_handle = lipc.init("com.github.koreader") + self.lipc_handle = lipc.init("com.github.koreader.kindlepowerd") end - + if model == "KindleTouch" then self.batt_capacity_file = self.kt_kpw_capacity self.is_charging_file = self.kt_charging @@ -83,4 +83,10 @@ function KindlePowerD:isChargingHW() return self.is_charging == 1 end +function KindlePowerD:coda() + if self.lipc_handle then + self.lipc_handle:close() + end +end + return KindlePowerD diff --git a/reader.lua b/reader.lua index 035cf5e58..e973cf45a 100755 --- a/reader.lua +++ b/reader.lua @@ -30,6 +30,8 @@ local InfoMessage = require("ui/widget/infomessage") local UIManager = require("ui/uimanager") local Menu = require("ui/widget/menu") local Device = require("ui/device") +local KindlePowerD = require("ui/device/kindlepowerd") +local ReaderActivityIndicator = require("apps/reader/modules/readeractivityindicator") local Screen = require("ui/screen") local DEBUG = require("dbg") @@ -42,6 +44,10 @@ function exitReader() input.closeAll() + -- Close lipc handles + KindlePowerD:coda() + ReaderActivityIndicator:coda() + if not util.isEmulated() then if Device:isKindle3() or (Device:getModel() == "KindleDXG") then -- send double menu key press events to trigger screen refresh From 2243689c687362a59cc8dcd31115a5c9851f4866 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 4 Jul 2014 20:23:25 +0200 Subject: [PATCH 3/5] Update koreader-base... To check how badly the nightlies will implode... ;D --- koreader-base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koreader-base b/koreader-base index 25deec728..a6bdb7cd7 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit 25deec728a94d9546e38f494bc47b26808742008 +Subproject commit a6bdb7cd75fa58d5073b522aa4d8de7a3273c68b From 6e10b877adb05499a40d34e41e33550302d2c637 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 5 Jul 2014 15:04:14 +0200 Subject: [PATCH 4/5] We don't need those at startup, delay until needed. --- reader.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reader.lua b/reader.lua index e973cf45a..f0d48c46f 100755 --- a/reader.lua +++ b/reader.lua @@ -30,8 +30,6 @@ local InfoMessage = require("ui/widget/infomessage") local UIManager = require("ui/uimanager") local Menu = require("ui/widget/menu") local Device = require("ui/device") -local KindlePowerD = require("ui/device/kindlepowerd") -local ReaderActivityIndicator = require("apps/reader/modules/readeractivityindicator") local Screen = require("ui/screen") local DEBUG = require("dbg") @@ -40,6 +38,9 @@ local ReaderUI = require("apps/reader/readerui") local Profiler = nil function exitReader() + local KindlePowerD = require("ui/device/kindlepowerd") + local ReaderActivityIndicator = require("apps/reader/modules/readeractivityindicator") + G_reader_settings:close() input.closeAll() From db4a30ff07eb13f7d3ec2b387cb7b8385aa7940c Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 5 Jul 2014 15:05:03 +0200 Subject: [PATCH 5/5] Add an 'ASAP' variant to the KOReader KUAL menu. Does away with the added ~3s of sleep, in exchange of possible UI quirks at startup. --- kindle/extensions/koreader/menu.json | 12 +++++++ kindle/koreader.sh | 51 +++++++++++++++++----------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/kindle/extensions/koreader/menu.json b/kindle/extensions/koreader/menu.json index e747f5462..a0e7d23e0 100644 --- a/kindle/extensions/koreader/menu.json +++ b/kindle/extensions/koreader/menu.json @@ -26,6 +26,18 @@ "priority": 4, "action": "/mnt/us/koreader/koreader.sh", "params": "--framework_stop" + }, + { + "name": "Start the filemanager (ASAP)", + "priority": 5, + "action": "/mnt/us/koreader/koreader.sh", + "params": "--asap /mnt/us/documents" + }, + { + "name": "Open the last document (ASAP)", + "priority": 6, + "action": "/mnt/us/koreader/koreader.sh", + "params": "--asap" } ] } diff --git a/kindle/koreader.sh b/kindle/koreader.sh index 8eb750311..0ca4e06fb 100755 --- a/kindle/koreader.sh +++ b/kindle/koreader.sh @@ -37,25 +37,34 @@ PILLOW_DISABLED="no" # Keep track of if we were started through KUAL FROM_KUAL="no" -# Detect if we were started by KUAL by checking our nice value... -if [ "$(nice)" == "5" ] ; then - FROM_KUAL="yes" - # Yield a bit to let stuff stop properly... - logmsg "Hush now . . ." - # NOTE: This may or may not be terribly useful... - usleep 250000 - - # Kindlet threads spawn with a nice value of 5, we aim for the same -2 as the KF8 reader - logmsg "Be nice!" - renice -n -7 $$ -fi - # By default, don't stop the framework. if [ "$1" == "--framework_stop" ] ; then shift 1 STOP_FRAMEWORK="yes" + NO_SLEEP="no" +elif [ "$1" == "--asap" ] ; then + # Start as soon as possible, without sleeping to workaround UI quirks + shift 1 + NO_SLEEP="yes" + STOP_FRAMEWORK="no" else STOP_FRAMEWORK="no" + NO_SLEEP="no" +fi + +# Detect if we were started by KUAL by checking our nice value... +if [ "$(nice)" == "5" ] ; then + FROM_KUAL="yes" + if [ "${NO_SLEEP}" == "no" ] ; then + # Yield a bit to let stuff stop properly... + logmsg "Hush now . . ." + # NOTE: This may or may not be terribly useful... + usleep 250000 + fi + + # Kindlet threads spawn with a nice value of 5, we aim for the same -2 as the KF8 reader + logmsg "Be nice!" + renice -n -7 $$ fi # we're always starting from our working directory @@ -124,13 +133,15 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then # NOTE: One more great find from eureka (http://www.mobileread.com/forums/showpost.php?p=2454141&postcount=34) lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.hideMe();"}' PILLOW_DISABLED="yes" - # NOTE: Leave the framework time to refresh the screen, so we don't start before it has finished redrawing after collapsing the title bar - usleep 250000 - # NOTE: If we were started from KUAL, we risk getting a list item to popup right over us, so, wait some more... - # The culprit appears to be a I WindowManager:flashTimeoutExpired:window=Root 0 0 600x30 - if [ "${FROM_KUAL}" == "yes" ] ; then - logmsg "Playing possum to wait for the window manager . . ." - usleep 2500000 + if [ "${NO_SLEEP}" == "no" ] ; then + # NOTE: Leave the framework time to refresh the screen, so we don't start before it has finished redrawing after collapsing the title bar + usleep 250000 + # NOTE: If we were started from KUAL, we risk getting a list item to popup right over us, so, wait some more... + # The culprit appears to be a I WindowManager:flashTimeoutExpired:window=Root 0 0 600x30 + if [ "${FROM_KUAL}" == "yes" ] ; then + logmsg "Playing possum to wait for the window manager . . ." + usleep 2500000 + fi fi fi fi