From a19954a201a01b70b0648619891349db9cdd72bb Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 16:11:24 +0200 Subject: [PATCH 01/10] Restart Kindle framework from an unpolluted env --- platform/kindle/koreader.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index a9dd54b35..2c8c52990 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -241,9 +241,9 @@ fi if [ "${STOP_FRAMEWORK}" == "yes" ] ; then logmsg "Restarting framework . . ." if [ "${INIT_TYPE}" == "sysv" ] ; then - /etc/init.d/framework start + cd / && env -u LD_LIBRARY_PATH /etc/init.d/framework start else - start lab126_gui + cd / && env -u LD_LIBRARY_PATH start lab126_gui fi fi From 928404a6b6651628311d8177194c5edd184ad270 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 16:19:00 +0200 Subject: [PATCH 02/10] Fix K4 key mappings --- frontend/device/kindle/event_map_kindle4.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/device/kindle/event_map_kindle4.lua b/frontend/device/kindle/event_map_kindle4.lua index 8520213e0..d4562ac80 100644 --- a/frontend/device/kindle/event_map_kindle4.lua +++ b/frontend/device/kindle/event_map_kindle4.lua @@ -7,7 +7,11 @@ return { [102] = "Home", [103] = "Up", [104] = "LPgFwd", + [105] = "Left", + [106] = "Right", [108] = "Down", + [109] = "RPgBack", + [139] = "Menu", [158] = "Back", [191] = "RPgFwd", [193] = "LPgBack", From df4bbc81916a67ac23ffd379d559481a623522b6 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 16:21:02 +0200 Subject: [PATCH 03/10] Only read Kindle S/N once --- frontend/device/kindle/device.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/device/kindle/device.lua b/frontend/device/kindle/device.lua index dc4a3fe5b..d0f4a33b9 100644 --- a/frontend/device/kindle/device.lua +++ b/frontend/device/kindle/device.lua @@ -289,12 +289,12 @@ local function Set(list) end -local kindle_sn = io.open("/proc/usid", "r") -if not kindle_sn then return end -local kindle_devcode = string.sub(kindle_sn:read(),3,4) -kindle_sn:seek("set") -local kindle_devcode_v2 = string.sub(kindle_sn:read(),4,6) -kindle_sn:close() +local kindle_sn_fd = io.open("/proc/usid", "r") +if not kindle_sn_fd then return end +local kindle_sn = kindle_sn_fd:read() +kindle_sn_fd:close() +local kindle_devcode = string.sub(kindle_sn,3,4) +local kindle_devcode_v2 = string.sub(kindle_sn,4,6) -- NOTE: Update me when new devices come out :) local k2_set = Set { "02", "03" } From f85c10e3b9f29f8368b8f17ab69ce67f8b165039 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 16:23:46 +0200 Subject: [PATCH 04/10] Minor tweak to exit behavior on legacy devices. Properly refresh the screen when exiting with the framework running. The lua code to handle that is called while cvm is SIGSTOPP'ed, so it doesn't help. --- platform/kindle/koreader.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index 2c8c52990..3060ad6bf 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -235,6 +235,9 @@ fi if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "sysv" ] ; then logmsg "Resuming cvm . . ." killall -cont cvm + # We need to handle the screen refresh ourselves, frontend/device/kindle/device.lua's Kindle3.exit is called before we resume cvm ;). + echo 'send 139' > /proc/keypad + echo 'send 139' > /proc/keypad fi # Restart framework (if need be) From ffd3f5c1cc2686c6205dbbebc163bfc99c27fc36 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 16:32:00 +0200 Subject: [PATCH 05/10] Fix input devices on K4 --- frontend/device/kindle/device.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/device/kindle/device.lua b/frontend/device/kindle/device.lua index d0f4a33b9..d39aecdb0 100644 --- a/frontend/device/kindle/device.lua +++ b/frontend/device/kindle/device.lua @@ -115,6 +115,7 @@ function Kindle4:init() device = self, event_map = require("device/kindle/event_map_kindle4"), } + self.input.open("/dev/input/event0") self.input.open("/dev/input/event1") Kindle.init(self) end From dc7b854196e49eba4fd2a93a47e22da13a04bacf Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 16:47:15 +0200 Subject: [PATCH 06/10] Fix input devices on K2 --- frontend/device/kindle/device.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/device/kindle/device.lua b/frontend/device/kindle/device.lua index d39aecdb0..215126f45 100644 --- a/frontend/device/kindle/device.lua +++ b/frontend/device/kindle/device.lua @@ -83,6 +83,7 @@ function Kindle2:init() device = self, event_map = require("device/kindle/event_map_keyboard"), } + self.input.open("/dev/input/event0") self.input.open("/dev/input/event1") Kindle.init(self) end From 2058209aa832a660f8ffa5a9284e1fb5b4084644 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 16:53:24 +0200 Subject: [PATCH 07/10] More Kindle startup tweaks on legacy devices Don't try to setup iptables if it's not there (K2/DX/DXG). Note that we'll do it on the K3, but it'll be useless there (no wifi). --- platform/kindle/koreader.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index 3060ad6bf..be0d5c24e 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -121,12 +121,15 @@ export STARDICT_DATA_DIR="data/dict" # export external font directory export EXT_FONT_DIR="/mnt/us/fonts" -logmsg "Setting up IPTables rules . . ." -# accept input ports for zsync plugin -iptables -A INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT -iptables -A INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT -# accept input ports for calibre companion -iptables -A INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT +# Don't try to setup iptables on devices where it doesn't make sense to... +if [ -e "/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter/ip_tables.ko" ] ; then + logmsg "Setting up IPTables rules . . ." + # accept input ports for zsync plugin + iptables -A INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT + iptables -A INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT + # accept input ports for calibre companion + iptables -A INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT +fi # bind-mount system fonts if ! grep ${KOREADER_DIR}/fonts/host /proc/mounts > /dev/null 2>&1 ; then @@ -263,9 +266,11 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then fi fi -logmsg "Restoring IPTables rules . . ." -# restore firewall rules -iptables -D INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT -iptables -D INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT -iptables -D INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT +if [ -e "/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter/ip_tables.ko" ] ; then + logmsg "Restoring IPTables rules . . ." + # restore firewall rules + iptables -D INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT + iptables -D INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT + iptables -D INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT +fi From d6ab3b52247480bb402d7d1e03af87483928f643 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 17:00:31 +0200 Subject: [PATCH 08/10] Fix previous commit So it actually works as intended ;p. --- platform/kindle/koreader.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index be0d5c24e..79576fd3c 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -121,8 +121,8 @@ export STARDICT_DATA_DIR="data/dict" # export external font directory export EXT_FONT_DIR="/mnt/us/fonts" -# Don't try to setup iptables on devices where it doesn't make sense to... -if [ -e "/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter/ip_tables.ko" ] ; then +# Only setup IPTables on evices where it makes sense to (FW 5.x & K4) +if [ "${INIT_TYPE}" == "upstart" -o "$(uname -r)" == "2.6.31-rt11-lab126" ] ; then logmsg "Setting up IPTables rules . . ." # accept input ports for zsync plugin iptables -A INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT @@ -266,7 +266,7 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then fi fi -if [ -e "/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter/ip_tables.ko" ] ; then +if [ "${INIT_TYPE}" == "upstart" -o "$(uname -r)" == "2.6.31-rt11-lab126" ] ; then logmsg "Restoring IPTables rules . . ." # restore firewall rules iptables -D INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT From 6309df9dec17d143085c1f985b05c61cb23b5709 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 17:23:48 +0200 Subject: [PATCH 09/10] Guard against nil text in menu widget Allow one to go further in the FM's setting menu on legacy devices... ... and potentially shoot oneself in the foot because of the unusable confirmdialogs (among other things ;p). --- frontend/ui/widget/menu.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/ui/widget/menu.lua b/frontend/ui/widget/menu.lua index 4aa477803..182683321 100644 --- a/frontend/ui/widget/menu.lua +++ b/frontend/ui/widget/menu.lua @@ -166,8 +166,9 @@ function MenuItem:init() ""..mandatory, true, self.bold).x local state_button_width = self.state_size.w or 0 + local my_text = self.text and ""..self.text or "" w = RenderText:sizeUtf8Text(0, self.dimen.w, self.face, - self.text, true, self.bold).x + ""..my_text, true, self.bold).x if w + mandatory_w + state_button_width >= self.content_width then if Device:hasKeyboard() then self.active_key_events.ShowItemDetail = { @@ -177,7 +178,7 @@ function MenuItem:init() local indicator = " >> " local indicator_w = RenderText:sizeUtf8Text(0, self.dimen.w, self.face, indicator, true, self.bold).x - self.text = RenderText:getSubTextByWidth(self.text, self.face, + self.text = RenderText:getSubTextByWidth(my_text, self.face, self.content_width - indicator_w - mandatory_w - state_button_width, true, self.bold) .. indicator end From d26878eb8426a4fda64e913148d9f1d3f34a2881 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 17:44:20 +0200 Subject: [PATCH 10/10] Update base --- base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base b/base index 442641fa7..5749fbcca 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 442641fa75d35c5e5113a1b989fd9a03e04688b7 +Subproject commit 5749fbccabddae688cd737ed1b30b6498308fa2b