Skip to content

Commit

Permalink
KOSync: Kill Wi-Fi once we're done on suspend
Browse files Browse the repository at this point in the history
Most older NTX boards will horribly implode when attempting to suspend
with the Wi-Fi chip powered on.

And the others may do very dumb things re: power management anyway.

(This falls outside of the existing machinery that deals with this case,
as it happens *before* sending the Suspend Event).

Fix koreader#12614
  • Loading branch information
NiLuJe committed Oct 11, 2024
1 parent f143f5f commit 49cfd80
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions plugins/kosync.koplugin/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ function KOSync:syncToProgress(progress)
end
end

function KOSync:updateProgress(ensure_networking, interactive, refresh_on_success)
function KOSync:updateProgress(ensure_networking, interactive, on_suspend)
if not self.settings.username or not self.settings.userkey then
if interactive then
promptLogin()
Expand All @@ -640,7 +640,7 @@ function KOSync:updateProgress(ensure_networking, interactive, refresh_on_succes
return
end

if ensure_networking and NetworkMgr:willRerunWhenOnline(function() self:updateProgress(ensure_networking, interactive, refresh_on_success) end) then
if ensure_networking and NetworkMgr:willRerunWhenOnline(function() self:updateProgress(ensure_networking, interactive, on_suspend) end) then
return
end

Expand Down Expand Up @@ -680,7 +680,7 @@ function KOSync:updateProgress(ensure_networking, interactive, refresh_on_succes
if err then logger.dbg("err:", err) end
else
-- This is solely for onSuspend's sake, to clear the ghosting left by the "Connected" InfoMessage
if refresh_on_success then
if on_suspend then
-- Our top-level widget should be the "Connected to network" InfoMessage from NetworkMgr's reconnectOrShowNetworkMenu
local widget = UIManager:getTopmostVisibleWidget()
if widget and widget.modal and widget.tag == "NetworkMgr" and not widget.dismiss_callback then
Expand All @@ -693,6 +693,15 @@ function KOSync:updateProgress(ensure_networking, interactive, refresh_on_succes
end
end

if on_suspend then
-- NOTE: We want to murder Wi-Fi once we're done in this specific case (i.e., Suspend),
-- because some of our hasWifiManager targets will horribly implode when attempting to suspend with the Wi-Fi chip powered on,
-- and they'll have attempted to kill Wi-Fi well before *we* run (e.g., in `Device:onPowerEvent`, *before* actually sending the Suspend Event)...
if Device:hasWifiManager() then
NetworkMgr:disableWifi()
end
end

self.push_timestamp = now
end

Expand Down

0 comments on commit 49cfd80

Please sign in to comment.