mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[Cervantes] Disable wifi before returning to QT, improved sysfs read (#5326)
This commit is contained in:
committed by
Frans de Jonge
parent
5f189beba9
commit
20ebb55703
@@ -14,11 +14,30 @@ local function getProductId()
|
||||
end
|
||||
|
||||
local function isConnected()
|
||||
-- read carrier state from sysfs (for eth0)
|
||||
local file = io.open("/sys/class/net/eth0/carrier", "rb")
|
||||
|
||||
-- file exists while wifi module is loaded.
|
||||
if not file then return 0 end
|
||||
local carrier = tonumber(file:read("*all")) or 0
|
||||
|
||||
-- 0 means not connected, 1 connected
|
||||
local out = file:read("*all")
|
||||
file:close()
|
||||
return carrier
|
||||
|
||||
-- strip NaN from file read (ie: line endings, error messages)
|
||||
local carrier
|
||||
if type(out) ~= "number" then
|
||||
carrier = tonumber(out)
|
||||
else
|
||||
carrier = out
|
||||
end
|
||||
|
||||
-- finally return if we're connected or not
|
||||
if type(carrier) == "number" then
|
||||
return carrier
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
local function isMassStorageSupported()
|
||||
|
||||
@@ -108,7 +108,8 @@ while [ "${RETURN_VALUE}" -ge "${RESTART_KOREADER}" ]; do
|
||||
# waiting forever for home button events.
|
||||
|
||||
elif [ "${RETURN_VALUE}" -eq "${ENTER_QBOOKAPP}" ]; then
|
||||
# iface is down and wpa killed. Start connman
|
||||
./release-ip.sh
|
||||
./disable-wifi.sh
|
||||
[ -x /etc/init.d/connman ] && /etc/init.d/connman start
|
||||
|
||||
# (re)start the reading application in the background
|
||||
@@ -123,6 +124,8 @@ while [ "${RETURN_VALUE}" -ge "${RESTART_KOREADER}" ]; do
|
||||
done
|
||||
|
||||
if [ "${STANDALONE}" != "true" ]; then
|
||||
./release-ip.sh
|
||||
./disable-wifi.sh
|
||||
[ -x /etc/init.d/connman ] && /etc/init.d/connman start
|
||||
restart.sh >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user