android: avoid downloading the APK again if there's one download in progress + fix signature error (#7657)

This commit is contained in:
Martín Fernández
2021-05-10 20:36:22 +02:00
committed by GitHub
parent 247166b3df
commit 939fcf7f0e
4 changed files with 14 additions and 1 deletions

View File

@@ -85,6 +85,7 @@ local Device = Generic:new{
isHapticFeedbackEnabled = yes,
hasClipboard = yes,
hasOTAUpdates = android.ota.isEnabled,
hasOTARunning = function() return android.ota.isRunning end,
hasFastWifiStatusQuery = yes,
hasSystemFonts = yes,
canOpenLink = yes,
@@ -216,6 +217,7 @@ function Device:init()
local Event = require("ui/event")
UIManager:broadcastEvent(Event:new("NotCharging"))
elseif ev.code == C.AEVENT_DOWNLOAD_COMPLETE then
android.ota.isRunning = false
if android.isResumed() then
self:install()
else

View File

@@ -103,6 +103,9 @@ local Device = {
-- set to yes on devices that support over-the-air incremental updates.
hasOTAUpdates = no,
-- For devices that have non-blocking OTA updates, this function will return true if the download is currently running.
hasOTARunning = no,
-- set to yes on devices that have a non-blocking isWifiOn implementation
-- (c.f., https://github.com/koreader/koreader/pull/5211#issuecomment-521304139)
hasFastWifiStatusQuery = no,

View File

@@ -208,6 +208,13 @@ function OTAManager:checkUpdate()
end
function OTAManager:fetchAndProcessUpdate()
if Device:hasOTARunning() then
UIManager:show(InfoMessage:new{
text = _("Download already scheduled. You'll be notified when it's ready."),
})
return
end
local ota_version, local_version, link, ota_package = OTAManager:checkUpdate()
if ota_version == 0 then
@@ -247,6 +254,7 @@ function OTAManager:fetchAndProcessUpdate()
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,