From 8e1275e052f50f4b097a8c0b5bb3ae57796f65fd Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 6 Aug 2021 07:39:11 +0200 Subject: [PATCH] Limit long back-off time --- .../main/java/eu/faircode/email/ServiceSynchronize.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 305d10ce35..961eec75c3 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -2153,8 +2153,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences state.setBackoff(backoff * 2); else if (backoff == CONNECT_BACKOFF_MAX) state.setBackoff(CONNECT_BACKOFF_ALARM_START * 60); - else if (backoff < CONNECT_BACKOFF_ALARM_MAX * 60) - state.setBackoff(backoff * 2); + else if (backoff < CONNECT_BACKOFF_ALARM_MAX * 60) { + int b = backoff * 2; + if (b > CONNECT_BACKOFF_ALARM_MAX * 60) + b = CONNECT_BACKOFF_ALARM_MAX * 60; + state.setBackoff(b); + } if (backoff <= CONNECT_BACKOFF_MAX) { // Short back-off period, keep device awake