2
0
mirror of https://github.com/koreader/koreader synced 2024-11-06 09:20:32 +00:00
koreader/platform/android/llapp_main.lua
chrox a38d851a15 mcode force allocation on Android is now optional
Anyone who encounters random freeze of koreader for Android
is encouraged to enable this by adding a file at
"/sdcard/koreader/patch.lua" with the content of:
```
require("jit.opt").start("sizemcode=256","maxmcode=256")
for i=1,100 do end  -- Force allocation of one large segment
```
The sizemcode and maxmcode could be adjusted from 196 to 512 to
make koreader best fit on your Android device.
2015-03-20 10:15:41 +08:00

32 lines
894 B
Lua

local A = require("android")
A.dl.library_path = A.dl.library_path .. ":" .. A.dir .. "/libs"
-- check uri of the intent that starts this application
local file = A.jni:context(A.app.activity.vm, function(JNI)
local uri = JNI:callObjectMethod(
JNI:callObjectMethod(
A.app.activity.clazz,
"getIntent",
"()Landroid/content/Intent;"
),
"getData",
"()Landroid/net/Uri;"
)
if uri ~= nil then
local path = JNI:callObjectMethod(
uri,
"getPath",
"()Ljava/lang/String;"
)
return JNI:to_string(path)
end
end)
A.LOGI("intent file path " .. (file or ""))
-- run koreader patch before koreader startup
pcall(function() dofile("/sdcard/koreader/patch.lua") end)
-- create fake command-line arguments
arg = {"-d", file or "/sdcard"}
dofile(A.dir.."/reader.lua")