From 148092cdf6897ddf87c0f785485ed1f110ca283e Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 9 Mar 2022 10:11:04 +0100 Subject: [PATCH] Added option to turn off logarithmic back-off --- .../faircode/email/FragmentOptionsMisc.java | 12 ++++++++- .../eu/faircode/email/ServiceSynchronize.java | 8 +++++- .../main/res/layout/fragment_options_misc.xml | 27 ++++++++++++++++++- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index feae107760..fdd306be39 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -159,6 +159,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swKeepAlivePoll; private SwitchCompat swEmptyPool; private SwitchCompat swIdleDone; + private SwitchCompat swLogarithmicBackoff; private SwitchCompat swExactAlarms; private SwitchCompat swInfra; private SwitchCompat swDupMsgId; @@ -199,7 +200,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc "chunk_size", "undo_manager", "webview_legacy", "use_modseq", "uid_command", "perform_expunge", "uid_expunge", "auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "auth_apop", - "keep_alive_poll", "empty_pool", "idle_done", + "keep_alive_poll", "empty_pool", "idle_done", "logarithmic_backoff", "exact_alarms", "infra", "dup_msgids", "test_iab" }; @@ -312,6 +313,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swKeepAlivePoll = view.findViewById(R.id.swKeepAlivePoll); swEmptyPool = view.findViewById(R.id.swEmptyPool); swIdleDone = view.findViewById(R.id.swIdleDone); + swLogarithmicBackoff = view.findViewById(R.id.swLogarithmicBackoff); swExactAlarms = view.findViewById(R.id.swExactAlarms); swInfra = view.findViewById(R.id.swInfra); swDupMsgId = view.findViewById(R.id.swDupMsgId); @@ -1042,6 +1044,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swLogarithmicBackoff.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("logarithmic_backoff", checked).apply(); + } + }); + swExactAlarms.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -1614,6 +1623,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swKeepAlivePoll.setChecked(prefs.getBoolean("keep_alive_poll", false)); swEmptyPool.setChecked(prefs.getBoolean("empty_pool", true)); swIdleDone.setChecked(prefs.getBoolean("idle_done", true)); + swLogarithmicBackoff.setChecked(prefs.getBoolean("logarithmic_backoff", true)); swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", true)); swInfra.setChecked(prefs.getBoolean("infra", false)); swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false)); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 22565fbc8f..8164e94857 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -2365,8 +2365,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences int backoff = state.getBackoff(); int recently = (lastLost + LOST_RECENTLY < now ? 1 : 2); + boolean logarithmic_backoff = prefs.getBoolean("logarithmic_backoff", true); EntityLog.log(this, EntityLog.Type.Account, account, - account.name + " backoff=" + backoff + " recently=" + recently + "x"); + account.name + " backoff=" + backoff + + " recently=" + recently + "x" + + " logarithmic=" + logarithmic_backoff); + + if (!logarithmic_backoff) + backoff = CONNECT_BACKOFF_START; if (backoff < CONNECT_BACKOFF_MAX) state.setBackoff(backoff * 2); diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 9a8d289fcc..c1bca120ff 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -1028,6 +1028,31 @@ app:layout_constraintTop_toBottomOf="@id/swEmptyPool" app:switchPadding="12dp" /> + + + + SASL APOP IDLE/DONE + Logarithmic back-off + Turning this off can result in a significant increase in battery usage! Poll on keep-alive Empty connection pool Use exact timers