From bea7334df995a613db4ae91103396b2e5302c94e Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 6 Sep 2021 11:26:46 +0200 Subject: [PATCH] Logaritmic back-off on auth failures --- .../main/java/eu/faircode/email/ServiceSynchronize.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 0d4663f400..fd8fc680c4 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1401,7 +1401,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences } else { Log.e(ex); try { - state.setBackoff(2 * CONNECT_BACKOFF_ALARM_MAX * 60); + int backoff = state.getBackoff(); + if (backoff < 2 * CONNECT_BACKOFF_ALARM_MAX * 60) + backoff = 2 * CONNECT_BACKOFF_ALARM_MAX * 60; + else if (backoff < 8 * CONNECT_BACKOFF_ALARM_MAX * 60) + backoff *= 2; + state.setBackoff(backoff); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify("receive:" + account.id, NotificationHelper.NOTIFICATION_TAGGED,