mirror of https://github.com/M66B/FairEmail.git
Added setting for operation wakelock timeout
This commit is contained in:
parent
2c7bfe5e61
commit
24977689a9
|
@ -205,6 +205,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
private SwitchCompat swIdleDone;
|
private SwitchCompat swIdleDone;
|
||||||
private SwitchCompat swLogarithmicBackoff;
|
private SwitchCompat swLogarithmicBackoff;
|
||||||
private SwitchCompat swExactAlarms;
|
private SwitchCompat swExactAlarms;
|
||||||
|
private SwitchCompat swOpWakelock;
|
||||||
private SwitchCompat swInfra;
|
private SwitchCompat swInfra;
|
||||||
private SwitchCompat swDupMsgId;
|
private SwitchCompat swDupMsgId;
|
||||||
private EditText etKeywords;
|
private EditText etKeywords;
|
||||||
|
@ -261,7 +262,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
"use_modseq", "uid_command", "perform_expunge", "uid_expunge",
|
"use_modseq", "uid_command", "perform_expunge", "uid_expunge",
|
||||||
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "auth_apop", "use_top",
|
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "auth_apop", "use_top",
|
||||||
"keep_alive_poll", "empty_pool", "idle_done", "logarithmic_backoff",
|
"keep_alive_poll", "empty_pool", "idle_done", "logarithmic_backoff",
|
||||||
"exact_alarms", "infra", "dkim_verify", "dup_msgids", "global_keywords", "test_iab"
|
"exact_alarms", "op_wakelock", "infra", "dkim_verify", "dup_msgids", "global_keywords", "test_iab"
|
||||||
};
|
};
|
||||||
|
|
||||||
private final static String[] RESET_QUESTIONS = new String[]{
|
private final static String[] RESET_QUESTIONS = new String[]{
|
||||||
|
@ -416,6 +417,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
swIdleDone = view.findViewById(R.id.swIdleDone);
|
swIdleDone = view.findViewById(R.id.swIdleDone);
|
||||||
swLogarithmicBackoff = view.findViewById(R.id.swLogarithmicBackoff);
|
swLogarithmicBackoff = view.findViewById(R.id.swLogarithmicBackoff);
|
||||||
swExactAlarms = view.findViewById(R.id.swExactAlarms);
|
swExactAlarms = view.findViewById(R.id.swExactAlarms);
|
||||||
|
swOpWakelock = view.findViewById(R.id.swOpWakelock);
|
||||||
swInfra = view.findViewById(R.id.swInfra);
|
swInfra = view.findViewById(R.id.swInfra);
|
||||||
swDupMsgId = view.findViewById(R.id.swDupMsgId);
|
swDupMsgId = view.findViewById(R.id.swDupMsgId);
|
||||||
etKeywords = view.findViewById(R.id.etKeywords);
|
etKeywords = view.findViewById(R.id.etKeywords);
|
||||||
|
@ -1426,6 +1428,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
swOpWakelock.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
prefs.edit().putBoolean("op_wakelock", checked).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
swInfra.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swInfra.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
@ -2126,6 +2135,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
swIdleDone.setChecked(prefs.getBoolean("idle_done", true));
|
swIdleDone.setChecked(prefs.getBoolean("idle_done", true));
|
||||||
swLogarithmicBackoff.setChecked(prefs.getBoolean("logarithmic_backoff", true));
|
swLogarithmicBackoff.setChecked(prefs.getBoolean("logarithmic_backoff", true));
|
||||||
swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", true));
|
swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", true));
|
||||||
|
swOpWakelock.setChecked(prefs.getBoolean("op_wakelock", false));
|
||||||
swInfra.setChecked(prefs.getBoolean("infra", false));
|
swInfra.setChecked(prefs.getBoolean("infra", false));
|
||||||
swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false));
|
swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false));
|
||||||
etKeywords.setText(prefs.getString("global_keywords", null));
|
etKeywords.setText(prefs.getString("global_keywords", null));
|
||||||
|
|
|
@ -2083,8 +2083,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
public void run() {
|
public void run() {
|
||||||
super.run();
|
super.run();
|
||||||
|
|
||||||
long start = new Date().getTime();
|
|
||||||
long timeout = 0;
|
long timeout = 0;
|
||||||
|
boolean op_wakelock = prefs.getBoolean("op_wakelock", false);
|
||||||
|
|
||||||
|
long start = new Date().getTime();
|
||||||
try {
|
try {
|
||||||
List<TupleOperationEx> partition;
|
List<TupleOperationEx> partition;
|
||||||
synchronized (partitions) {
|
synchronized (partitions) {
|
||||||
|
@ -2122,7 +2124,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
else
|
else
|
||||||
timeout += WAKELOCK_OPERATION_MAX; // -> 10 seconds
|
timeout += WAKELOCK_OPERATION_MAX; // -> 10 seconds
|
||||||
|
|
||||||
wlOperations.acquire(timeout);
|
if (op_wakelock)
|
||||||
|
wlOperations.acquire(timeout);
|
||||||
|
else
|
||||||
|
wlOperations.acquire();
|
||||||
|
|
||||||
Log.i(account.name + "/" + folder.name +
|
Log.i(account.name + "/" + folder.name +
|
||||||
" executing partition=" + key +
|
" executing partition=" + key +
|
||||||
|
@ -2255,11 +2260,16 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
else
|
else
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
} finally {
|
} finally {
|
||||||
if (!wlOperations.isHeld()) {
|
long elapsed = new Date().getTime() - start;
|
||||||
long elapsed = new Date().getTime() - start;
|
if (!wlOperations.isHeld() || elapsed > timeout) {
|
||||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug,
|
String msg = key + " prematurely released" +
|
||||||
key + " prematurely released" +
|
" elapsed=" + elapsed +
|
||||||
" elapsed=" + elapsed + " timeout=" + timeout);
|
" timeout=" + timeout +
|
||||||
|
" enforced=" + op_wakelock +
|
||||||
|
" held=" + wlOperations.isHeld() +
|
||||||
|
" host=" + account.host;
|
||||||
|
Log.e(msg);
|
||||||
|
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug, msg);
|
||||||
}
|
}
|
||||||
wlOperations.release();
|
wlOperations.release();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1490,12 +1490,24 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
|
android:checked="true"
|
||||||
android:text="@string/title_advanced_exact_alarms"
|
android:text="@string/title_advanced_exact_alarms"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvLogarithmicBackoffHint"
|
app:layout_constraintTop_toBottomOf="@id/tvLogarithmicBackoffHint"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swOpWakelock"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="@string/title_advanced_op_wakelock"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/swExactAlarms"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/swInfra"
|
android:id="@+id/swInfra"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -1504,7 +1516,7 @@
|
||||||
android:text="@string/title_advanced_infra"
|
android:text="@string/title_advanced_infra"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/swExactAlarms"
|
app:layout_constraintTop_toBottomOf="@id/swOpWakelock"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.constraintlayout.helper.widget.Flow
|
<androidx.constraintlayout.helper.widget.Flow
|
||||||
|
|
|
@ -814,6 +814,7 @@
|
||||||
<string name="title_advanced_keep_alive_poll" translatable="false">Poll on keep-alive</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_empty_pool" translatable="false">Empty connection pool</string>
|
||||||
<string name="title_advanced_exact_alarms" translatable="false">Use exact timers</string>
|
<string name="title_advanced_exact_alarms" translatable="false">Use exact timers</string>
|
||||||
|
<string name="title_advanced_op_wakelock" translatable="false">Operation wakelock timeout</string>
|
||||||
<string name="title_advanced_infra" translatable="false">Show infrastructure</string>
|
<string name="title_advanced_infra" translatable="false">Show infrastructure</string>
|
||||||
<string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string>
|
<string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string>
|
||||||
<string name="title_advanced_global_keywords" translatable="false">Global keywords</string>
|
<string name="title_advanced_global_keywords" translatable="false">Global keywords</string>
|
||||||
|
|
Loading…
Reference in New Issue