From 910b67d35b004ebd58da7558ff98b2faa338ab76 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Thu, 17 Aug 2023 17:19:28 +0200 Subject: [PATCH] NetworkListener: Only disable Wi-Fi on suspend on hasWifiManager platforms Assume the host system does things right otherwise. Should be sane on Kindle On PocketBook, who knows, but assuming the device actually suspends, that should effectively kill our keepalive Irrelevant for Android, as we skipped it because the wifi toggling methods are interactive. --- frontend/ui/network/manager.lua | 3 ++- frontend/ui/network/networklistener.lua | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/ui/network/manager.lua b/frontend/ui/network/manager.lua index 6a01fc521..1503ba651 100644 --- a/frontend/ui/network/manager.lua +++ b/frontend/ui/network/manager.lua @@ -757,7 +757,8 @@ end function NetworkMgr:getRestoreMenuTable() return { text = _("Restore Wi-Fi connection on resume"), - help_text = _([[This will attempt to automatically and silently re-connect to Wi-Fi on startup or on resume if Wi-Fi used to be enabled the last time you used KOReader.]]), + -- i.e., *everything* flips wifi_was_on true, but only direct user interaction (i.e., Menu & Gestures) will flip it off. + help_text = _([[This will attempt to automatically and silently re-connect to Wi-Fi on startup or on resume if Wi-Fi used to be enabled the last time you used KOReader, and you did not explicitly disable it.]]), checked_func = function() return G_reader_settings:isTrue("auto_restore_wifi") end, enabled_func = function() return Device:hasWifiRestore() end, callback = function() G_reader_settings:flipNilOrFalse("auto_restore_wifi") end, diff --git a/frontend/ui/network/networklistener.lua b/frontend/ui/network/networklistener.lua index 61e11c5aa..852e59497 100644 --- a/frontend/ui/network/networklistener.lua +++ b/frontend/ui/network/networklistener.lua @@ -205,8 +205,8 @@ function NetworkListener:onSuspend() logger.dbg("NetworkListener: onSuspend") -- If we haven't already (e.g., via Generic's onPowerEvent), kill Wi-Fi. - -- Except on Android, where turnOnWifi/turnOffWifi are *interactive*... :/ - if Device:hasWifiToggle() and NetworkMgr:isWifiOn() and not Device:isAndroid() then + -- Do so only on devices where we have explicit management of Wi-Fi: assume the host system does things properly elsewhere. + if Device:hasWifiManager() and NetworkMgr:isWifiOn() then NetworkMgr:disableWifi() end