2014-10-30 18:42:18 +00:00
|
|
|
local isAndroid, android = pcall(require, "android")
|
|
|
|
local util = require("ffi/util")
|
|
|
|
|
|
|
|
local function probeDevice()
|
|
|
|
if util.isEmulated() then
|
|
|
|
return require("device/emulator/device")
|
|
|
|
end
|
|
|
|
|
|
|
|
if isAndroid then
|
|
|
|
return require("device/android/device")
|
|
|
|
end
|
|
|
|
|
|
|
|
local kindle_sn = io.open("/proc/usid", "r")
|
|
|
|
if kindle_sn then
|
|
|
|
kindle_sn:close()
|
|
|
|
return require("device/kindle/device")
|
|
|
|
end
|
|
|
|
|
|
|
|
local kg_test_fd = lfs.attributes("/bin/kobo_config.sh")
|
|
|
|
if kg_test_fd then
|
|
|
|
return require("device/kobo/device")
|
|
|
|
end
|
|
|
|
|
2015-01-09 14:10:25 +00:00
|
|
|
local pbook_test_fd = lfs.attributes("/ebrmain")
|
|
|
|
if pbook_test_fd then
|
|
|
|
return require("device/pocketbook/device")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- add new ports here:
|
|
|
|
if --[[ implement a proper test instead --]] false then
|
|
|
|
return require("device/newport/device")
|
|
|
|
end
|
|
|
|
|
2014-10-30 18:42:18 +00:00
|
|
|
error("did not find a hardware abstraction for this platform")
|
|
|
|
end
|
|
|
|
|
|
|
|
local dev = probeDevice()
|
|
|
|
dev:init()
|
|
|
|
return dev
|