mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Prevent promptWifiOn() needing to be called twice and refactor OTA update fetch/version check
This commit is contained in:
@@ -23,6 +23,7 @@ local function koboEnableWifi(toggle)
|
||||
local path = "/etc/wpa_supplicant/wpa_supplicant.conf"
|
||||
os.execute("insmod /drivers/ntx508/wifi/sdio_wifi_pwr.ko 2>/dev/null")
|
||||
os.execute("insmod /drivers/ntx508/wifi/dhd.ko")
|
||||
os.execute("sleep 1")
|
||||
os.execute("ifconfig eth0 up")
|
||||
os.execute("wlarm_le -i eth0 up")
|
||||
os.execute("wpa_supplicant -s -i eth0 -c "..path.." -C /var/run/wpa_supplicant -B")
|
||||
|
||||
@@ -90,6 +90,36 @@ function OTAManager:checkUpdate()
|
||||
end
|
||||
end
|
||||
|
||||
function OTAManager:fetchAndProcessUpdate()
|
||||
local ota_version = OTAManager:checkUpdate()
|
||||
if ota_version == 0 then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Your koreader is updated."),
|
||||
})
|
||||
elseif ota_version == nil then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("OTA server is not available."),
|
||||
})
|
||||
elseif ota_version then
|
||||
UIManager:show(ConfirmBox:new{
|
||||
text = _("Do you want to update to version ")..ota_version.."?",
|
||||
ok_callback = function()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Downloading may take several minutes..."),
|
||||
timeout = 3,
|
||||
})
|
||||
UIManager:scheduleIn(1, function()
|
||||
if OTAManager:zsync() == 0 then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Koreader will be updated on next restart."),
|
||||
})
|
||||
end
|
||||
end)
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function OTAManager:_buildLocalPackage()
|
||||
return os.execute(string.format(
|
||||
"./tar cvf %s -C .. -T %s --no-recursion",
|
||||
@@ -142,33 +172,7 @@ function OTAManager:getOTAMenuTable()
|
||||
if NetworkMgr:getWifiStatus() == false then
|
||||
NetworkMgr:promptWifiOn()
|
||||
else
|
||||
local ota_version = OTAManager:checkUpdate()
|
||||
if ota_version == 0 then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Your koreader is updated."),
|
||||
})
|
||||
elseif ota_version == nil then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("OTA server is not available."),
|
||||
})
|
||||
elseif ota_version then
|
||||
UIManager:show(ConfirmBox:new{
|
||||
text = _("Do you want to update to version ")..ota_version.."?",
|
||||
ok_callback = function()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Downloading may take several minutes..."),
|
||||
timeout = 3,
|
||||
})
|
||||
UIManager:scheduleIn(1, function()
|
||||
if OTAManager:zsync() == 0 then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Koreader will be updated on next restart."),
|
||||
})
|
||||
end
|
||||
end)
|
||||
end
|
||||
})
|
||||
end
|
||||
OTAManager.fetchAndProcessUpdate()
|
||||
end
|
||||
end
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user