Split suspend-resume logic

pull/269/head
Giorgio Micotti 11 years ago
parent 22abc0b77a
commit ec3d23ef10

@ -155,19 +155,31 @@ end
function Device:Suspend() function Device:Suspend()
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = _("Standby"), text = _("Standby"),
timeout = 4, timeout = 2,
}) })
if self.fl ~= nil then if self.fl ~= nil then
self.fl:sleep() self.fl:sleep()
end end
os.execute("./kobo_suspend.sh &") self.screen_saver_mode = true
os.execute("./kobo_suspend.sh")
end end
function Device:Resume() function Device:Resume()
--util.usleep(1500000)
os.execute("echo 0 > /sys/power/state-extended")
if self.fl ~= nil then if self.fl ~= nil then
self.fl:resume() self.fl:resume()
end end
-- Screen:refresh(0) -- 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 end
function Device:usbPlugIn() function Device:usbPlugIn()

@ -385,7 +385,7 @@ function Input:adjustKindle4EventMap()
end end
function Input:adjustKoboEventMap() function Input:adjustKoboEventMap()
self.event_map[53] = "Power" self.event_map[59] = "Power_SleepCover"
self.event_map[90] = "Light" self.event_map[90] = "Light"
self.event_map[116] = "Power" self.event_map[116] = "Power"
end end
@ -424,7 +424,7 @@ function Input:handleKeyBoardEv(ev)
end end
-- Kobo sleep -- Kobo sleep
if keycode == "Power" then if keycode == "Power_SleepCover" then
if ev.value == EVENT_VALUE_KEY_PRESS then if ev.value == EVENT_VALUE_KEY_PRESS then
return "Suspend" return "Suspend"
else else
@ -433,7 +433,7 @@ function Input:handleKeyBoardEv(ev)
end end
if ev.value == EVENT_VALUE_KEY_RELEASE if ev.value == EVENT_VALUE_KEY_RELEASE
and keycode == "Light" then and (keycode == "Light" or keycode == "Power") then
return keycode return keycode
end end

@ -293,6 +293,8 @@ function UIManager:run()
Device:usbPlugOut() Device:usbPlugOut()
elseif input_event == "Light" then elseif input_event == "Light" then
Device:getFrontlight():toggle() Device:getFrontlight():toggle()
elseif input_event == "Power" then
Device:Power()
elseif input_event == "Suspend" then elseif input_event == "Suspend" then
Device:Suspend() Device:Suspend()
elseif input_event == "Resume" then elseif input_event == "Resume" then

@ -1,17 +1,7 @@
#!/bin/sh #!/bin/sh
export PATH=$PATH:/sbin:/usr/sbin export PATH=$PATH:/sbin:/usr/sbin
ts_file=/tmp/back_from_suspend #disable wifi
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
if lsmod | grep -q sdio_wifi_pwr ; then if lsmod | grep -q sdio_wifi_pwr ; then
wlarm_le -i eth0 down wlarm_le -i eth0 down
ifconfig eth0 down ifconfig eth0 down
@ -19,12 +9,7 @@ if lsmod | grep -q sdio_wifi_pwr ; then
/sbin/rmmod -r sdio_wifi_pwr /sbin/rmmod -r sdio_wifi_pwr
fi fi
#go to sleep
sleep 1
sync sync
echo 1 > /sys/power/state-extended echo 1 > /sys/power/state-extended
echo mem > /sys/power/state echo mem > /sys/power/state
echo 0 > /sys/power/state-extended
touch $ts_file

Loading…
Cancel
Save