[plugin] Add a caching mechanism for CoverImage (#7510)

This commit is contained in:
zwim
2021-04-22 08:38:49 +02:00
committed by GitHub
parent 85085b545a
commit e4c9409f97
5 changed files with 591 additions and 307 deletions

View File

@@ -392,7 +392,20 @@ function Device:canExecuteScript(file)
end
function Device:isValidPath(path)
return android.isPathInsideSandbox(path)
-- the fast check
if android.isPathInsideSandbox(path) then
return true
end
-- the thorough check
local real_ext_storage = FFIUtil.realpath(android.getExternalStoragePath())
local real_path = FFIUtil.realpath(path)
if real_path then
return real_path:sub(1, #real_ext_storage) == real_ext_storage
else
return false
end
end
function Device:showLightDialog()
@@ -432,6 +445,15 @@ function Device:untar(archive, extract_to)
return android.untar(archive, extract_to)
end
-- todo: Wouldn't we like an android.deviceIdentifier() method, so we can use better default paths?
function Device:getDefaultCoverPath()
if android.prop.product == "ntx_6sl" then -- Tolino HD4 and other
return android.getExternalStoragePath() .. "/suspend_others.jpg"
else
return android.getExternalStoragePath() .. "/cover.jpg"
end
end
android.LOGI(string.format("Android %s - %s (API %d) - flavor: %s",
android.prop.version, getCodename(), Device.firmware_rev, android.prop.flavor))