mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
2
base
2
base
Submodule base updated: a3deaf03ad...84d7b7a064
@@ -40,17 +40,17 @@ end
|
||||
|
||||
function ReaderFrontLight:onAdjust(arg, ges)
|
||||
local powerd = Device:getPowerDevice()
|
||||
if powerd.flIntensity ~= nil then
|
||||
DEBUG("frontlight intensity", powerd.flIntensity)
|
||||
if powerd.fl_intensity ~= nil then
|
||||
DEBUG("frontlight intensity", powerd.fl_intensity)
|
||||
local step = math.ceil(#self.steps * ges.distance / self.gestureScale)
|
||||
DEBUG("step = ", step)
|
||||
local delta_int = self.steps[step] or self.steps[#self.steps]
|
||||
DEBUG("delta_int = ", delta_int)
|
||||
local new_intensity
|
||||
if ges.direction == "north" then
|
||||
new_intensity = powerd.flIntensity + delta_int
|
||||
new_intensity = powerd.fl_intensity + delta_int
|
||||
elseif ges.direction == "south" then
|
||||
new_intensity = powerd.flIntensity - delta_int
|
||||
new_intensity = powerd.fl_intensity - delta_int
|
||||
end
|
||||
if new_intensity ~= nil then
|
||||
powerd:setIntensity(new_intensity)
|
||||
@@ -61,9 +61,9 @@ end
|
||||
|
||||
function ReaderFrontLight:onShowIntensity()
|
||||
local powerd = Device:getPowerDevice()
|
||||
if powerd.flIntensity ~= nil then
|
||||
if powerd.fl_intensity ~= nil then
|
||||
UIManager:show(Notification:new{
|
||||
text = T( _("Frontlight intensity is set to %1."), powerd.flIntensity),
|
||||
text = T(_("Frontlight intensity is set to %1."), powerd.fl_intensity),
|
||||
timeout = 1.0,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
local BasePowerD = {
|
||||
fl_min = 0, -- min frontlight intensity
|
||||
fl_max = 10, -- max frontlight intensity
|
||||
flIntensity = nil, -- frontlight intensity
|
||||
fl_min = 0, -- min frontlight intensity
|
||||
fl_max = 10, -- max frontlight intensity
|
||||
fl_intensity = nil, -- frontlight intensity
|
||||
battCapacity = nil, -- battery capacity
|
||||
device = nil, -- device object
|
||||
device = nil, -- device object
|
||||
|
||||
capacity_pulled_count = 0,
|
||||
capacity_cached_count = 10,
|
||||
@@ -57,7 +57,8 @@ function BasePowerD:normalizeIntensity(intensity)
|
||||
end
|
||||
|
||||
function BasePowerD:setIntensity(intensity)
|
||||
self.flIntensity = self:normalizeIntensity(intensity)
|
||||
if intensity == self.fl_intensity then return end
|
||||
self.fl_intensity = self:normalizeIntensity(intensity)
|
||||
self:setIntensityHW()
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ local BasePowerD = require("device/generic/powerd")
|
||||
local KindlePowerD = BasePowerD:new{
|
||||
fl_min = 0, fl_max = 24,
|
||||
|
||||
flIntensity = nil,
|
||||
fl_intensity = nil,
|
||||
battCapacity = nil,
|
||||
is_charging = nil,
|
||||
lipc_handle = nil,
|
||||
@@ -17,9 +17,9 @@ function KindlePowerD:init()
|
||||
end
|
||||
if self.device.hasFrontlight() then
|
||||
if self.lipc_handle ~= nil then
|
||||
self.flIntensity = self.lipc_handle:get_int_property("com.lab126.powerd", "flIntensity")
|
||||
self.fl_intensity = self.lipc_handle:get_int_property("com.lab126.powerd", "flIntensity")
|
||||
else
|
||||
self.flIntensity = self:read_int_file(self.fl_intensity_file)
|
||||
self.fl_intensity = self:read_int_file(self.fl_intensity_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -27,7 +27,7 @@ end
|
||||
function KindlePowerD:toggleFrontlight()
|
||||
local sysint = self:read_int_file(self.fl_intensity_file)
|
||||
if sysint == 0 then
|
||||
self:setIntensity(self.flIntensity)
|
||||
self:setIntensity(self.fl_intensity)
|
||||
else
|
||||
os.execute("echo -n 0 > " .. self.fl_intensity_file)
|
||||
end
|
||||
@@ -35,9 +35,9 @@ end
|
||||
|
||||
function KindlePowerD:setIntensityHW()
|
||||
if self.lipc_handle ~= nil then
|
||||
self.lipc_handle:set_int_property("com.lab126.powerd", "flIntensity", self.flIntensity)
|
||||
self.lipc_handle:set_int_property("com.lab126.powerd", "flIntensity", self.fl_intensity)
|
||||
else
|
||||
os.execute("echo -n ".. self.flIntensity .." > " .. self.fl_intensity_file)
|
||||
os.execute("echo -n ".. self.fl_intensity .." > " .. self.fl_intensity_file)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -143,6 +143,14 @@ end
|
||||
|
||||
function Kobo:resume()
|
||||
os.execute("echo 0 > /sys/power/state-extended")
|
||||
-- cf. #1862, I can reliably break IR touch input on resume...
|
||||
if os.getenv("FROM_NICKEL") == "true" then
|
||||
local f = io.open("/sys/devices/virtual/input/input1/neocmd", "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
os.execute("echo 'a' > /sys/devices/virtual/input/input1/neocmd")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-------------- device probe ------------
|
||||
|
||||
@@ -57,9 +57,9 @@ function NickelConf.frontLightLevel.get()
|
||||
if new_intensity then
|
||||
return powerd:normalizeIntensity(new_intensity)
|
||||
else
|
||||
local fallback_FrontLightLevel = powerd.flIntensity or 1
|
||||
assert(NickelConf.frontLightLevel.set(fallback_FrontLightLevel))
|
||||
return fallback_FrontLightLevel
|
||||
local fallback_fl_level = powerd.fl_intensity or 1
|
||||
assert(NickelConf.frontLightLevel.set(fallback_fl_level))
|
||||
return fallback_fl_level
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,16 +68,12 @@ function NickelConf.frontLightState.get()
|
||||
if new_state then
|
||||
new_state = (new_state == "true") or false
|
||||
end
|
||||
|
||||
if new_state == nil then
|
||||
assert(NickelConf.frontLightState.set(false))
|
||||
return false
|
||||
end
|
||||
|
||||
-- for devices that do not have toggle button, the entry will be missing
|
||||
-- and we return nil in this case.
|
||||
return new_state
|
||||
end
|
||||
|
||||
function NickelConf._write_kobo_conf(re_Match, key, value)
|
||||
function NickelConf._write_kobo_conf(re_Match, key, value, dont_create)
|
||||
local kobo_conf = io.open(kobo_conf_path, "r")
|
||||
local lines = {}
|
||||
local found = false
|
||||
@@ -112,7 +108,7 @@ function NickelConf._write_kobo_conf(re_Match, key, value)
|
||||
kobo_conf:close()
|
||||
end
|
||||
|
||||
if not found then
|
||||
if not found and dont_create ~= true then
|
||||
if not correct_section then
|
||||
lines[#lines + 1] = "[PowerOptions]"
|
||||
end
|
||||
@@ -134,6 +130,9 @@ end
|
||||
function NickelConf.frontLightLevel.set(new_intensity)
|
||||
assert(new_intensity >= 0 and new_intensity <= 100,
|
||||
"Wrong brightness value given!")
|
||||
-- Make sure we're in sync with KOReader on the config level, too
|
||||
G_reader_settings:saveSetting("frontlight_intensity",
|
||||
new_intensity)
|
||||
return NickelConf._write_kobo_conf(re_FrontLightLevel,
|
||||
front_light_level_str,
|
||||
new_intensity)
|
||||
@@ -144,7 +143,9 @@ function NickelConf.frontLightState.set(new_state)
|
||||
"Wrong front light state value type (expect boolean)!")
|
||||
return NickelConf._write_kobo_conf(re_FrontLightState,
|
||||
front_light_state_str,
|
||||
new_state)
|
||||
new_state,
|
||||
-- do not create this entry is missing
|
||||
true)
|
||||
end
|
||||
|
||||
return NickelConf
|
||||
|
||||
@@ -8,11 +8,15 @@ local KoboPowerD = BasePowerD:new{
|
||||
-- Do not actively set front light to 0, it may confuse users -- pressing
|
||||
-- hardware button won't take any effect.
|
||||
fl_min = 1, fl_max = 100,
|
||||
flIntensity = 20,
|
||||
fl_intensity = 20,
|
||||
restore_settings = true,
|
||||
fl = nil,
|
||||
|
||||
flState = false,
|
||||
-- We will set this value for all kobo models. but it will only be synced
|
||||
-- with nickel's FrontLightState config if the current nickel firmware
|
||||
-- supports this config.
|
||||
is_fl_on = false,
|
||||
|
||||
batt_capacity_file = batt_state_folder .. "capacity",
|
||||
is_charging_file = batt_state_folder .. "status",
|
||||
battCapacity = nil,
|
||||
@@ -23,29 +27,49 @@ function KoboPowerD:init()
|
||||
if self.device.hasFrontlight() then
|
||||
local kobolight = require("ffi/kobolight")
|
||||
local ok, light = pcall(kobolight.open)
|
||||
if ok then self.fl = light end
|
||||
if ok then
|
||||
self.fl = light
|
||||
if NickelConf.frontLightState.get() ~= nil then
|
||||
self.has_fl_state_cfg = true
|
||||
else
|
||||
self.has_fl_state_cfg = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function KoboPowerD:toggleFrontlight()
|
||||
if self.fl ~= nil then
|
||||
if self.flState then
|
||||
if self.is_fl_on then
|
||||
self.fl:setBrightness(0)
|
||||
else
|
||||
self.fl:setBrightness(self.flIntensity)
|
||||
self.fl:setBrightness(self.fl_intensity)
|
||||
end
|
||||
self.flState = not self.flState
|
||||
if KOBO_SYNC_BRIGHTNESS_WITH_NICKEL then
|
||||
NickelConf.frontLightState.set(self.flState)
|
||||
self.is_fl_on = not self.is_fl_on
|
||||
if self.has_fl_state_cfg and KOBO_SYNC_BRIGHTNESS_WITH_NICKEL then
|
||||
NickelConf.frontLightState.set(self.is_fl_on)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function KoboPowerD:setIntensityHW()
|
||||
if self.fl ~= nil then
|
||||
self.fl:setBrightness(self.flIntensity)
|
||||
self.fl:setBrightness(self.fl_intensity)
|
||||
if KOBO_SYNC_BRIGHTNESS_WITH_NICKEL then
|
||||
NickelConf.frontLightLevel.set(self.flIntensity)
|
||||
NickelConf.frontLightLevel.set(self.fl_intensity)
|
||||
end
|
||||
-- also keep self.is_fl_on in sync with intensity if needed
|
||||
local is_fl_on
|
||||
if self.fl_intensity > 0 then
|
||||
is_fl_on = true
|
||||
else
|
||||
is_fl_on = false
|
||||
end
|
||||
if self.is_fl_on ~= is_fl_on then
|
||||
self.is_fl_on = is_fl_on
|
||||
if self.has_fl_state_cfg and KOBO_SYNC_BRIGHTNESS_WITH_NICKEL then
|
||||
NickelConf.frontLightState.set(self.is_fl_on)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -62,19 +86,19 @@ end
|
||||
|
||||
-- Turn off front light before suspend.
|
||||
function KoboPowerD:beforeSuspend()
|
||||
if self.flState then
|
||||
assert(self.fl ~= nil)
|
||||
if self.fl ~= nil then
|
||||
self.fl:setBrightness(0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Restore front light state after resume.
|
||||
function KoboPowerD:afterResume()
|
||||
if KOBO_LIGHT_ON_START and tonumber(KOBO_LIGHT_ON_START) > -1 then
|
||||
self:setIntensity(math.min(KOBO_LIGHT_ON_START, 100))
|
||||
elseif self.flState then
|
||||
assert(self.fl ~= nil)
|
||||
self.fl:setBrightness(self.flIntensity)
|
||||
if self.fl ~= nil then
|
||||
if KOBO_LIGHT_ON_START and tonumber(KOBO_LIGHT_ON_START) > -1 then
|
||||
self:setIntensity(math.min(KOBO_LIGHT_ON_START, 100))
|
||||
elseif self.is_fl_on then
|
||||
self.fl:setBrightness(self.fl_intensity)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -64,24 +64,33 @@ function UIManager:init()
|
||||
local kobo_light_on_start = tonumber(KOBO_LIGHT_ON_START)
|
||||
if kobo_light_on_start then
|
||||
local new_intensity
|
||||
local new_state
|
||||
local is_frontlight_on
|
||||
if kobo_light_on_start > 0 then
|
||||
new_intensity = math.min(kobo_light_on_start, 100)
|
||||
new_state = true
|
||||
is_frontlight_on = true
|
||||
elseif kobo_light_on_start == 0 then
|
||||
new_state = false
|
||||
is_frontlight_on = false
|
||||
elseif kobo_light_on_start == -2 then
|
||||
local NickelConf = require("device/kobo/nickel_conf")
|
||||
new_intensity = NickelConf.frontLightLevel.get()
|
||||
new_state = NickelConf.frontLightState:get()
|
||||
is_frontlight_on = NickelConf.frontLightState:get()
|
||||
if is_frontlight_on == nil then
|
||||
-- this device does not support frontlight toggle,
|
||||
-- we set the value based on frontlight intensity.
|
||||
if new_intensity > 0 then
|
||||
is_frontlight_on = true
|
||||
else
|
||||
is_frontlight_on = false
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Since this kobo-specific, we save all values in settings here
|
||||
-- and let the code (reader.lua) pick it up later during bootstrap.
|
||||
if new_intensity then
|
||||
-- Since this kobo-specific, we save here and let the code pick
|
||||
-- it up later from the reader settings.
|
||||
G_reader_settings:saveSetting(
|
||||
"frontlight_intensity", new_intensity)
|
||||
G_reader_settings:saveSetting("frontlight_intensity",
|
||||
new_intensity)
|
||||
end
|
||||
G_reader_settings:saveSetting("frontlight_state", new_state)
|
||||
G_reader_settings:saveSetting("is_frontlight_on", is_frontlight_on)
|
||||
end
|
||||
elseif Device:isKindle() then
|
||||
self.event_handlers["IntoSS"] = function()
|
||||
|
||||
2
kodev
2
kodev
@@ -130,7 +130,7 @@ ${SUPPORTED_TARGETS}"
|
||||
;;
|
||||
android)
|
||||
make TARGET=android clean
|
||||
rm *.apk
|
||||
rm -f *.apk
|
||||
;;
|
||||
pocketbook)
|
||||
make TARGET=pocketbook clean
|
||||
|
||||
@@ -29,12 +29,12 @@ export EXT_FONT_DIR="/mnt/onboard/fonts"
|
||||
|
||||
# fast and dirty way of check if we are called from nickel
|
||||
# through fmon, or from another launcher (KSM or advboot)
|
||||
from_nickel="false"
|
||||
export FROM_NICKEL="false"
|
||||
if pkill -0 nickel ; then
|
||||
from_nickel="true"
|
||||
FROM_NICKEL="true"
|
||||
fi
|
||||
|
||||
if [ "${from_nickel}" == "true" ] ; then
|
||||
if [ "${FROM_NICKEL}" == "true" ] ; then
|
||||
# Siphon a few things from nickel's env...
|
||||
eval "$(xargs -n 1 -0 < /proc/$(pidof nickel)/environ | grep -e DBUS_SESSION_BUS_ADDRESS -e WIFI_MODULE -e PLATFORM -e WIFI_MODULE_PATH -e INTERFACE -e PRODUCT 2>/dev/null)"
|
||||
export DBUS_SESSION_BUS_ADDRESS WIFI_MODULE PLATFORM WIFI_MODULE_PATH INTERFACE PRODUCT
|
||||
@@ -80,16 +80,14 @@ if [ ! -n "${PLATFORM}" ] ; then
|
||||
fi
|
||||
# end of value check of PLATFORM
|
||||
|
||||
grep ' /mnt/sd ' /proc/mounts | grep 'ro'
|
||||
# Remount SD to RW if it's RO
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
mount -o remount,rw /mnt/sd
|
||||
# Remount the SD card RW if it's inserted and currently RO
|
||||
if awk '$4~/(^|,)ro($|,)/' /proc/mounts | grep ' /mnt/sd ' ; then
|
||||
mount -o remount,rw /mnt/sd
|
||||
fi
|
||||
|
||||
./reader.lua "${args}" 2> crash.log
|
||||
|
||||
if [ "${from_nickel}" == "true" ] ; then
|
||||
if [ "${FROM_NICKEL}" == "true" ] ; then
|
||||
# start kobo software because it was running before koreader
|
||||
./nickel.sh &
|
||||
else
|
||||
|
||||
91
platform/kobo/nickel_suspend_strace.txt
Normal file
91
platform/kobo/nickel_suspend_strace.txt
Normal file
@@ -0,0 +1,91 @@
|
||||
## On the other hand, nickel doesn't seem to fare any better... when the suspend to ram fails, it spends its time doing this over and over:
|
||||
# strace -fitv -P /sys/power/state -P /sys/power/state-extended -P /sys/power/wakeup_count -p $(pidof nickel)
|
||||
|
||||
strace: Process 4474 attached
|
||||
strace: Process 4475 attached
|
||||
[pid 4475] 19:38:43 [????????] +++ exited with 0 +++
|
||||
[pid 4474] 19:38:43 [2ab4c276] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4475, si_uid=0, si_status=0, si_utime=1, si_stime=0} ---
|
||||
[pid 4474] 19:38:43 [????????] +++ exited with 0 +++
|
||||
[pid 3681] 19:38:43 [2f0d8386] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4474, si_uid=0, si_status=0, si_utime=0, si_stime=2} ---
|
||||
[pid 3681] 19:38:46 [2f0d8386] open("/sys/power/wakeup_count", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 24
|
||||
[pid 3681] 19:38:46 [2f0d8386] fcntl64(24, F_SETFD, FD_CLOEXEC) = 0
|
||||
[pid 3681] 19:38:46 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:08:22.880008624, st_ctime=2016/02/29-19:08:22.880008624}) = 0
|
||||
[pid 3681] 19:38:46 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:08:22.880008624, st_ctime=2016/02/29-19:08:22.880008624}) = 0
|
||||
[pid 3681] 19:38:46 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:08:22.880008624, st_ctime=2016/02/29-19:08:22.880008624}) = 0
|
||||
[pid 3681] 19:38:46 [2f0d63a4] read(24, "3183\n", 16384) = 5
|
||||
[pid 3681] 19:38:46 [2f0d63a4] read(24, "", 16379) = 0
|
||||
[pid 3681] 19:38:46 [2f0d63a4] read(24, "", 4091) = 0
|
||||
[pid 3681] 19:38:46 [2f0d6454] close(24) = 0
|
||||
[pid 3681] 19:38:46 [2f0d8386] open("/sys/power/state-extended", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 26
|
||||
[pid 3681] 19:38:46 [2f0d8386] fcntl64(26, F_SETFD, FD_CLOEXEC) = 0
|
||||
[pid 3681] 19:38:46 [2f232276] fstat64(26, {st_dev=makedev(0, 14), st_ino=38, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:38:46.129858648, st_ctime=2016/02/29-19:38:46.129858648}) = 0
|
||||
[pid 3681] 19:38:46 [2f0d62f4] write(26, "1", 1) = 1
|
||||
[pid 3681] 19:38:46 [2f0d6454] close(26) = 0
|
||||
[pid 3681] 19:38:46 [2f0d8386] open("/sys/power/state", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 26
|
||||
[pid 3681] 19:38:46 [2f0d8386] fcntl64(26, F_SETFD, FD_CLOEXEC) = 0
|
||||
[pid 3681] 19:38:46 [2f232276] fstat64(26, {st_dev=makedev(0, 14), st_ino=33, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:38:46.129858648, st_ctime=2016/02/29-19:38:46.129858648}) = 0
|
||||
[pid 3681] 19:38:46 [2f0d62f4] write(26, "mem", 3) = -1 EBUSY (Device or resource busy)
|
||||
[pid 3681] 19:38:46 [2f0d6454] close(26) = 0
|
||||
[pid 3681] 19:38:46 [2f0d8386] open("/sys/power/state-extended", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 26
|
||||
[pid 3681] 19:38:46 [2f0d8386] fcntl64(26, F_SETFD, FD_CLOEXEC) = 0
|
||||
[pid 3681] 19:38:46 [2f232276] fstat64(26, {st_dev=makedev(0, 14), st_ino=38, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:38:46.449974712, st_ctime=2016/02/29-19:38:46.449974712}) = 0
|
||||
[pid 3681] 19:38:46 [2f0d62f4] write(26, "0", 1) = 1
|
||||
[pid 3681] 19:38:46 [2f0d6454] close(26) = 0
|
||||
strace: Process 4478 attached
|
||||
strace: Process 4479 attached
|
||||
[pid 4479] 19:38:47 [????????] +++ exited with 0 +++
|
||||
[pid 4478] 19:38:47 [2ab4c276] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4479, si_uid=0, si_status=0, si_utime=1, si_stime=0} ---
|
||||
[pid 4478] 19:38:47 [????????] +++ exited with 0 +++
|
||||
[pid 3681] 19:38:47 [2f0d8386] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4478, si_uid=0, si_status=0, si_utime=1, si_stime=0} ---
|
||||
[pid 3681] 19:38:50 [2f0d8386] open("/sys/power/wakeup_count", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 24
|
||||
[pid 3681] 19:38:50 [2f0d8386] fcntl64(24, F_SETFD, FD_CLOEXEC) = 0
|
||||
[pid 3681] 19:38:50 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:08:22.880008624, st_ctime=2016/02/29-19:08:22.880008624}) = 0
|
||||
[pid 3681] 19:38:50 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:08:22.880008624, st_ctime=2016/02/29-19:08:22.880008624}) = 0
|
||||
[pid 3681] 19:38:50 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:08:22.880008624, st_ctime=2016/02/29-19:08:22.880008624}) = 0
|
||||
[pid 3681] 19:38:50 [2f0d63a4] read(24, "3185\n", 16384) = 5
|
||||
[pid 3681] 19:38:50 [2f0d63a4] read(24, "", 16379) = 0
|
||||
[pid 3681] 19:38:50 [2f0d63a4] read(24, "", 4091) = 0
|
||||
[pid 3681] 19:38:50 [2f0d6454] close(24) = 0
|
||||
[pid 3681] 19:38:50 [2f0d8386] open("/sys/power/state-extended", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 26
|
||||
[pid 3681] 19:38:50 [2f0d8386] fcntl64(26, F_SETFD, FD_CLOEXEC) = 0
|
||||
[pid 3681] 19:38:50 [2f232276] fstat64(26, {st_dev=makedev(0, 14), st_ino=38, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:38:50.129984109, st_ctime=2016/02/29-19:38:50.129984109}) = 0
|
||||
[pid 3681] 19:38:50 [2f0d62f4] write(26, "1", 1) = 1
|
||||
[pid 3681] 19:38:50 [2f0d6454] close(26) = 0
|
||||
[pid 3681] 19:38:50 [2f0d8386] open("/sys/power/state", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 26
|
||||
[pid 3681] 19:38:50 [2f0d8386] fcntl64(26, F_SETFD, FD_CLOEXEC) = 0
|
||||
[pid 3681] 19:38:50 [2f232276] fstat64(26, {st_dev=makedev(0, 14), st_ino=33, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:38:50.129984109, st_ctime=2016/02/29-19:38:50.129984109}) = 0
|
||||
[pid 3681] 19:38:50 [2f0d62f4] write(26, "mem", 3) = -1 EBUSY (Device or resource busy)
|
||||
[pid 3681] 19:38:50 [2f0d6454] close(26) = 0
|
||||
[pid 3681] 19:38:50 [2f0d8386] open("/sys/power/state-extended", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 26
|
||||
[pid 3681] 19:38:50 [2f0d8386] fcntl64(26, F_SETFD, FD_CLOEXEC) = 0
|
||||
[pid 3681] 19:38:50 [2f232276] fstat64(26, {st_dev=makedev(0, 14), st_ino=38, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/02/29-18:18:37.514794262, st_mtime=2016/02/29-19:38:50.440016287, st_ctime=2016/02/29-19:38:50.440016287}) = 0
|
||||
[pid 3681] 19:38:50 [2f0d62f4] write(26, "0", 1) = 1
|
||||
[pid 3681] 19:38:50 [2f0d6454] close(26) = 0
|
||||
|
||||
|
||||
## Compared to a successful suspend/wakeup cycle:
|
||||
522 00:59:53 [2f0d8386] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1291, si_uid=0, si_status=0, si_utime=0, si_stime=1} ---
|
||||
522 00:59:54 [2f0d8386] open("/sys/power/wakeup_count", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 21
|
||||
522 00:59:54 [2f0d8386] fcntl64(21, F_SETFD, FD_CLOEXEC) = 0
|
||||
522 00:59:54 [2f232276] fstat64(21, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/03/01-00:52:55.478751029, st_mtime=2016/03/01-00:52:55.478751029, st_ctime=2016/03/01-00:52:55.478751029}) = 0
|
||||
522 00:59:54 [2f232276] fstat64(21, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/03/01-00:52:55.478751029, st_mtime=2016/03/01-00:52:55.478751029, st_ctime=2016/03/01-00:52:55.478751029}) = 0
|
||||
522 00:59:54 [2f232276] fstat64(21, {st_dev=makedev(0, 14), st_ino=36, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/03/01-00:52:55.478751029, st_mtime=2016/03/01-00:52:55.478751029, st_ctime=2016/03/01-00:52:55.478751029}) = 0
|
||||
522 00:59:54 [2f0d63a4] read(21, "93\n", 16384) = 3
|
||||
522 00:59:54 [2f0d63a4] read(21, "", 16381) = 0
|
||||
522 00:59:54 [2f0d63a4] read(21, "", 4093) = 0
|
||||
522 00:59:54 [2f0d6454] close(21) = 0
|
||||
522 00:59:54 [2f0d8386] open("/sys/power/state-extended", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 24
|
||||
522 00:59:54 [2f0d8386] fcntl64(24, F_SETFD, FD_CLOEXEC) = 0
|
||||
522 00:59:54 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=38, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/03/01-00:59:54.358750902, st_mtime=2016/03/01-00:59:54.358750902, st_ctime=2016/03/01-00:59:54.358750902}) = 0
|
||||
522 00:59:54 [2f0d62f4] write(24, "1", 1) = 1
|
||||
522 00:59:54 [2f0d6454] close(24) = 0
|
||||
522 00:59:54 [2f0d8386] open("/sys/power/state", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 24
|
||||
522 00:59:54 [2f0d8386] fcntl64(24, F_SETFD, FD_CLOEXEC) = 0
|
||||
522 00:59:54 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=33, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/03/01-00:59:54.358750902, st_mtime=2016/03/01-00:59:54.358750902, st_ctime=2016/03/01-00:59:54.358750902}) = 0
|
||||
522 00:59:54 [2f0d62f4] write(24, "mem", 3) = 3
|
||||
522 01:00:27 [2f0d6454] close(24) = 0
|
||||
522 01:00:27 [2f0d8386] open("/sys/power/state-extended", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 24
|
||||
522 01:00:27 [2f0d8386] fcntl64(24, F_SETFD, FD_CLOEXEC) = 0
|
||||
522 01:00:27 [2f232276] fstat64(24, {st_dev=makedev(0, 14), st_ino=38, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2016/03/01-00:59:54.358750902, st_mtime=2016/03/01-01:00:27.398750985, st_ctime=2016/03/01-01:00:27.398750985}) = 0
|
||||
522 01:00:27 [2f0d62f4] write(24, "0", 1) = 1
|
||||
522 01:00:27 [2f0d6454] close(24) = 0
|
||||
@@ -1,16 +1,36 @@
|
||||
#!/bin/sh
|
||||
export PATH="${PATH}:/sbin:/usr/sbin"
|
||||
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: BEGIN!"
|
||||
# Disable wifi
|
||||
if lsmod | grep -q sdio_wifi_pwr ; then
|
||||
wlarm_le -i eth0 down
|
||||
ifconfig eth0 down
|
||||
rmmod -r dhd
|
||||
rmmod -r sdio_wifi_pwr
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Killed WiFi"
|
||||
fi
|
||||
|
||||
# Go to sleep
|
||||
sync
|
||||
current_wakeup_count="$(cat /sys/power/wakeup_count)"
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Current WakeUp count: ${current_wakeup_count}"
|
||||
echo 1 > /sys/power/state-extended
|
||||
sleep 2 # Because reasons?
|
||||
# NOTE: Sets gSleep_Mode_Suspend to 1. Used as a flag throughout the kernel to suspend/resume various subsystems
|
||||
# cf. kernel/power/main.c @ L#207
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Asked the kernel to put subsystems to sleep"
|
||||
sleep 2
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Waited for 2s because of reasons..."
|
||||
sync
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Synced FS"
|
||||
echo ${current_wakeup_count} > /sys/power/wakeup_count
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Wrote WakeUp count: ${current_wakeup_count} ($?)"
|
||||
echo mem > /sys/power/state
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: Asked to suspend to RAM... ZzZ ZzZ ZzZ? ($?)"
|
||||
## NOTE: Ideally, we'd need a way to warn the user that suspending gloriously failed at this point...
|
||||
## We can safely assume that just from a non-zero return code, without looking at the detailed stderr message
|
||||
## (most of the failures we'll see are -EBUSY anyway)
|
||||
## For reference, when that happens to nickel, it appears to keep retrying to wakeup & sleep ad nauseam,
|
||||
## which is where the non-sensical 1 -> mem -> 0 loop idea comes from...
|
||||
## cf. nickel_suspend_strace.txt for more details.
|
||||
|
||||
echo "[$(date +'%x @ %X')] Kobo Suspend: END! (WakeUp count: $(cat /sys/power/wakeup_count))"
|
||||
|
||||
16
reader.lua
16
reader.lua
@@ -120,12 +120,20 @@ end
|
||||
if Device:isKobo() then
|
||||
local powerd = Device:getPowerDevice()
|
||||
if powerd and powerd.restore_settings then
|
||||
-- UIManager:init() should have sanely set up the frontlight_stuff by this point
|
||||
local intensity = G_reader_settings:readSetting("frontlight_intensity")
|
||||
powerd.flIntensity = intensity or powerd.flIntensity
|
||||
local state = G_reader_settings:readSetting("frontlight_state")
|
||||
if state then
|
||||
-- Default state is off
|
||||
powerd.fl_intensity = intensity or powerd.fl_intensity
|
||||
local is_frontlight_on = G_reader_settings:readSetting("is_frontlight_on")
|
||||
if is_frontlight_on then
|
||||
-- default powerd.is_fl_on is false, turn it on
|
||||
powerd:toggleFrontlight()
|
||||
else
|
||||
-- the light can still be turned on manually outside of koreader
|
||||
-- or nickel. so we always set the intensity to 0 here to keep it
|
||||
-- in sync with powerd.is_fl_on (false by default)
|
||||
-- NOTE: we cant use setIntensity method here because for kobo the
|
||||
-- min intensity is 1 :(
|
||||
powerd.fl:setBrightness(0)
|
||||
end
|
||||
end
|
||||
if Device:getCodeName() == "trilogy" then
|
||||
|
||||
@@ -59,7 +59,7 @@ bar=baz
|
||||
|
||||
NickelConf._set_kobo_conf_path(fn)
|
||||
assert.Equals(NickelConf.frontLightLevel.get(), 20)
|
||||
assert.Equals(NickelConf.frontLightState.get(), false)
|
||||
assert.Equals(NickelConf.frontLightState.get(), nil)
|
||||
|
||||
os.remove(fn)
|
||||
end)
|
||||
@@ -83,7 +83,6 @@ FrontLightLevel=6
|
||||
FrontLightLevel=6
|
||||
[PowerOptions]
|
||||
FrontLightLevel=100
|
||||
FrontLightState=true
|
||||
]])
|
||||
fd:close()
|
||||
os.remove(fn)
|
||||
@@ -99,7 +98,6 @@ FrontLightState=true
|
||||
assert.Equals(fd:read("*a"), [[
|
||||
[PowerOptions]
|
||||
FrontLightLevel=20
|
||||
FrontLightState=false
|
||||
]])
|
||||
fd:close()
|
||||
os.remove(fn)
|
||||
@@ -153,14 +151,13 @@ bar=baz
|
||||
NickelConf.frontLightState.set(true)
|
||||
|
||||
fd = io.open(fn, "r")
|
||||
assert.Equals(fd:read("*a"), [[
|
||||
assert.Equals([[
|
||||
[PowerOptions]
|
||||
foo=bar
|
||||
FrontLightLevel=1
|
||||
FrontLightState=true
|
||||
[OtherThing]
|
||||
bar=baz
|
||||
]])
|
||||
]], fd:read("*a"))
|
||||
fd:close()
|
||||
os.remove(fn)
|
||||
end)
|
||||
@@ -178,7 +175,6 @@ bar=baz
|
||||
assert.Equals([[
|
||||
[PowerOptions]
|
||||
FrontLightLevel=15
|
||||
FrontLightState=false
|
||||
]],
|
||||
fd:read("*a"))
|
||||
fd:close()
|
||||
|
||||
Reference in New Issue
Block a user