mirror of https://github.com/M66B/FairEmail.git
Tune keep-alive interval by default
This commit is contained in:
parent
fda85e1f07
commit
92b585d792
|
@ -80,6 +80,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
private TextView tvSubscriptionPro;
|
||||
private SwitchCompat swCheckMx;
|
||||
private SwitchCompat swCheckReply;
|
||||
private SwitchCompat swTuneKeepAlive;
|
||||
private Group grpExempted;
|
||||
|
||||
private AdapterAccountExempted adapter;
|
||||
|
@ -88,7 +89,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
"enabled", "poll_interval", "schedule", "schedule_start", "schedule_end",
|
||||
"sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "gmail_thread_id",
|
||||
"sync_folders", "sync_shared_folders", "subscriptions",
|
||||
"check_mx", "check_reply"
|
||||
"check_mx", "check_reply", "tune_keep_alive"
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -129,6 +130,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
tvSubscriptionPro = view.findViewById(R.id.tvSubscriptionPro);
|
||||
swCheckMx = view.findViewById(R.id.swCheckMx);
|
||||
swCheckReply = view.findViewById(R.id.swCheckReply);
|
||||
swTuneKeepAlive = view.findViewById(R.id.swTuneKeepAlive);
|
||||
grpExempted = view.findViewById(R.id.grpExempted);
|
||||
|
||||
setOptions();
|
||||
|
@ -308,6 +310,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
}
|
||||
});
|
||||
|
||||
swTuneKeepAlive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("tune_keep_alive", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
DB db = DB.getInstance(getContext());
|
||||
db.account().liveSynchronizingAccounts().observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
|
||||
@Override
|
||||
|
@ -397,6 +406,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
swSubscriptions.setEnabled(pro);
|
||||
swCheckMx.setChecked(prefs.getBoolean("check_mx", false));
|
||||
swCheckReply.setChecked(prefs.getBoolean("check_reply", false));
|
||||
swTuneKeepAlive.setChecked(prefs.getBoolean("tune_keep_alive", true));
|
||||
}
|
||||
|
||||
private String formatHour(Context context, int minutes) {
|
||||
|
|
|
@ -1376,14 +1376,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
boolean first = true;
|
||||
while (state.isRunning()) {
|
||||
long idleTime = state.getIdleTime();
|
||||
boolean auto_optimize = prefs.getBoolean("auto_optimize", false);
|
||||
boolean optimize = (auto_optimize && !first &&
|
||||
boolean tune_keep_alive = prefs.getBoolean("tune_keep_alive", true);
|
||||
boolean tune = (tune_keep_alive && !first &&
|
||||
!account.keep_alive_ok && account.poll_interval > 9 &&
|
||||
Math.abs(idleTime - account.poll_interval * 60 * 1000L) < 60 * 1000L);
|
||||
if (auto_optimize && !first && !account.keep_alive_ok)
|
||||
if (tune_keep_alive && !first && !account.keep_alive_ok)
|
||||
EntityLog.log(ServiceSynchronize.this, account.name +
|
||||
" Optimize interval=" + account.poll_interval +
|
||||
" idle=" + idleTime + "/" + optimize);
|
||||
" Tune interval=" + account.poll_interval +
|
||||
" idle=" + idleTime + "/" + tune);
|
||||
try {
|
||||
if (!state.isRecoverable())
|
||||
throw new StoreClosedException(iservice.getStore(), "Unrecoverable");
|
||||
|
@ -1414,7 +1414,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
Log.i(folder.name + " poll count=" + folder.poll_count);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
if (optimize) {
|
||||
if (tune) {
|
||||
account.keep_alive_failed++;
|
||||
account.keep_alive_succeeded = 0;
|
||||
if (account.keep_alive_failed >= 3) {
|
||||
|
@ -1433,7 +1433,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
throw ex;
|
||||
}
|
||||
|
||||
if (optimize) {
|
||||
if (tune) {
|
||||
account.keep_alive_failed = 0;
|
||||
account.keep_alive_succeeded++;
|
||||
db.account().setAccountKeepAliveValues(account.id,
|
||||
|
|
|
@ -516,6 +516,18 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swCheckReply" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swTuneKeepAlive"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:text="@string/title_advanced_tune_keep_alive"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCheckReplyHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpExempted"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -276,6 +276,9 @@
|
|||
<string name="title_advanced_sync_folders">Synchronize folder list</string>
|
||||
<string name="title_advanced_sync_shared_folders">Synchronize shared folder lists</string>
|
||||
<string name="title_advanced_subscriptions">Manage folder subscriptions</string>
|
||||
<string name="title_advanced_check_mx">Check sender email addresses on synchronizing messages</string>
|
||||
<string name="title_advanced_check_reply">Check reply email addresses on synchronizing messages</string>
|
||||
<string name="title_advanced_tune_keep_alive">Automatically tune the keep-alive interval</string>
|
||||
|
||||
<string name="title_advanced_keyboard">Show keyboard by default</string>
|
||||
<string name="title_advanced_suggest_local">Suggest locally stored contacts</string>
|
||||
|
@ -477,20 +480,18 @@
|
|||
<string name="title_advanced_poll_hint">Synchronizing periodically will compare local and remote messages each and every time, which is an expensive operation possibly resulting in extra battery usage, especially when there are a lot of messages to synchronize. Always synchronizing will avoid this by continuous monitoring for changes only.</string>
|
||||
<string name="title_advanced_optimized_hint">This option can be optimized automatically (miscellaneous settings)</string>
|
||||
<string name="title_advanced_schedule_hint">Tap on a time to set a time</string>
|
||||
<string name="title_advanced_check_mx">Check sender email addresses on synchronizing messages</string>
|
||||
<string name="title_advanced_check_reply">Check reply email addresses on synchronizing messages</string>
|
||||
<string name="title_advanced_no_date_hint">Some providers store messages with an unknown, invalid or future date as messages without date</string>
|
||||
<string name="title_advanced_unseen_hint">Some providers don\'t support this properly, which may cause synchronizing none or all messages</string>
|
||||
<string name="title_advanced_deleted_unseen">When disabled, unread messages are kept on the device forever</string>
|
||||
<string name="title_advanced_sync_kept_hint">This will transfer extra data and consume extra battery power, especially if a lot of messages are stored on the device</string>
|
||||
<string name="title_advanced_sync_folders_hint">Disabling this will reduce data and battery usage somewhat, but will disable updating the list of folders too</string>
|
||||
<string name="title_advanced_lookup_mx_hint">This will check if DNS MX records exist</string>
|
||||
<string name="title_advanced_sync_delay_hint">This will slow down synchronizing messages</string>
|
||||
<string name="title_advanced_check_reply_hint">This will check if domain name of the sender and reply addresses are the same</string>
|
||||
|
||||
<string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string>
|
||||
<string name="title_advanced_usenet_hint">Insert \'-- \' between the text and the signature</string>
|
||||
<string name="title_advanced_send_reminders_hint">Show a warning when the message text or the subject is empty or when an attachment might be missing</string>
|
||||
<string name="title_advanced_lookup_mx_hint">This will check if DNS MX records exist</string>
|
||||
<string name="title_advanced_check_reply_hint">This will check if domain name of the sender and reply addresses are the same</string>
|
||||
|
||||
<string name="title_advanced_metered_hint">Metered connections are generally mobile connections or paid Wi-Fi hotspots</string>
|
||||
<string name="title_advanced_metered_warning">Disabling this option will disable receiving and sending messages on mobile internet connections</string>
|
||||
|
|
Loading…
Reference in New Issue