mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
network: Allow auto_wifi_off on kindle & remarkable
They expose a network sysfs entry so we can track usage Works for me on kindle, but i stop the amazon framework
This commit is contained in:
@@ -497,7 +497,6 @@ function NetworkMgr:getPowersaveMenuTable()
|
||||
text = _("Disable Wi-Fi connection when inactive"),
|
||||
help_text = _([[This will automatically turn Wi-Fi off after a generous period of network inactivity, without disrupting workflows that require a network connection, so you can just keep reading without worrying about battery drain.]]),
|
||||
checked_func = function() return G_reader_settings:isTrue("auto_disable_wifi") end,
|
||||
enabled_func = function() return Device:hasWifiManager() end,
|
||||
callback = function()
|
||||
G_reader_settings:flipNilOrFalse("auto_disable_wifi")
|
||||
-- NOTE: Well, not exactly, but the activity check wouldn't be (un)scheduled until the next Network(Dis)Connected event...
|
||||
@@ -608,8 +607,12 @@ function NetworkMgr:getMenuTable(common_settings)
|
||||
common_settings.network_proxy = self:getProxyMenuTable()
|
||||
common_settings.network_info = self:getInfoMenuTable()
|
||||
|
||||
if Device:hasWifiManager() or Device:isEmulator() then
|
||||
-- Allow auto_disable_wifi on devices where the net sysfs entry is exposed.
|
||||
if self:getNetworkInterfaceName() then
|
||||
common_settings.network_powersave = self:getPowersaveMenuTable()
|
||||
end
|
||||
|
||||
if Device:hasWifiManager() or Device:isEmulator() then
|
||||
common_settings.network_restore = self:getRestoreMenuTable()
|
||||
common_settings.network_dismiss_scan = self:getDismissScanMenuTable()
|
||||
common_settings.network_before_wifi_action = self:getBeforeWifiActionMenuTable()
|
||||
|
||||
@@ -115,8 +115,8 @@ local network_activity_noise_margin = 12 -- unscaled_size_check: ignore
|
||||
|
||||
-- Read the statistics/tx_packets sysfs entry for the current network interface.
|
||||
-- It *should* be the least noisy entry on an idle network...
|
||||
-- The fact that auto_disable_wifi is only available on Device:hasWifiManager()
|
||||
-- allows us to get away with a Linux-only solution.
|
||||
-- The fact that auto_disable_wifi is only available on devices that expose a
|
||||
-- net sysfs entry allows us to get away with a Linux-only solution.
|
||||
function NetworkListener:_getTxPackets()
|
||||
-- read tx_packets stats from sysfs (for the right network if)
|
||||
local file = io.open("/sys/class/net/" .. NetworkMgr:getNetworkInterfaceName() .. "/statistics/tx_packets", "rb")
|
||||
@@ -198,14 +198,12 @@ end
|
||||
|
||||
function NetworkListener:onNetworkConnected()
|
||||
logger.dbg("NetworkListener: onNetworkConnected")
|
||||
if not Device:hasWifiManager() then
|
||||
return
|
||||
if Device:hasWifiManager() then
|
||||
-- This is for the sake of events that don't emanate from NetworkMgr itself...
|
||||
NetworkMgr:setWifiState(true)
|
||||
NetworkMgr:setConnectionState(true)
|
||||
end
|
||||
|
||||
-- This is for the sake of events that don't emanate from NetworkMgr itself...
|
||||
NetworkMgr:setWifiState(true)
|
||||
NetworkMgr:setConnectionState(true)
|
||||
|
||||
if not G_reader_settings:isTrue("auto_disable_wifi") then
|
||||
return
|
||||
end
|
||||
@@ -218,13 +216,11 @@ end
|
||||
|
||||
function NetworkListener:onNetworkDisconnected()
|
||||
logger.dbg("NetworkListener: onNetworkDisconnected")
|
||||
if not Device:hasWifiManager() then
|
||||
return
|
||||
if Device:hasWifiManager() then
|
||||
NetworkMgr:setWifiState(false)
|
||||
NetworkMgr:setConnectionState(false)
|
||||
end
|
||||
|
||||
NetworkMgr:setWifiState(false)
|
||||
NetworkMgr:setConnectionState(false)
|
||||
|
||||
if not G_reader_settings:isTrue("auto_disable_wifi") then
|
||||
return
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user