Added option to turn off logarithmic back-off

This commit is contained in:
M66B 2022-03-09 10:11:04 +01:00
parent dd0c68b918
commit 148092cdf6
4 changed files with 46 additions and 3 deletions

View File

@ -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));

View File

@ -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);

View File

@ -1028,6 +1028,31 @@
app:layout_constraintTop_toBottomOf="@id/swEmptyPool"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLogarithmicBackoff"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_logarithmic_backoff"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swIdleDone"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvLogarithmicBackoffHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_logarithmic_backoff_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLogarithmicBackoff" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swExactAlarms"
android:layout_width="0dp"
@ -1036,7 +1061,7 @@
android:text="@string/title_advanced_exact_alarms"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swIdleDone"
app:layout_constraintTop_toBottomOf="@id/tvLogarithmicBackoffHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -723,6 +723,8 @@
<string name="title_advanced_auth_sasl" translatable="false">SASL</string>
<string name="title_advanced_auth_apop" translatable="false">APOP</string>
<string name="title_advanced_idle_done" translatable="false">IDLE/DONE</string>
<string name="title_advanced_logarithmic_backoff" translatable="false">Logarithmic back-off</string>
<string name="title_advanced_logarithmic_backoff_hint" translatable="false">Turning this off can result in a significant increase in battery usage!</string>
<string name="title_advanced_keep_alive_poll" translatable="false">Poll on keep-alive</string>
<string name="title_advanced_empty_pool" translatable="false">Empty connection pool</string>
<string name="title_advanced_exact_alarms" translatable="false">Use exact timers</string>