2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00

Merge pull request #696 from NiLuJe/master

Bundle o' Kindle tweaks!
This commit is contained in:
Qingping Hou 2014-07-04 01:45:31 -04:00
commit b7f6b35828
5 changed files with 130 additions and 43 deletions

View File

@ -101,10 +101,14 @@ kindleupdate: all
ln -sf ../kindle/launchpad $(INSTALL_DIR)/
ln -sf ../../kindle/koreader.sh $(INSTALL_DIR)/koreader
# create new package
# Don't bundle launchpad on touch devices..
ifeq ($(TARGET), kindle-legacy)
KINDLE_LEGACY_LAUNCHER:=launchpad
endif
cd $(INSTALL_DIR) && \
zip -9 -r \
../koreader-kindle-$(MACHINE)-$(VERSION).zip \
extensions koreader launchpad \
extensions koreader $(KINDLE_LEGACY_LAUNCHER) \
-x "koreader/resources/fonts/*" \
"koreader/resources/icons/src/*" "koreader/spec/*"
# @TODO write an installation script for KUAL (houqp)

View File

@ -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,
@ -40,7 +41,7 @@ function Device:getModel()
if kindle_sn then
local kindle_devcode = string.sub(kindle_sn:read(),3,4)
kindle_sn:close()
-- NOTE: Update me when new models come out :)
-- NOTE: Update me when new devices come out :)
local k2_set = Set { "02", "03" }
local dx_set = Set { "04", "05" }
local dxg_set = Set { "09" }
@ -48,7 +49,7 @@ function Device:getModel()
local k4_set = Set { "0E", "23" }
local touch_set = Set { "0F", "11", "10", "12" }
local pw_set = Set { "24", "1B", "1D", "1F", "1C", "20" }
local pw2_set = Set { "D4", "5A", "D5", "D7", "D8", "F2" }
local pw2_set = Set { "D4", "5A", "D5", "D6", "D7", "D8", "F2" }
if k2_set[kindle_devcode] then
self.model = "Kindle2"
@ -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

View File

