mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Split suspend-resume logic
This commit is contained in:
@@ -155,19 +155,31 @@ end
|
||||
function Device:Suspend()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Standby"),
|
||||
timeout = 4,
|
||||
timeout = 2,
|
||||
})
|
||||
if self.fl ~= nil then
|
||||
self.fl:sleep()
|
||||
end
|
||||
os.execute("./kobo_suspend.sh &")
|
||||
self.screen_saver_mode = true
|
||||
os.execute("./kobo_suspend.sh")
|
||||
end
|
||||
|
||||
function Device:Resume()
|
||||
--util.usleep(1500000)
|
||||
os.execute("echo 0 > /sys/power/state-extended")
|
||||
if self.fl ~= nil then
|
||||
self.fl:resume()
|
||||
end
|
||||
-- Screen:refresh(0)
|
||||
self.screen_saver_mode = false
|
||||
end
|
||||
|
||||
function Device:Power()
|
||||
if self.screen_saver_mode == true then
|
||||
Device:Resume()
|
||||
else
|
||||
Device:Suspend()
|
||||
end
|
||||
end
|
||||
|
||||
function Device:usbPlugIn()
|
||||
|
||||
@@ -385,7 +385,7 @@ function Input:adjustKindle4EventMap()
|
||||
end
|
||||
|
||||
function Input:adjustKoboEventMap()
|
||||
self.event_map[53] = "Power"
|
||||
self.event_map[59] = "Power_SleepCover"
|
||||
self.event_map[90] = "Light"
|
||||
self.event_map[116] = "Power"
|
||||
end
|
||||
@@ -424,7 +424,7 @@ function Input:handleKeyBoardEv(ev)
|
||||
end
|
||||
|
||||
-- Kobo sleep
|
||||
if keycode == "Power" then
|
||||
if keycode == "Power_SleepCover" then
|
||||
if ev.value == EVENT_VALUE_KEY_PRESS then
|
||||
return "Suspend"
|
||||
else
|
||||
@@ -433,7 +433,7 @@ function Input:handleKeyBoardEv(ev)
|
||||
end
|
||||
|
||||
if ev.value == EVENT_VALUE_KEY_RELEASE
|
||||
and keycode == "Light" then
|
||||
and (keycode == "Light" or keycode == "Power") then
|
||||
return keycode
|
||||
end
|
||||
|
||||
|
||||
@@ -293,6 +293,8 @@ function UIManager:run()
|
||||
Device:usbPlugOut()
|
||||
elseif input_event == "Light" then
|
||||
Device:getFrontlight():toggle()
|
||||
elseif input_event == "Power" then
|
||||
Device:Power()
|
||||
elseif input_event == "Suspend" then
|
||||
Device:Suspend()
|
||||
elseif input_event == "Resume" then
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
#!/bin/sh
|
||||
export PATH=$PATH:/sbin:/usr/sbin
|
||||
|
||||
ts_file=/tmp/back_from_suspend
|
||||
|
||||
if test -e $ts_file ; then
|
||||
sec_back_suspend=$(stat -t $ts_file | awk '{print $13}' )
|
||||
delta_sec=$(( $(date +%s) - $sec_back_suspend ))
|
||||
echo sec_back_suspend=$sec_back_suspend delta_sec=$delta_sec >> /tmp/event_test.txt
|
||||
test $delta_sec -gt 2 || exit
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
|
||||
#disable wifi
|
||||
if lsmod | grep -q sdio_wifi_pwr ; then
|
||||
wlarm_le -i eth0 down
|
||||
ifconfig eth0 down
|
||||
@@ -19,12 +9,7 @@ if lsmod | grep -q sdio_wifi_pwr ; then
|
||||
/sbin/rmmod -r sdio_wifi_pwr
|
||||
fi
|
||||
|
||||
|
||||
sleep 1
|
||||
|
||||
#go to sleep
|
||||
sync
|
||||
echo 1 > /sys/power/state-extended
|
||||
echo mem > /sys/power/state
|
||||
echo 0 > /sys/power/state-extended
|
||||
|
||||
touch $ts_file
|
||||
|
||||
Reference in New Issue
Block a user