Terminal: Better yet, disable it properly on prereq failure

reviewable/pr11044/r7
NiLuJe 4 months ago
parent a906838123
commit 75ffc3bb76

@ -37,18 +37,18 @@ local function check_prerequisites()
local ptmx = C.open("/dev/ptmx", bit.bor(C.O_RDWR, C.O_NONBLOCK, C.O_CLOEXEC)) local ptmx = C.open("/dev/ptmx", bit.bor(C.O_RDWR, C.O_NONBLOCK, C.O_CLOEXEC))
if ptmx == -1 then if ptmx == -1 then
logger.warn("Terminal: cannot open /dev/ptmx:", ffi.string(C.strerror(ffi.errno()))) logger.warn("Terminal: cannot open /dev/ptmx:", ffi.string(C.strerror(ffi.errno())))
error("Device doesn't meet some of the plugin's prerequisites") return false
end end
if C.grantpt(ptmx) ~= 0 then if C.grantpt(ptmx) ~= 0 then
logger.warn("Terminal: cannot use grantpt:", ffi.string(C.strerror(ffi.errno()))) logger.warn("Terminal: cannot use grantpt:", ffi.string(C.strerror(ffi.errno())))
C.close(ptmx) C.close(ptmx)
error("Device doesn't meet some of the plugin's prerequisites") return false
end end
if C.unlockpt(ptmx) ~= 0 then if C.unlockpt(ptmx) ~= 0 then
logger.warn("Terminal: cannot use unlockpt:", ffi.string(C.strerror(ffi.errno()))) logger.warn("Terminal: cannot use unlockpt:", ffi.string(C.strerror(ffi.errno())))
C.close(ptmx) C.close(ptmx)
error("Device doesn't meet some of the plugin's prerequisites") return false
end end
C.close(ptmx) C.close(ptmx)
return true return true
@ -58,7 +58,8 @@ end
-- So sorry for the Tolinos with (Android 4.4.x). -- So sorry for the Tolinos with (Android 4.4.x).
-- Maybe https://f-droid.org/de/packages/jackpal.androidterm/ could be an alternative then. -- Maybe https://f-droid.org/de/packages/jackpal.androidterm/ could be an alternative then.
if (Device:isAndroid() and Device.firmware_rev < 21) or not check_prerequisites() then if (Device:isAndroid() and Device.firmware_rev < 21) or not check_prerequisites() then
return logger.warn("Terminal: Device doesn't meet some of the plugin's prerequisites")
return { disabled = true, }
end end
local Aliases = require("aliases") local Aliases = require("aliases")

Loading…
Cancel
Save