Fix some screen refresh effects (#10306)

reviewable/pr10376/r1
zwim 1 year ago committed by GitHub
parent 04fba2205d
commit 662bd65a5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -224,6 +224,10 @@ function NetworkMgr:toggleWifiOn(complete_callback, long_press)
self.wifi_was_on = true
G_reader_settings:makeTrue("wifi_was_on")
self.wifi_toggle_long_press = long_press
-- Connecting might take a few seconds (hello standby).
-- Broadcast the information, that network is changing, so affected modules/plugins can react.
UIManager:broadcastEvent(Event:new("NetworkConnecting"))
self:turnOnWifi(complete_callback)
UIManager:close(toggle_im)
@ -238,6 +242,10 @@ function NetworkMgr:toggleWifiOff(complete_callback)
self.wifi_was_on = false
G_reader_settings:makeFalse("wifi_was_on")
-- Disconnecting might take some time, but less than connecting (hello standby).
-- Broadcast the information, that network is changing, so affected modules/plugins can react.
UIManager:broadcastEvent(Event:new("NetworkDisconnecting"))
self:turnOffWifi(complete_callback)
UIManager:close(toggle_im)
@ -503,16 +511,16 @@ function NetworkMgr:getWifiToggleMenuTable()
UIManager:broadcastEvent(Event:new("NetworkConnected"))
end
end
end
end -- complete_callback()
if fully_connected then
self:toggleWifiOff(complete_callback)
elseif self.is_wifi_on and not self.is_connected then
-- ask whether user wants to connect or turn off wifi
self:promptWifi(complete_callback, long_press)
else
else -- if not connected at all
self:toggleWifiOn(complete_callback, long_press)
end
end
end -- toggleCallback()
return {
text = _("Wi-Fi connection"),

@ -265,7 +265,7 @@ function AutoSuspend:_schedule_standby(sleep_in)
if NetworkMgr:getWifiState() then
-- Don't enter standby if wifi is on, as this will break in fun and interesting ways (from Wi-Fi issues to kernel deadlocks).
--logger.dbg("AutoSuspend: WiFi is on, delaying standby")
standby_delay_seconds = self.auto_standby_timeout_seconds
standby_delay_seconds = sleep_in
elseif Device.powerd:isCharging() and not Device:canPowerSaveWhileCharging() then
-- Don't enter standby when charging on devices where charging *may* prevent entering low power states.
-- (*May*, because depending on the USB controller, it might depend on what it's plugged to, and how it's setup:
@ -273,7 +273,7 @@ function AutoSuspend:_schedule_standby(sleep_in)
-- NOTE: Minor simplification here, we currently don't do the hasAuxBattery dance like in _schedule,
-- because all the hasAuxBattery devices can currently enter PM states while charging ;).
--logger.dbg("AutoSuspend: charging, delaying standby")
standby_delay_seconds = self.auto_standby_timeout_seconds
standby_delay_seconds = sleep_in
else
local now = UIManager:getElapsedTimeSinceBoot()
standby_delay_seconds = sleep_in - time.to_number(now - self.last_action_time)
@ -658,4 +658,31 @@ function AutoSuspend:toggleStandbyHandler(toggle)
end
end
function AutoSuspend:onNetworkConnected()
logger.dbg("AutoSuspend: onNetworkConnected")
self:_unschedule_standby()
-- Schedule the next check at the end of our timescale, the subsequent checks are ... well never ;)
self:_start_standby(math.huge)
end
function AutoSuspend:onNetworkConnecting()
logger.dbg("AutoSuspend: onNetworkConnecting")
self:_unschedule_standby()
-- Schedule the next check in 60s. If something goes wrong, the subsequent checks are in `self.auto_standby_timeout_seconds`.
self:_start_standby(time.s(60))
end
function AutoSuspend:onNetworkDisconnected()
logger.dbg("AutoSuspend: onNetworkDisonnected")
self:_unschedule_standby()
-- Schedule the next check as usual.
self:_start_standby()
end
--[[ -- not necessary right now
function AutoSuspend:onNetworkDisconnecting()
logger.dbg("AutoSuspend: onNetworkDisconnecting")
end
--]]
return AutoSuspend

Loading…
Cancel
Save