From 939fcf7f0e678143c0d64f9280c809f6c518d8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Fern=C3=A1ndez?= <975883+pazos@users.noreply.github.com> Date: Mon, 10 May 2021 20:36:22 +0200 Subject: [PATCH] android: avoid downloading the APK again if there's one download in progress + fix signature error (#7657) --- frontend/device/android/device.lua | 2 ++ frontend/device/generic/device.lua | 3 +++ frontend/ui/otamanager.lua | 8 ++++++++ platform/android/luajit-launcher | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/device/android/device.lua b/frontend/device/android/device.lua index a63552757..e20347753 100644 --- a/frontend/device/android/device.lua +++ b/frontend/device/android/device.lua @@ -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 diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index 7a6ea47e3..acd3197ce 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -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, diff --git a/frontend/ui/otamanager.lua b/frontend/ui/otamanager.lua index 31d20f38b..76de33d97 100644 --- a/frontend/ui/otamanager.lua +++ b/frontend/ui/otamanager.lua @@ -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, diff --git a/platform/android/luajit-launcher b/platform/android/luajit-launcher index 77ce2b7e6..76f10d206 160000 --- a/platform/android/luajit-launcher +++ b/platform/android/luajit-launcher @@ -1 +1 @@ -Subproject commit 77ce2b7e63d28d6b1c520764c9104975bfdeeb8f +Subproject commit 76f10d206a8b07924630598667872b0cd7ede64c