@ -1,30 +1,30 @@
{
"items": [
{
"name": "Koreader",
"name": "KOReader",
"priority": 0,
"items": [
{
"name": "Start the filemanager",
"priority": 1,
"action": "nice -n -7 /mnt/us/koreader/koreader.sh",
"action": "/mnt/us/koreader/koreader.sh",
"params": "/mnt/us/documents"
},
{
"name": "Open the last document",
"priority": 2,
"action": "nice -n -7 /mnt/us/koreader/koreader.sh"
"action": "/mnt/us/koreader/koreader.sh"
},
{
"name": "Start the filemanager (no framework)",
"priority": 3,
"action": "nice -n -7 /mnt/us/koreader/koreader.sh",
"action": "/mnt/us/koreader/koreader.sh",
"params": "--framework_stop /mnt/us/documents"
},
{
"name": "Open the last document (no framework)",
"priority": 4,
"action": "nice -n -7 /mnt/us/koreader/koreader.sh",
"action": "/mnt/us/koreader/koreader.sh",
"params": "--framework_stop"
}
]

View File

@ -6,24 +6,54 @@ PROC_FIVEWAY="/proc/fiveway"
[ -e $PROC_KEYPAD ] && echo unlock > $PROC_KEYPAD
[ -e $PROC_FIVEWAY ] && echo unlock > $PROC_FIVEWAY
# Check which type of init system we're running on
if [ -d /etc/upstart ] ; then
INIT_TYPE="upstart"
# We'll need that for logging
[ -f /etc/upstart/functions ] && source /etc/upstart/functions
else
INIT_TYPE="sysv"
# We'll need that for logging
[ -f /etc/rc.d/functions ] && source /etc/rc.d/functions
fi
# Handle logging...
logmsg()
{
# Use the right tools for the platform
if [ "${INIT_TYPE}" == "sysv" ] ; then
msg "koreader: ${1}" "I"
elif [ "${INIT_TYPE}" == "upstart" ] ; then
f_log I koreader wrapper "" "${1}"
fi
# And throw that on stdout too, for the DIY crowd ;)
echo "${1}"
}
# Keep track of what we do with pillow...
PILLOW_DISABLED="no"
# Detect if we were started by KUAL by checking our nice value...
if [ "$(nice)" == "5" ] ; then
# Yield a bit to let stuff stop properly...
logmsg "Hush now . . ."
# NOTE: This may or may not be terribly useful...
sleep 1
# 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"
# Yield a bit to let stuff stop properly...
echo "Stopping framework . . ."
sleep 2
else
STOP_FRAMEWORK="no"
fi
# Check which type of init system we're using
if [ -d /etc/upstart ] ; then
INIT_TYPE="upstart"
else
INIT_TYPE="sysv"
fi
# we're always starting from our working directory
cd /mnt/us/koreader
@ -34,18 +64,21 @@ export TESSDATA_PREFIX="data"
export STARDICT_DATA_DIR="data/dict"
# accept input ports for zsync plugin
logmsg "Setting up IPTables rules . . ."
iptables -A INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT
iptables -A INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT
# bind-mount system fonts
if ! grep /mnt/us/koreader/fonts/host /proc/mounts ; then
if ! grep /mnt/us/koreader/fonts/host /proc/mounts > /dev/null 2>&1 ; then
logmsg "Mounting system fonts . . ."
mount -o bind /usr/java/lib/fonts /mnt/us/koreader/fonts/host
fi
# bind-mount altfonts
if [ -d /mnt/us/fonts ] ; then
mkdir -p /mnt/us/koreader/fonts/altfonts
if ! grep /mnt/us/koreader/fonts/altfonts /proc/mounts ; then
if ! grep /mnt/us/koreader/fonts/altfonts /proc/mounts > /dev/null 2>&1 ; then
logmsg "Mounting altfonts . . ."
mount -o bind /mnt/us/fonts /mnt/us/koreader/fonts/altfonts
fi
fi
@ -53,13 +86,15 @@ fi
# bind-mount linkfonts
if [ -d /mnt/us/linkfonts/fonts ] ; then
mkdir -p /mnt/us/koreader/fonts/linkfonts
if ! grep /mnt/us/koreader/fonts/linkfonts /proc/mounts ; then
if ! grep /mnt/us/koreader/fonts/linkfonts /proc/mounts > /dev/null 2>&1 ; then
logmsg "Mounting linkfonts . . ."
mount -o bind /mnt/us/linkfonts/fonts /mnt/us/koreader/fonts/linkfonts
fi
fi
# check if we are supposed to shut down the Amazon framework
if [ "${STOP_FRAMEWORK}" == "yes" ]; then
if [ "${STOP_FRAMEWORK}" == "yes" ] ; then
logmsg "Stopping the framework . . ."
# Upstart or SysV?
if [ "${INIT_TYPE}" == "sysv" ] ; then
/etc/init.d/framework stop
@ -67,51 +102,69 @@ if [ "${STOP_FRAMEWORK}" == "yes" ]; then
# The framework job sends a SIGTERM on stop, trap it so we don't get killed if we were launched by KUAL
trap "" SIGTERM
stop lab126_gui
# Let things lie a bit so that we don't hit the black screen of no X ;).
sleep 2
# And remove the trap like a ninja now!
trap - SIGTERM
fi
fi
# check if kpvbooklet was launched for more than once, if not we will disable pillow
# there's no pillow if we stopped the framework, and it's only there on systems with upstart anyway
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
count=`lipc-get-prop -eiq com.github.koreader.kpvbooklet.timer count`
if [ "$count" == "" -o "$count" == "0" ]; then
count=$(lipc-get-prop -eiq com.github.koreader.kpvbooklet.timer count)
if [ "$count" == "" -o "$count" == "0" ] ; then
logmsg "Disabling pillow . . ."
lipc-set-prop com.lab126.pillow disableEnablePillow disable
PILLOW_DISABLED="yes"
# NOTE: This may or may not be terribly useful...
sleep 1
fi
fi
# stop cvm (sysv & framework up only)
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "sysv" ] ; then
logmsg "Stopping cvm . . ."
killall -stop cvm
fi
# finally call reader
logmsg "Starting KOReader . . ."
./reader.lua "$@" 2> crash.log
# clean up forked process in case the reader crashed
if [ "${INIT_TYPE}" == "sysv" ] ; then
# clean up our own process tree in case the reader crashed (if needed, to avoid flooding KUAL's log)
if pidof reader.lua > /dev/null 2>&1 ; then
logmsg "Sending a SIGTERM to stray KOreader processes . . ."
killall -TERM reader.lua
else
# We trapped SIGTERM, remember? ;)
killall -KILL reader.lua
fi
# unmount system fonts
if grep /mnt/us/koreader/fonts/host /proc/mounts ; then
if grep /mnt/us/koreader/fonts/host /proc/mounts > /dev/null 2>&1 ; then
logmsg "Unmounting system fonts . . ."
umount /mnt/us/koreader/fonts/host
fi
# unmount altfonts
if grep /mnt/us/koreader/fonts/altfonts /proc/mounts ; then
if grep /mnt/us/koreader/fonts/altfonts /proc/mounts > /dev/null 2>&1 ; then
logmsg "Unmounting altfonts . . ."
umount /mnt/us/koreader/fonts/altfonts
fi
# unmount linkfonts
if grep /mnt/us/koreader/fonts/linkfonts /proc/mounts ; then
if grep /mnt/us/koreader/fonts/linkfonts /proc/mounts > /dev/null 2>&1 ; then
logmsg "Unmounting linkfonts . . ."
umount /mnt/us/koreader/fonts/linkfonts
fi
# always try to continue cvm
if ! killall -cont cvm ; then
# Resume cvm (only if we stopped it)
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "sysv" ] ; then
logmsg "Resuming cvm . . ."
killall -cont cvm
fi
# Restart framework (if need be)
if [ "${STOP_FRAMEWORK}" == "yes" ] ; then
logmsg "Restarting framework . . ."
if [ "${INIT_TYPE}" == "sysv" ] ; then
/etc/init.d/framework start
else
@ -121,10 +174,15 @@ fi
# display chrome bar (upstart & framework up only)
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
lipc-set-prop com.lab126.pillow disableEnablePillow enable
# Only if we actually killed it...
if [ "${PILLOW_DISABLED}" == "yes" ] ; then
logmsg "Enabling pillow . . ."
lipc-set-prop com.lab126.pillow disableEnablePillow enable
fi
fi
# restore firewall rules
logmsg "Restoring IPTables rules . . ."
iptables -D INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT
iptables -D INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT

View File

@ -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