2019-08-23 17:53:53 +00:00
--[[--
Checks for updates on the specified nightly build server .
] ]
2020-01-04 00:18:51 +00:00
local BD = require ( " ui/bidi " )
2014-08-01 13:59:59 +00:00
local ConfirmBox = require ( " ui/widget/confirmbox " )
2015-10-03 06:18:47 +00:00
local DataStorage = require ( " datastorage " )
2014-10-30 18:42:18 +00:00
local Device = require ( " device " )
2017-04-06 13:11:21 +00:00
local InfoMessage = require ( " ui/widget/infomessage " )
2019-01-01 19:06:55 +00:00
local MultiConfirmBox = require ( " ui/widget/multiconfirmbox " )
2017-04-06 13:11:21 +00:00
local NetworkMgr = require ( " ui/network/manager " )
local UIManager = require ( " ui/uimanager " )
2017-04-15 12:45:56 +00:00
local Version = require ( " version " )
2017-04-06 13:11:21 +00:00
local lfs = require ( " libs/libkoreader-lfs " )
2016-12-29 08:10:38 +00:00
local logger = require ( " logger " )
2014-08-01 13:59:59 +00:00
local _ = require ( " gettext " )
2021-12-06 12:07:06 +00:00
local C_ = _.pgettext
2017-04-06 13:11:21 +00:00
local T = require ( " ffi/util " ) . template
2014-08-01 04:36:32 +00:00
2015-10-03 06:18:47 +00:00
local ota_dir = DataStorage : getDataDir ( ) .. " /ota/ "
2014-08-01 04:36:32 +00:00
local OTAManager = {
2020-02-04 02:14:23 +00:00
-- NOTE: Each URL *MUST* end with a /
2014-08-06 12:28:09 +00:00
ota_servers = {
2020-02-04 02:14:23 +00:00
" http://ota.koreader.rocks/ " ,
2018-07-03 21:16:45 +00:00
--[[
2020-02-04 02:14:23 +00:00
-- NOTE: Seems down? Ping @chrox ;).
" http://vislab.bjmu.edu.cn/apps/koreader/ota/ " ,
2018-07-03 21:16:45 +00:00
--]]
2020-02-04 02:14:23 +00:00
" http://koreader-fr.ak-team.com/ " ,
" http://koreader-pl.ak-team.com/ " ,
" http://koreader-na.ak-team.com/ " ,
" http://koreader.ak-team.com/ " ,
2014-08-06 12:28:09 +00:00
} ,
ota_channels = {
2015-02-01 09:24:50 +00:00
" stable " ,
2014-08-06 12:28:09 +00:00
" nightly " ,
} ,
2019-02-21 07:26:48 +00:00
link_template = " koreader-%s-latest-%s " ,
2014-08-01 04:36:32 +00:00
zsync_template = " koreader-%s-latest-%s.zsync " ,
2016-03-13 15:42:58 +00:00
installed_package = ota_dir .. " koreader.installed.tar " ,
2014-08-01 04:36:32 +00:00
package_indexfile = " ota/package.index " ,
2016-03-13 15:42:58 +00:00
updated_package = ota_dir .. " koreader.updated.tar " ,
2018-09-05 23:35:48 +00:00
can_pretty_print = lfs.attributes ( " ./fbink " , " mode " ) == " file " and true or false ,
2014-08-01 04:36:32 +00:00
}
2015-02-01 09:24:50 +00:00
local ota_channels = {
2016-12-14 19:08:57 +00:00
stable = _ ( " Stable " ) ,
nightly = _ ( " Development " ) ,
2015-02-01 09:24:50 +00:00
}
2019-01-20 18:08:44 +00:00
-- Try to detect WARIO+ Kindle boards (i.MX6 & i.MX7)
function OTAManager : _isKindleWarioOrMore ( )
local cpu_hw = nil
-- Parse cpuinfo line by line, until we find the Hardware description
for line in io.lines ( " /proc/cpuinfo " ) do
if line : find ( " ^Hardware " ) then
cpu_hw = line : match ( " ^Hardware%s*:%s([%g%s]*)$ " )
end
end
-- NOTE: I couldn't dig up a cpuinfo dump from an Oasis 2 to check the CPU part value,
-- but for Wario (Cortex A9), matching that to 0xc09 would work, too.
-- On the other hand, I'm already using the Hardware match in MRPI, so, that sealed the deal ;).
-- If we've got a Hardware string, check if it mentions an i.MX 6 or 7...
if cpu_hw then
2019-02-01 14:37:15 +00:00
if cpu_hw : find ( " i.MX%s?[6-7] " ) then
2019-01-20 18:08:44 +00:00
return true
else
return false
end
else
return false
end
end
2018-12-15 09:23:51 +00:00
-- "x86", "x64", "arm", "arm64", "ppc", "mips" or "mips64".
local arch = jit.arch
2014-08-01 04:36:32 +00:00
function OTAManager : getOTAModel ( )
2018-10-31 22:48:36 +00:00
if Device : isAndroid ( ) then
2018-12-15 09:23:51 +00:00
if arch == " x86 " then
return " android-x86 "
end
2018-10-31 22:48:36 +00:00
return " android "
2019-02-21 07:26:48 +00:00
elseif Device : isSDL ( ) then
return " appimage "
2018-10-31 22:48:36 +00:00
elseif Device : isCervantes ( ) then
return " cervantes "
elseif Device : isKindle ( ) then
2019-01-20 18:11:20 +00:00
if Device : isTouchDevice ( ) or Device.model == " Kindle4 " then
2019-01-20 18:08:44 +00:00
if self : _isKindleWarioOrMore ( ) then
return " kindlepw2 "
else
return " kindle "
end
2016-11-08 05:43:10 +00:00
else
return " kindle-legacy "
end
2014-08-01 04:36:32 +00:00
elseif Device : isKobo ( ) then
return " kobo "
2015-01-19 16:07:36 +00:00
elseif Device : isPocketBook ( ) then
return " pocketbook "
2020-02-08 00:58:10 +00:00
elseif Device : isRemarkable ( ) then
return " remarkable "
2018-10-06 05:55:35 +00:00
elseif Device : isSonyPRSTUX ( ) then
return " sony-prstux "
2014-08-01 04:36:32 +00:00
else
return " "
end
end
2019-02-21 07:26:48 +00:00
function OTAManager : getOTAType ( )
local ota_model = self : getOTAModel ( )
if ota_model == " " then return end
if ota_model : find ( " android " ) or ota_model : find ( " appimage " ) then
return " link "
end
return " ota "
end
2014-08-06 12:28:09 +00:00
function OTAManager : getOTAServer ( )
return G_reader_settings : readSetting ( " ota_server " ) or self.ota_servers [ 1 ]
end
function OTAManager : setOTAServer ( server )
2016-12-29 08:10:38 +00:00
logger.dbg ( " Set OTA server: " , server )
2014-08-06 12:28:09 +00:00
G_reader_settings : saveSetting ( " ota_server " , server )
end
2014-08-01 04:36:32 +00:00
function OTAManager : getOTAChannel ( )
2014-08-06 12:28:09 +00:00
return G_reader_settings : readSetting ( " ota_channel " ) or self.ota_channels [ 1 ]
2014-08-01 04:36:32 +00:00
end
function OTAManager : setOTAChannel ( channel )
2016-12-29 08:10:38 +00:00
logger.dbg ( " Set OTA channel: " , channel )
2014-08-06 12:28:09 +00:00
G_reader_settings : saveSetting ( " ota_channel " , channel )
2014-08-01 04:36:32 +00:00
end
2019-02-21 07:26:48 +00:00
function OTAManager : getLinkFilename ( )
return self.link_template : format ( self : getOTAModel ( ) , self : getOTAChannel ( ) )
end
2014-08-01 04:36:32 +00:00
function OTAManager : getZsyncFilename ( )
return self.zsync_template : format ( self : getOTAModel ( ) , self : getOTAChannel ( ) )
end
function OTAManager : checkUpdate ( )
local http = require ( " socket.http " )
local ltn12 = require ( " ltn12 " )
2021-03-15 00:25:10 +00:00
local socket = require ( " socket " )
local socketutil = require ( " socketutil " )
2014-08-01 04:36:32 +00:00
2019-02-21 07:26:48 +00:00
local update_file = ( self : getOTAType ( ) == " link " ) and self : getLinkFilename ( ) or self : getZsyncFilename ( )
local ota_update_file = self : getOTAServer ( ) .. update_file
local local_update_file = ota_dir .. update_file
2014-08-01 04:36:32 +00:00
-- download zsync file from OTA server
2019-02-21 07:26:48 +00:00
logger.dbg ( " downloading update file " , ota_update_file )
2021-03-15 00:25:10 +00:00
socketutil : set_timeout ( )
local code , _ , status = socket.skip ( 1 , http.request {
url = ota_update_file ,
sink = ltn12.sink . file ( io.open ( local_update_file , " w " ) ) ,
} )
socketutil : reset_timeout ( )
if code ~= 200 then
logger.warn ( " cannot find update file: " , status or code or " network unreachable " )
2015-02-01 09:24:50 +00:00
return
end
2014-08-20 07:46:43 +00:00
-- parse OTA package version
2019-02-21 07:26:48 +00:00
local link , ota_package
local update_info = io.open ( local_update_file , " r " )
if update_info then
if OTAManager : getOTAType ( ) == " link " then
local i = 0
for line in update_info : lines ( ) do
i = i + 1
if i == 1 then
ota_package = line
link = self : getOTAServer ( ) .. ota_package
end
end
else
for line in update_info : lines ( ) do
ota_package = line : match ( " ^Filename:%s*(.-)%s*$ " )
if ota_package then break end
end
2014-08-01 04:36:32 +00:00
end
2019-02-21 07:26:48 +00:00
update_info : close ( )
2014-08-01 04:36:32 +00:00
end
2014-11-10 12:21:25 +00:00
local local_ok , local_version = pcall ( function ( )
2017-04-15 12:45:56 +00:00
local rev = Version : getCurrentRevision ( )
if rev then return Version : getNormalizedVersion ( rev ) end
2014-11-10 12:21:25 +00:00
end )
local ota_ok , ota_version = pcall ( function ( )
2017-04-15 12:45:56 +00:00
return Version : getNormalizedVersion ( ota_package )
2014-11-10 12:21:25 +00:00
end )
2014-08-01 04:36:32 +00:00
-- return ota package version if package on OTA server has version
-- larger than the local package version
2014-11-10 12:21:25 +00:00
if local_ok and ota_ok and ota_version and local_version and
2015-02-01 09:24:50 +00:00
ota_version ~= local_version then
2019-02-23 13:25:29 +00:00
return ota_version , local_version , link , ota_package
2014-08-01 04:36:32 +00:00
elseif ota_version and ota_version == local_version then
return 0
end
end
2014-08-26 19:21:18 +00:00
function OTAManager : fetchAndProcessUpdate ( )
2021-05-10 18:36:22 +00:00
if Device : hasOTARunning ( ) then
UIManager : show ( InfoMessage : new {
text = _ ( " Download already scheduled. You'll be notified when it's ready. " ) ,
} )
return
end
2019-02-23 13:25:29 +00:00
local ota_version , local_version , link , ota_package = OTAManager : checkUpdate ( )
2019-02-21 07:26:48 +00:00
2014-08-26 19:21:18 +00:00
if ota_version == 0 then
UIManager : show ( InfoMessage : new {
2017-04-06 13:11:21 +00:00
text = _ ( " KOReader is up to date. " ) ,
2014-08-26 19:21:18 +00:00
} )
elseif ota_version == nil then
2015-04-15 05:38:01 +00:00
local channel = ota_channels [ OTAManager : getOTAChannel ( ) ]
2014-08-26 19:21:18 +00:00
UIManager : show ( InfoMessage : new {
2019-02-21 07:26:48 +00:00
text = T ( _ ( " Update information not available on %1 channel. " ) , channel ) ,
2014-08-26 19:21:18 +00:00
} )
elseif ota_version then
2019-02-25 21:50:01 +00:00
local update_message = T ( _ ( " Do you want to update? \n Installed version: %1 \n Available version: %2 " ) ,
2020-01-04 00:18:51 +00:00
BD.ltr ( local_version ) ,
BD.ltr ( ota_version ) )
2021-12-06 12:07:06 +00:00
local update_ok_text = C_ ( " Application update | Button " , " Update " )
2019-02-25 21:50:01 +00:00
if ota_version < local_version then
2021-05-16 13:19:32 +00:00
-- Android cannot downgrade APKs. The user needs to uninstall current app first.
-- Instead of doing the auto-update when ready we just download the APK using the browser.
if Device : isAndroid ( ) then
UIManager : show ( ConfirmBox : new {
text = T ( _ ( " The currently installed version is newer than the available version. \n You'll need to uninstall the app before installing a previous version. \n Download anyway? \n \n Installed version: %1 \n Available version: %2 " ) ,
BD.ltr ( local_version ) ,
BD.ltr ( ota_version ) ) ,
ok_text = _ ( " Download " ) ,
ok_callback = function ( )
Device : openLink ( link )
end ,
} )
return
end
2019-02-25 21:50:01 +00:00
update_message = T ( _ ( " The currently installed version is newer than the available version. \n Would you still like to continue and downgrade? \n Installed version: %1 \n Available version: %2 " ) ,
2020-01-04 00:18:51 +00:00
BD.ltr ( local_version ) ,
BD.ltr ( ota_version ) )
2019-02-25 21:50:01 +00:00
update_ok_text = _ ( " Downgrade " )
end
2021-05-08 21:02:35 +00:00
local wait_for_download = _ ( " Downloading may take several minutes… " )
2019-02-21 07:26:48 +00:00
if OTAManager : getOTAType ( ) == " link " then
UIManager : show ( ConfirmBox : new {
2019-02-25 21:50:01 +00:00
text = update_message ,
ok_text = update_ok_text ,
2019-02-21 07:26:48 +00:00
ok_callback = function ( )
2021-05-15 23:27:14 +00:00
if Device : isAndroid ( ) then
Device : download ( link , ota_package , wait_for_download )
2019-02-23 13:25:29 +00:00
elseif Device : isSDL ( ) then
2019-03-20 15:58:32 +00:00
Device : openLink ( link )
2014-08-26 19:21:18 +00:00
end
2019-02-21 07:26:48 +00:00
end
} )
else
UIManager : show ( ConfirmBox : new {
2019-02-25 21:50:01 +00:00
text = update_message ,
ok_text = update_ok_text ,
2019-02-21 07:26:48 +00:00
ok_callback = function ( )
UIManager : show ( InfoMessage : new {
2021-05-08 21:02:35 +00:00
text = wait_for_download ,
2019-02-21 07:26:48 +00:00
timeout = 3 ,
} )
UIManager : scheduleIn ( 1 , function ( )
if OTAManager : zsync ( ) == 0 then
2021-05-08 21:02:35 +00:00
Device : install ( )
2019-02-21 07:26:48 +00:00
-- Make it clear that zsync is done
if self.can_pretty_print then
os.execute ( " ./fbink -q -y -7 -pm ' ' ' ' " )
end
else
-- Make it clear that zsync is done
if self.can_pretty_print then
os.execute ( " ./fbink -q -y -7 -pm ' ' ' ' " )
end
UIManager : show ( MultiConfirmBox : new {
text = _ ( " Failed to update KOReader. \n \n You can: \n Cancel, keeping temporary files. \n Retry the update process with a full download. \n Abort and cleanup all temporary files. " ) ,
choice1_text = _ ( " Retry " ) ,
choice1_callback = function ( )
UIManager : show ( InfoMessage : new {
text = _ ( " Downloading may take several minutes… " ) ,
timeout = 3 ,
} )
-- Clear the installed package, as well as the complete/incomplete update download
2020-02-09 04:08:46 +00:00
os.execute ( " rm -f " .. self.installed_package )
os.execute ( " rm -f " .. self.updated_package .. " * " )
-- As well as temporary files, in case zsync went kablooey too early...
os.execute ( " rm -f ./rcksum-* " )
2019-02-21 07:26:48 +00:00
-- And then relaunch zsync in full download mode...
UIManager : scheduleIn ( 1 , function ( )
if OTAManager : zsync ( true ) == 0 then
2021-05-08 21:02:35 +00:00
Device : install ( )
2019-02-21 07:26:48 +00:00
-- Make it clear that zsync is done
if self.can_pretty_print then
os.execute ( " ./fbink -q -y -7 -pm ' ' ' ' " )
end
else
-- Make it clear that zsync is done
if self.can_pretty_print then
os.execute ( " ./fbink -q -y -7 -pm ' ' ' ' " )
end
UIManager : show ( ConfirmBox : new {
text = _ ( " Error updating KOReader. Would you like to delete temporary files? " ) ,
ok_callback = function ( )
2020-02-09 04:08:46 +00:00
os.execute ( " rm -f " .. ota_dir .. " ko* " )
2019-02-21 07:26:48 +00:00
end ,
} )
end
end )
end ,
choice2_text = _ ( " Abort " ) ,
choice2_callback = function ( )
2020-02-09 04:08:46 +00:00
os.execute ( " rm -f " .. ota_dir .. " ko* " )
os.execute ( " rm -f " .. self.updated_package .. " * " )
os.execute ( " rm -f ./rcksum-* " )
2019-02-21 07:26:48 +00:00
end ,
} )
end
end )
end
} )
end
2014-08-26 19:21:18 +00:00
end
end
2019-08-23 17:53:53 +00:00
---- Uses zsync and tar to prepare an update package.
2014-08-01 04:36:32 +00:00
function OTAManager : _buildLocalPackage ( )
2019-08-23 17:53:53 +00:00
--- @todo Validate the installed package?
2016-03-13 15:42:58 +00:00
local installed_package = self.installed_package
2014-10-14 05:04:49 +00:00
if lfs.attributes ( installed_package , " mode " ) == " file " then
return 0
end
2017-04-23 02:10:48 +00:00
if lfs.attributes ( self.package_indexfile , " mode " ) ~= " file " then
logger.err ( " Missing ota metadata: " , self.package_indexfile )
return nil
end
2019-02-21 07:26:48 +00:00
-- With visual feedback if supported...
if self.can_pretty_print then
os.execute ( " ./fbink -q -y -7 -pmh 'Preparing local OTA package' " )
-- We need a vague idea of how much space the tarball we're creating will take to compute a proper percentage...
-- Get the size from the latest zsync package, which'll be a closer match than anything else we might come up with.
local update_file = self : getZsyncFilename ( )
local local_update_file = ota_dir .. update_file
local tarball_size = nil
local zsync = io.open ( local_update_file , " r " )
if zsync then
for line in zsync : lines ( ) do
tarball_size = line : match ( " ^Length: (%d*)$ " )
if tarball_size then break end
2018-09-05 23:35:48 +00:00
end
2019-02-21 07:26:48 +00:00
zsync : close ( )
end
-- Next, we need to compute the amount of tar blocks that'll take, knowing that tar's default blocksize is 20 * 512 bytes.
-- c.f., https://superuser.com/questions/168749 & http://www.noah.org/wiki/tar_notes
-- Defaults to a sane-ish value as-of now, in case shit happens...
local blocks = 6405
if tarball_size then
blocks = tarball_size / ( 512 * 20 )
2018-07-03 21:16:45 +00:00
end
2019-02-21 07:26:48 +00:00
-- And since we want a percentage, devise the exact value we need for tar to spit out exactly 100 checkpoints ;).
local cpoints = blocks / 100
return os.execute ( string.format (
" ./tar --no-recursion -cf %s -C .. -T %s --checkpoint=%d --checkpoint-action=exec='./fbink -q -y -6 -P $(($TAR_CHECKPOINT/%d))' " ,
self.installed_package , self.package_indexfile , cpoints , cpoints ) )
else
return os.execute ( string.format (
" ./tar --no-recursion -cf %s -C .. -T %s " ,
self.installed_package , self.package_indexfile ) )
2016-03-13 15:42:58 +00:00
end
2014-08-01 04:36:32 +00:00
end
2019-01-01 19:06:55 +00:00
function OTAManager : zsync ( full_dl )
if full_dl or self : _buildLocalPackage ( ) == 0 then
2020-02-04 02:14:23 +00:00
local zsync_wrapper = " zsync2 "
2020-02-11 23:07:05 +00:00
local use_pipefail = true
2018-09-05 23:35:48 +00:00
-- With visual feedback if supported...
if self.can_pretty_print then
zsync_wrapper = " spinning_zsync "
2020-02-11 23:07:05 +00:00
-- And because everything is terrible, we can't check for pipefail's usability in spinning_zsync,
-- because older ash versions abort on set -o failures...
-- c.f., ko/#5844
-- So, instead, check from this side of the fence...
-- (remember, os.execute is essentially system(), it goes through sh)
use_pipefail = ( os.execute ( " set -o pipefail 2>/dev/null " ) == 0 )
2018-07-03 21:16:45 +00:00
end
2019-01-01 19:06:55 +00:00
-- If that's a full-download fallback, drop the input tarball
if full_dl then
return os.execute (
2020-02-11 23:07:05 +00:00
( " env WITH_PIPEFAIL='%s' ./%s -o '%s' -u '%s' '%s%s' " ) : format (
use_pipefail ,
2019-01-01 19:06:55 +00:00
zsync_wrapper ,
self.updated_package ,
self : getOTAServer ( ) ,
ota_dir ,
self : getZsyncFilename ( ) )
)
else
return os.execute (
2020-02-11 23:07:05 +00:00
( " env WITH_PIPEFAIL='%s' ./%s -i '%s' -o '%s' -u '%s' '%s%s' " ) : format (
use_pipefail ,
2019-01-01 19:06:55 +00:00
zsync_wrapper ,
self.installed_package ,
self.updated_package ,
self : getOTAServer ( ) ,
ota_dir ,
self : getZsyncFilename ( ) )
)
end
2014-08-01 04:36:32 +00:00
end
end
2014-08-06 12:28:09 +00:00
function OTAManager : genServerList ( )
local servers = { }
for _ , server in ipairs ( self.ota_servers ) do
local server_item = {
text = server ,
checked_func = function ( ) return self : getOTAServer ( ) == server end ,
callback = function ( ) self : setOTAServer ( server ) end
}
table.insert ( servers , server_item )
end
return servers
end
function OTAManager : genChannelList ( )
local channels = { }
for _ , channel in ipairs ( self.ota_channels ) do
local channel_item = {
2015-02-01 09:24:50 +00:00
text = ota_channels [ channel ] ,
2014-08-06 12:28:09 +00:00
checked_func = function ( ) return self : getOTAChannel ( ) == channel end ,
callback = function ( ) self : setOTAChannel ( channel ) end
}
table.insert ( channels , channel_item )
end
return channels
end
2014-08-01 14:23:08 +00:00
function OTAManager : getOTAMenuTable ( )
2014-08-01 13:59:59 +00:00
return {
2021-12-06 12:07:06 +00:00
text = C_ ( " Application update | Menu " , " Update " ) ,
2019-02-21 07:26:48 +00:00
hold_callback = function ( )
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
local connect_callback = function ( )
2019-02-21 07:26:48 +00:00
OTAManager : fetchAndProcessUpdate ( )
end
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
NetworkMgr : runWhenOnline ( connect_callback )
2019-02-21 07:26:48 +00:00
end ,
2014-08-06 12:28:09 +00:00
sub_item_table = {
{
2021-07-25 19:04:13 +00:00
text = _ ( " Check for updates " ) ,
2014-08-06 12:28:09 +00:00
callback = function ( )
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
local connect_callback = function ( )
2015-04-15 05:38:01 +00:00
OTAManager : fetchAndProcessUpdate ( )
2014-08-01 13:59:59 +00:00
end
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
NetworkMgr : runWhenOnline ( connect_callback )
2014-08-06 12:28:09 +00:00
end
} ,
{
text = _ ( " Settings " ) ,
sub_item_table = {
{
2019-02-21 07:26:48 +00:00
text = _ ( " Update server " ) ,
2014-08-06 12:28:09 +00:00
sub_item_table = self : genServerList ( )
} ,
{
2019-02-21 07:26:48 +00:00
text = _ ( " Update channel " ) ,
2014-08-06 12:28:09 +00:00
sub_item_table = self : genChannelList ( )
} ,
}
} ,
}
2014-08-01 13:59:59 +00:00
}
end
2014-08-01 04:36:32 +00:00
return OTAManager