move android specific bits outside OTAManager

pull/7700/head
Martín Fdez 3 years ago committed by Martín Fernández
parent 4b265bcd7a
commit 23b7bfe0ce

@ -461,6 +461,28 @@ function Device:untar(archive, extract_to)
return android.untar(archive, extract_to)
end
function Device:download(link, name, ok_text)
local UIManager = require("ui/uimanager")
local ConfirmBox = require("ui/widget/confirmbox")
local InfoMessage = require("ui/widget/infomessage")
local ok = android.download(link, name)
if ok == C.ADOWNLOAD_EXISTS then
self:install()
elseif ok == C.ADOWNLOAD_OK then
android.ota.isRunning = true
UIManager:show(InfoMessage:new{
text = ok_text,
timeout = 3,
})
elseif ok == C.ADOWNLOAD_FAILED then
UIManager:show(ConfirmBox:new{
text = _("Your device seems to be unable to download packages.\nRetry using the browser?"),
ok_text = _("Retry"),
ok_callback = function() self:openLink(link) end,
})
end
end
function Device:install()
local UIManager = require("ui/uimanager")
local ConfirmBox = require("ui/widget/confirmbox")

@ -245,27 +245,8 @@ function OTAManager:fetchAndProcessUpdate()
text = update_message,
ok_text = update_ok_text,
ok_callback = function()
local isAndroid, android = pcall(require, "android")
if isAndroid then
local ffi = require("ffi")
local C = ffi.C
-- try to download the package
local ok = android.download(link, ota_package)
if ok == C.ADOWNLOAD_EXISTS then
Device:install()
elseif ok == C.ADOWNLOAD_OK then
android.ota.isRunning = true
UIManager:show(InfoMessage:new{
text = wait_for_download,
timeout = 3,
})
elseif ok == C.ADOWNLOAD_FAILED then
UIManager:show(ConfirmBox:new{
text = _("Your device seems to be unable to download packages.\nRetry using the browser?"),
ok_text = _("Retry"),
ok_callback = function() Device:openLink(link) end,
})
end
if Device:isAndroid() then
Device:download(link, ota_package, wait_for_download)
elseif Device:isSDL() then
Device:openLink(link)
end

Loading…
Cancel
Save