Autosuspend: fix 'Disable' not disabling (#8684)

reviewable/pr8694/r1
zwim 2 years ago committed by GitHub
parent eb0c2bfc93
commit b21dc4dcc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,7 +42,7 @@ function AutoSuspend:_enabledShutdown()
end end
function AutoSuspend:_schedule(shutdown_only) function AutoSuspend:_schedule(shutdown_only)
if not self:_enabled() and (Device:canPowerOff() and not self:_enabledShutdown()) then if not self:_enabled() and Device:canPowerOff() and not self:_enabledShutdown() then
logger.dbg("AutoSuspend:_schedule is disabled") logger.dbg("AutoSuspend:_schedule is disabled")
return return
end end
@ -61,10 +61,10 @@ function AutoSuspend:_schedule(shutdown_only)
end end
-- Try to shutdown first, as we may have been woken up from suspend just for the sole purpose of doing that. -- Try to shutdown first, as we may have been woken up from suspend just for the sole purpose of doing that.
if delay_shutdown <= 0 then if self:_enabledShutdown() and delay_shutdown <= 0 then
logger.dbg("AutoSuspend: initiating shutdown") logger.dbg("AutoSuspend: initiating shutdown")
UIManager:poweroff_action() UIManager:poweroff_action()
elseif delay_suspend <= 0 and not shutdown_only then elseif self:_enabled() and delay_suspend <= 0 and not shutdown_only then
logger.dbg("AutoSuspend: will suspend the device") logger.dbg("AutoSuspend: will suspend the device")
UIManager:suspend() UIManager:suspend()
else else
@ -223,6 +223,7 @@ function AutoSuspend:setSuspendShutdownTimes(touchmenu_instance, title, info, se
extra_text = _("Disable"), extra_text = _("Disable"),
extra_callback = function(_self) extra_callback = function(_self)
self[setting] = -1 -- disable with a negative time/number self[setting] = -1 -- disable with a negative time/number
G_reader_settings:saveSetting(setting, -1)
self:_unschedule() self:_unschedule()
if touchmenu_instance then touchmenu_instance:updateItems() end if touchmenu_instance then touchmenu_instance:updateItems() end
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{

Loading…
Cancel
Save