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-02-21 07:26:48 +00:00
function OTAManager : getOTAType ( )
2024-06-25 19:35:38 +00:00
local platform , kind = Device : otaModel ( )
if not platform then return " none " end
return kind
2019-02-21 07:26:48 +00:00
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
2024-06-25 19:35:38 +00:00
function OTAManager : getFilename ( kind )
if type ( kind ) ~= " string " then return end
local model = Device : otaModel ( )
local channel = self : getOTAChannel ( )
if kind == " ota " then
return self.zsync_template : format ( model , channel )
elseif kind == " link " then
return self.link_template : format ( model , channel )
end
2014-08-01 04:36:32 +00:00
end
2024-06-29 06:06:46 +00:00
function OTAManager : getZsyncFilename ( )
return self : getFilename ( " ota " )
end
2014-08-01 04:36:32 +00:00
function OTAManager : checkUpdate ( )
2023-07-04 20:58:40 +00:00
if Device : isDeprecated ( ) then return - 1 end
2014-08-01 04:36:32 +00:00
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
2024-06-25 19:35:38 +00:00
local update_kind = self : getOTAType ( )
if not update_kind then return - 1 end
local update_file = self : getFilename ( update_kind )
if not update_file then return - 2 end
2019-02-21 07:26:48 +00:00
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 ( )
2022-09-16 22:08:00 +00:00
local code , headers , status = socket.skip ( 1 , http.request {
2021-03-15 00:25:10 +00:00
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 " )
2022-09-16 22:08:00 +00:00
logger.dbg ( " Response headers: " , headers )
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
} )
2023-07-04 20:58:40 +00:00
elseif ota_version == - 1 then
UIManager : show ( InfoMessage : new {
text = T ( _ ( " Device no longer supported. \n \n Please check %1 " ) , " https://github.com/koreader/koreader/wiki/deprecated-devices " )
} )
2024-06-25 19:35:38 +00:00
elseif ota_version == - 2 then
UIManager : show ( InfoMessage : new {
text = _ ( " Unable to determine OTA model. " )
} )
2014-08-26 19:21:18 +00:00
elseif ota_version == nil then
UIManager : show ( InfoMessage : new {
2024-01-12 18:00:55 +00:00
text = _ ( " Unable to contact OTA server. Try again later, or try another mirror. " ) ,
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
2022-10-10 20:21:27 +00:00
blocks = tarball_size * ( 1 / ( 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 ;).
2022-10-10 20:21:27 +00:00
local cpoints = blocks * ( 1 / 100 )
2019-02-21 07:26:48 +00:00
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 ( )
2022-05-08 20:17:58 +00:00
local working_im = InfoMessage : new {
alignment = " center " ,
show_icon = false ,
text = " ⌛ " ,
}
UIManager : show ( working_im )
UIManager : forceRePaint ( )
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
2022-05-08 20:17:58 +00:00
UIManager : close ( working_im )
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