2012-06-13 17:52:08 +00:00
|
|
|
Device = {
|
|
|
|
screen_saver_mode = false,
|
|
|
|
charging_mode = false,
|
2012-12-11 00:01:32 +00:00
|
|
|
model = nil,
|
2012-06-13 17:52:08 +00:00
|
|
|
}
|
|
|
|
|
2012-10-14 06:22:01 +00:00
|
|
|
function Device:getModel()
|
|
|
|
local std_out = io.popen("grep 'MX' /proc/cpuinfo | cut -d':' -f2 | awk {'print $2'}", "r")
|
|
|
|
local cpu_mod = std_out:read()
|
|
|
|
if not cpu_mod then
|
2012-10-14 18:32:08 +00:00
|
|
|
local ret = os.execute("grep 'Hardware : Mario Platform' /proc/cpuinfo", "r")
|
|
|
|
if ret ~= 0 then
|
|
|
|
return nil
|
|
|
|
else
|
|
|
|
return "KindleDXG"
|
|
|
|
end
|
2012-10-14 06:22:01 +00:00
|
|
|
end
|
|
|
|
if cpu_mod == "MX50" then
|
2012-12-08 06:06:47 +00:00
|
|
|
-- for KPW
|
|
|
|
local pw_test_fd = lfs.attributes("/sys/devices/system/fl_tps6116x/fl_tps6116x0/fl_intensity")
|
|
|
|
-- for KT
|
|
|
|
local kt_test_fd = lfs.attributes("/sys/devices/platform/whitney-button")
|
|
|
|
-- another special file for KT is Neonode zForce touchscreen:
|
|
|
|
-- /sys/devices/platform/zforce.0/
|
|
|
|
if pw_test_fd then
|
2012-10-14 06:22:01 +00:00
|
|
|
return "KindlePaperWhite"
|
2012-12-08 06:06:47 +00:00
|
|
|
elseif kt_test_fd then
|
|
|
|
return "KindleTouch"
|
2012-10-14 06:22:01 +00:00
|
|
|
else
|
|
|
|
return "Kindle4"
|
|
|
|
end
|
|
|
|
elseif cpu_mod == "MX35" then
|
|
|
|
-- check if we are running on Kindle 3 (additional volume input)
|
2012-10-14 18:32:08 +00:00
|
|
|
return "Kindle3"
|
2012-10-14 06:22:01 +00:00
|
|
|
elseif cpu_mod == "MX3" then
|
|
|
|
return "Kindle2"
|
|
|
|
else
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-13 17:52:08 +00:00
|
|
|
function Device:isKindle4()
|
2012-12-12 02:03:16 +00:00
|
|
|
return (self:getModel() == "Kindle4")
|
2012-06-13 13:27:38 +00:00
|
|
|
end
|
|
|
|
|
2012-06-13 17:52:08 +00:00
|
|
|
function Device:isKindle3()
|
2012-06-13 13:27:38 +00:00
|
|
|
re_val = os.execute("cat /proc/cpuinfo | grep MX35")
|
|
|
|
if re_val == 0 then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-13 17:52:08 +00:00
|
|
|
function Device:isKindle2()
|
2012-06-13 13:27:38 +00:00
|
|
|
re_val = os.execute("cat /proc/cpuinfo | grep MX3")
|
|
|
|
if re_val == 0 then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
2012-06-13 17:52:08 +00:00
|
|
|
|
2012-12-11 00:01:32 +00:00
|
|
|
function Device:hasNoKeyboard()
|
|
|
|
if not self.model then
|
|
|
|
self.model = self:getModel()
|
|
|
|
end
|
|
|
|
return self:isTouchDevice() or (self.model == "Kindle4")
|
|
|
|
end
|
|
|
|
|
2013-01-01 01:44:52 +00:00
|
|
|
function Device:hasKeyboard()
|
|
|
|
return not self:hasNoKeyboard()
|
|
|
|
end
|
|
|
|
|
2012-11-11 07:24:11 +00:00
|
|
|
function Device:isTouchDevice()
|
2012-12-11 00:01:32 +00:00
|
|
|
if not self.model then
|
|
|
|
self.model = self:getModel()
|
|
|
|
end
|
|
|
|
return (self.model == "KindlePaperWhite") or (self.model == "KindleTouch") or util.isEmulated()
|
2012-11-11 07:24:11 +00:00
|
|
|
end
|
|
|
|
|
2012-06-13 17:52:08 +00:00
|
|
|
function Device:intoScreenSaver()
|
|
|
|
--os.execute("echo 'screensaver in' >> /mnt/us/event_test.txt")
|
|
|
|
if self.charging_mode == false and self.screen_saver_mode == false then
|
|
|
|
Screen:saveCurrentBB()
|
2013-02-02 08:37:48 +00:00
|
|
|
--UIManager:show(InfoMessage:new{
|
|
|
|
--text = "Going into screensaver... ",
|
|
|
|
--timeout = 2,
|
|
|
|
--})
|
2013-01-10 06:23:11 +00:00
|
|
|
--util.sleep(1)
|
|
|
|
--os.execute("killall -cont cvm")
|
2012-06-13 17:52:08 +00:00
|
|
|
self.screen_saver_mode = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Device:outofScreenSaver()
|
|
|
|
--os.execute("echo 'screensaver out' >> /mnt/us/event_test.txt")
|
|
|
|
if self.screen_saver_mode == true and self.charging_mode == false then
|
2013-02-02 08:37:48 +00:00
|
|
|
-- wait for native system update screen before we recover saved
|
|
|
|
-- Blitbuffer.
|
|
|
|
util.usleep(1500000)
|
2013-01-10 06:23:11 +00:00
|
|
|
--os.execute("killall -stop cvm")
|
2012-06-13 17:52:08 +00:00
|
|
|
Screen:restoreFromSavedBB()
|
2013-02-02 06:36:29 +00:00
|
|
|
Screen:refresh(0)
|
2012-06-13 17:52:08 +00:00
|
|
|
end
|
|
|
|
self.screen_saver_mode = false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Device:usbPlugIn()
|
|
|
|
--os.execute("echo 'usb in' >> /mnt/us/event_test.txt")
|
|
|
|
if self.charging_mode == false and self.screen_saver_mode == false then
|
|
|
|
Screen:saveCurrentBB()
|
2013-02-02 08:37:48 +00:00
|
|
|
--UIManager:show(InfoMessage:new{
|
|
|
|
--text = "Going into USB mode... ",
|
|
|
|
--timeout = 2,
|
|
|
|
--})
|
2013-02-02 06:36:29 +00:00
|
|
|
--util.sleep(1)
|
|
|
|
--os.execute("killall -cont cvm")
|
2012-06-13 17:52:08 +00:00
|
|
|
end
|
|
|
|
self.charging_mode = true
|
|
|
|
end
|
|
|
|
|
|
|
|
function Device:usbPlugOut()
|
|
|
|
--os.execute("echo 'usb out' >> /mnt/us/event_test.txt")
|
|
|
|
if self.charging_mode == true and self.screen_saver_mode == false then
|
2013-02-02 06:36:29 +00:00
|
|
|
--util.usleep(1500000)
|
|
|
|
--os.execute("killall -stop cvm")
|
2012-06-13 17:52:08 +00:00
|
|
|
Screen:restoreFromSavedBB()
|
2013-02-02 06:36:29 +00:00
|
|
|
Screen:refresh(0)
|
2012-06-13 17:52:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--@TODO signal filemanager for file changes 13.06 2012 (houqp)
|
|
|
|
self.charging_mode = false
|
|
|
|
end
|