mirror of
https://github.com/koreader/koreader
synced 2024-10-31 21:20:20 +00:00
9bf19d1bb3
* UIManager: Support more specialized update modes for corner-cases: * A2, which we'll use for the VirtualKeyboards keys (they'd... inadvertently switched to UI with the highlight refactor). * NO_MERGE variants of ui & partial (for sunxi). Use `[ui]` in ReaderHighlight's popup, because of a Sage kernel bug that could otherwise make it translucent, sometimes completely so (*sigh*). * UIManager: Assorted code cleanups & simplifications. * Logger & dbg: Unify logging style, and code cleanups. * SDL: Unbreak suspend/resume outside of the emulator (fix #9567). * NetworkMgr: Cache the network status, and allow it to be queried. (Used by AutoSuspend to avoid repeatedly poking the system when computing the standby schedule delay). * OneTimeMigration: Don't forget about `NETWORK_PROXY` & `STARDICT_DATA_DIR` when migrating `defaults.persistent.lua` (fix #9573) * WakeupMgr: Workaround an apparent limitation of the RTC found on i.MX5 Kobo devices, where setting a wakealarm further than UINT16_MAX seconds in the future would apparently overflow and wraparound... (fix #8039, many thanks to @yfede for the extensive deep-dive and for actually accurately pinpointing the issue!). * Kobo: Handle standby transitions at full CPU clock speeds, in order to limit the latency hit. * UIManager: Properly quit on reboot & exit. This ensures our exit code is preserved, as we exit on our own terms (instead of being killed by the init system). This is important on platforms where exit codes are semantically meaningful (e.g., Kobo). * UIManager: Speaking of reboot & exit, make sure the Screensaver shows in all circumstances (e.g., autoshutdown, re: #9542)), and that there aren't any extraneous refreshes triggered. (Additionally, fix a minor regression since #9448 about tracking this very transient state on Kobo & Cervantes). * Kindle: ID the upcoming Scribe. * Bump base (https://github.com/koreader/koreader-base/pull/1524)
141 lines
4.2 KiB
Lua
141 lines
4.2 KiB
Lua
-- Check if we're running a busted version recent enough that we don't need to deal with the LuaJIT hacks...
|
|
-- That currently means > 2.0.0 (i.e., scm-2, which isn't on LuaRocks...).
|
|
local busted_ok = false
|
|
for name, _ in pairs(package.loaded) do
|
|
if name == "busted.luajit" then
|
|
busted_ok = true
|
|
break
|
|
end
|
|
end
|
|
|
|
-- Don't try to overwrite metatables so we can use --auto-insulate-tests
|
|
-- Shamelessly copied from https://github.com/Olivine-Labs/busted/commit/2dfff99bda01fd3da56fd23415aba5a2a4cc0ffd
|
|
if not busted_ok then
|
|
local ffi = require "ffi"
|
|
|
|
local original_metatype = ffi.metatype
|
|
local original_store = {}
|
|
ffi.metatype = function (primary, ...)
|
|
if original_store[primary] then
|
|
return original_store[primary]
|
|
end
|
|
local success, result, err = pcall(original_metatype, primary, ...)
|
|
if not success then
|
|
-- hard error was thrown
|
|
error(result, 2)
|
|
end
|
|
if not result then
|
|
-- soft error was returned
|
|
return result, err
|
|
end
|
|
-- it worked, store and return
|
|
original_store[primary] = result
|
|
return result
|
|
end
|
|
end
|
|
|
|
package.path = "?.lua;common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path
|
|
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath
|
|
|
|
-- turn off debug by default and set log level to warning
|
|
require("dbg"):turnOff()
|
|
local logger = require("logger")
|
|
logger:setLevel(logger.levels.warn)
|
|
|
|
-- global defaults
|
|
local DataStorage = require("datastorage")
|
|
os.remove(DataStorage:getDataDir() .. "/defaults.tests.lua")
|
|
os.remove(DataStorage:getDataDir() .. "/defaults.tests.lua.old")
|
|
G_defaults = require("luadefaults"):open(DataStorage:getDataDir() .. "/defaults.tests.lua")
|
|
|
|
-- global reader settings
|
|
os.remove(DataStorage:getDataDir().."/settings.reader.lua")
|
|
G_reader_settings = require("luasettings"):open(".reader")
|
|
|
|
-- global einkfb for Screen (do not show SDL window)
|
|
einkfb = require("ffi/framebuffer") --luacheck: ignore
|
|
einkfb.dummy = true --luacheck: ignore
|
|
|
|
local Device = require("device")
|
|
|
|
-- init output device
|
|
local Screen = Device.screen
|
|
Screen:init()
|
|
|
|
local CanvasContext = require("document/canvascontext")
|
|
CanvasContext:init(Device)
|
|
|
|
-- init input device (do not show SDL window)
|
|
local Input = Device.input
|
|
Input.dummy = true
|
|
|
|
package.unload = function(module)
|
|
if type(module) ~= "string" then return false end
|
|
package.loaded[module] = nil
|
|
_G[module] = nil
|
|
return true
|
|
end
|
|
|
|
package.replace = function(name, module)
|
|
if type(name) ~= "string" then return false end
|
|
assert(package.unload(name))
|
|
package.loaded[name] = module
|
|
return true
|
|
end
|
|
|
|
package.reload = function(name)
|
|
if type(name) ~= "string" then return false end
|
|
assert(package.unload(name))
|
|
return require(name)
|
|
end
|
|
|
|
package.unloadAll = function()
|
|
local candidates = {
|
|
"spec/",
|
|
"frontend/",
|
|
"plugins/",
|
|
"datastorage.lua",
|
|
"defaults.lua",
|
|
}
|
|
local pending = {}
|
|
for name, _ in pairs(package.loaded) do
|
|
local path = package.searchpath(name, package.path)
|
|
if path ~= nil then
|
|
for _, candidate in ipairs(candidates) do
|
|
if path:find(candidate) == 1 then
|
|
table.insert(pending, name)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
for _, name in ipairs(pending) do
|
|
if name ~= "commonrequire" then
|
|
assert(package.unload(name))
|
|
end
|
|
end
|
|
return #pending
|
|
end
|
|
|
|
local background_runner
|
|
requireBackgroundRunner = function()
|
|
require("pluginshare").stopBackgroundRunner = nil
|
|
if background_runner == nil then
|
|
local package_path = package.path
|
|
package.path = "plugins/backgroundrunner.koplugin/?.lua;" .. package.path
|
|
background_runner = dofile("plugins/backgroundrunner.koplugin/main.lua")
|
|
package.path = package_path
|
|
end
|
|
return background_runner
|
|
end
|
|
|
|
stopBackgroundRunner = function()
|
|
background_runner = nil
|
|
require("pluginshare").stopBackgroundRunner = true
|
|
end
|
|
|
|
notifyBackgroundJobsUpdated = function()
|
|
if background_runner then
|
|
background_runner:onBackgroundJobsUpdated()
|
|
end
|
|
end
|