From 6036761a401098675d37ba232a5d3942663d587f Mon Sep 17 00:00:00 2001 From: zwim <36999612+zwim@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:00:52 +0100 Subject: [PATCH] [AutoSuspend] Make day selector less restrictive (#12835) This allows to set days to zero. As a security fall back setting days and hours both to zero will yield 5m autosuspend time. (to avoid shutdown loops). fixes #12831 --- plugins/autosuspend.koplugin/main.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/autosuspend.koplugin/main.lua b/plugins/autosuspend.koplugin/main.lua index fcc79d201..c67846149 100644 --- a/plugins/autosuspend.koplugin/main.lua +++ b/plugins/autosuspend.koplugin/main.lua @@ -408,11 +408,12 @@ function AutoSuspend:pickTimeoutValue(touchmenu_instance, title, info, setting, local is_standby = setting == "auto_standby_timeout_seconds" local day, hour, minute, second - local day_max, hour_max, min_max, sec_max + local day_max, day_min, hour_max, min_max, sec_max if time_scale == 2 then day = math.floor(setting_val * (1/(24*3600))) hour = math.floor(setting_val * (1/3600)) % 24 day_max = math.floor(range[2] * (1/(24*3600))) - 1 + day_min = 0 hour_max = 23 elseif time_scale == 1 then hour = math.floor(setting_val * (1/3600)) @@ -437,6 +438,7 @@ function AutoSuspend:pickTimeoutValue(touchmenu_instance, title, info, setting, min_hold_step = 10, sec_hold_step = 10, day_max = day_max, + day_min = day_min, hour_max = hour_max, min_max = min_max, sec_max = sec_max, @@ -465,6 +467,7 @@ function AutoSuspend:pickTimeoutValue(touchmenu_instance, title, info, setting, text = T(_("%1: %2"), title, time_string), timeout = 3, }) + time_spinner:onClose() end, default_value = datetime.secondsToClockDuration("letters", default_value, time_scale == 2 or time_scale == 1, true),