mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
[chore] Some Wi-Fi tweaks (#4564)
* On Kobo, kill WiFi on startup if we detect an inconsistent state... Untested, not terribly pretty. The other solution is to slow down the Wi-Fi meny by doing the same check for the "Wi-Fi connection" checkbox as in the later wifi_status one... * Don't enable auto_restore_wifi by default It's liable to silently murder batteries for no good reason, given that we prompt to enable WiFi by default when needed, and we otherwise have no actual need to keep WiFi on in the background. re #2215 (in particular, this directly contradicts @houqp in https://github.com/koreader/koreader/pull/2215#discussion_r74696133 ;)).
This commit is contained in:
@@ -154,7 +154,7 @@ function Device:onPowerEvent(ev)
|
||||
local UIManager = require("ui/uimanager")
|
||||
UIManager:unschedule(self.suspend)
|
||||
local network_manager = require("ui/network/manager")
|
||||
if network_manager.wifi_was_on and G_reader_settings:nilOrTrue("auto_restore_wifi") then
|
||||
if network_manager.wifi_was_on and G_reader_settings:isTrue("auto_restore_wifi") then
|
||||
network_manager:restoreWifiAsync()
|
||||
end
|
||||
self:resume()
|
||||
|
||||
@@ -5,6 +5,7 @@ local InfoMessage = require("ui/widget/infomessage")
|
||||
local LuaSettings = require("luasettings")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local ffiutil = require("ffi/util")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local T = ffiutil.template
|
||||
|
||||
@@ -15,8 +16,15 @@ function NetworkMgr:readNWSettings()
|
||||
end
|
||||
|
||||
function NetworkMgr:init()
|
||||
-- On Kobo, kill WiFi if NetworkMgr:isWifiOn() and NOT NetworkMgr:isConnected()
|
||||
-- (i.e., if the launcher left the WiFi in an inconsistent state: modules loaded, but no route to gateway).
|
||||
if Device:isKobo() and self:isWifiOn() and not self:isConnected() then
|
||||
logger.info("Kobo WiFi: Left in an inconsistent state by launcher!")
|
||||
self:turnOffWifi()
|
||||
end
|
||||
|
||||
self.wifi_was_on = G_reader_settings:isTrue("wifi_was_on")
|
||||
if self.wifi_was_on and G_reader_settings:nilOrTrue("auto_restore_wifi") then
|
||||
if self.wifi_was_on and G_reader_settings:isTrue("auto_restore_wifi") then
|
||||
self:restoreWifiAsync()
|
||||
end
|
||||
end
|
||||
@@ -186,9 +194,9 @@ end
|
||||
function NetworkMgr:getRestoreMenuTable()
|
||||
return {
|
||||
text = _("Automatically restore Wi-Fi connection after resume"),
|
||||
checked_func = function() return G_reader_settings:nilOrTrue("auto_restore_wifi") end,
|
||||
checked_func = function() return G_reader_settings:isTrue("auto_restore_wifi") end,
|
||||
enabled_func = function() return Device:isKobo() or Device:isCervantes() end,
|
||||
callback = function() G_reader_settings:flipNilOrTrue("auto_restore_wifi") end,
|
||||
callback = function() G_reader_settings:flipNilOrFalse("auto_restore_wifi") end,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ describe("network_manager module", function()
|
||||
local release_ip_called
|
||||
|
||||
local function clearState()
|
||||
G_reader_settings:saveSetting("auto_restore_wifi", true)
|
||||
turn_on_wifi_called = 0
|
||||
turn_off_wifi_called = 0
|
||||
obtain_ip_called = 0
|
||||
|
||||
Reference in New Issue
Block a user