From ff3ca5d98dc913597f59d88f555154f3a73405d6 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Thu, 28 Sep 2017 15:03:04 +0200 Subject: [PATCH] [Android] Enable CoverBrowser (#3264) I was reminded by @KenMaltby that this is disabled on Android. https://www.mobileread.com/forums/showthread.php?p=3586162#post3586162 --- plugins/coverbrowser.koplugin/main.lua | 8 +------ plugins/coverbrowser.koplugin/xutil.lua | 30 ++++++++++--------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/plugins/coverbrowser.koplugin/main.lua b/plugins/coverbrowser.koplugin/main.lua index f3277e0c4..4418533bf 100644 --- a/plugins/coverbrowser.koplugin/main.lua +++ b/plugins/coverbrowser.koplugin/main.lua @@ -1,4 +1,3 @@ -local Device = require("device") local InputContainer = require("ui/widget/container/inputcontainer") local UIManager = require("ui/uimanager") local logger = require("logger") @@ -38,12 +37,7 @@ local CoverBrowser = InputContainer:new{} function CoverBrowser:init() self.full_featured = true - -- As we don't know how to run and kill subprocesses on Android (for - -- background info extraction), this plugin is very limited on Android, - -- and will provide only a menu for managing a few core settings. - if Device.isAndroid() then - self.full_featured = false - end + -- Set to false to provide a fallback option with only a menu for managing a few core settings. self.ui.menu:registerToMainMenu(self) diff --git a/plugins/coverbrowser.koplugin/xutil.lua b/plugins/coverbrowser.koplugin/xutil.lua index bb9c56fd9..270de476e 100644 --- a/plugins/coverbrowser.koplugin/xutil.lua +++ b/plugins/coverbrowser.koplugin/xutil.lua @@ -1,5 +1,4 @@ local ffi = require("ffi") -local util = require("ffi/util") local C = ffi.C -- Utilities functions needed by this plugin, but that may be added to @@ -9,24 +8,19 @@ local xutil = {} -- Sub-process management (may be put into base/ffi/util.lua) function xutil.runInSubProcess(func) - if util.isAndroid() then - -- not sure how to do that on android - return nil - else - local pid = C.fork() - if pid == 0 then -- child process - -- Just run the provided lua code object in this new process, - -- and exit immediatly (so we do not release drivers and - -- resources still used by parent process) - func() - os.exit(0) - end - -- parent/main process, return pid of child - if pid == -1 then -- On failure, -1 is returned in the parent - return false - end - return pid + local pid = C.fork() + if pid == 0 then -- child process + -- Just run the provided lua code object in this new process, + -- and exit immediatly (so we do not release drivers and + -- resources still used by parent process) + func() + os.exit(0) end + -- parent/main process, return pid of child + if pid == -1 then -- On failure, -1 is returned in the parent + return false + end + return pid end function xutil.isSubProcessDone(pid)