From c4a802c4864f5c5d555de51ce6f9c920a0e2d136 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 7 Aug 2022 14:11:03 -0400 Subject: [PATCH] kindle: allow stopping the framework on 5.X this reclaims a bunch of memory useful on low memory devices --- frontend/device/kindle/device.lua | 25 +++++++++++++++++++ platform/kindle/extensions/koreader/menu.json | 1 - platform/kindle/koreader.sh | 3 +-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/frontend/device/kindle/device.lua b/frontend/device/kindle/device.lua index b9269c864..f268a4aa8 100644 --- a/frontend/device/kindle/device.lua +++ b/frontend/device/kindle/device.lua @@ -121,6 +121,26 @@ local function hasSpecialOffers() end end +local function frameworkStopped() + if os.getenv("STOP_FRAMEWORK") == "yes" then + local haslipc, lipc = pcall(require, "liblipclua") + if not (haslipc and lipc) then + logger.warn("could not load liblibclua") + return + end + local lipc_handle = lipc.init("com.lab126.kaf") + if not lipc_handle then + logger.warn("could not get lipc handle") + return + end + local frameworkStarted = lipc_handle:register_int_property("frameworkStarted", "r") + frameworkStarted.value = 1 + lipc_handle:set_string_property("com.lab126.blanket", "unload", "splash") + lipc_handle:set_string_property("com.lab126.blanket", "unload", "screensaver") + return lipc_handle + end +end + local Kindle = Generic:new{ model = "Kindle", isKindle = yes, @@ -150,6 +170,7 @@ local Kindle = Generic:new{ canHWDither = no, -- The time the device went into suspend suspend_time = 0, + framework_lipc_handle = frameworkStopped() } function Kindle:initNetworkManager(NetworkMgr) @@ -997,6 +1018,10 @@ function KindleTouch:exit() self.screen:_MTK_ToggleFastMode(false) end + if self.framework_lipc_handle then + self.framework_lipc_handle:close() + end + Generic.exit(self) if self.isSpecialOffers then diff --git a/platform/kindle/extensions/koreader/menu.json b/platform/kindle/extensions/koreader/menu.json index 488c2aefc..d018a86a7 100644 --- a/platform/kindle/extensions/koreader/menu.json +++ b/platform/kindle/extensions/koreader/menu.json @@ -25,7 +25,6 @@ }, { "name": "Start KOReader (no framework)", - "if": "\"Kindle2\" -m \"KindleDX\" -m \"KindleDXG\" -m \"Kindle3\" -m \"Kindle4\" -m || || || ||", "priority": 4, "action": "/mnt/us/koreader/koreader.sh", "params": "--kual --framework_stop", diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index 9afe11753..ae2b01603 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -56,6 +56,7 @@ if [ "${INIT_TYPE}" = "upstart" ]; then fi # Keep track of what we do with pillow... +export STOP_FRAMEWORK="no" export AWESOME_STOPPED="no" export CVM_STOPPED="no" export VOLUMD_STOPPED="no" @@ -87,12 +88,10 @@ elif [ "${1}" = "--asap" ]; then # Start as soon as possible, without sleeping to workaround UI quirks shift 1 NO_SLEEP="yes" - STOP_FRAMEWORK="no" REEXEC_FLAGS="${REEXEC_FLAGS} --asap" # Don't sleep during eips calls either... export EIPS_NO_SLEEP="true" else - STOP_FRAMEWORK="no" NO_SLEEP="no" fi