NetworkManager: Plug a logic hole in the beforeWifiAction logic

The *runWhenOnline wrappers may not pass a callback when connected but
not online yet, so we need nil guards all the way down ;).

Re: #10806
reviewable/pr10821/r1
NiLuJe 9 months ago
parent 22678ee5ff
commit 7a5216a0a6

@ -322,8 +322,12 @@ end
function NetworkMgr:turnOnWifiAndWaitForConnection(callback)
-- Just run the callback if WiFi is already up...
if self:isWifiOn() and self:isConnected() then
-- Given the guards in beforeWifiAction callers, this shouldn't really ever happen...
callback()
--- @note: beforeWifiAction only guarantees isConnected, not isOnline.
-- In the rare cases we're isConnected but !isOnline, if we're called via a *runWhenOnline wrapper,
-- we don't get a callback at all to avoid infinite recursion, so we need to check it.
if callback then
callback()
end
return
end

Loading…
Cancel
Save