1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-02 13:14:39 +00:00

Keep device awake during long syncs

This commit is contained in:
M66B 2022-10-23 16:11:36 +02:00
parent ddb69341e3
commit 145e4771fd

View file

@ -2144,16 +2144,23 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
public void run() { public void run() {
super.run(); super.run();
long timeout = Helper.WAKELOCK_MAX;
long start = new Date().getTime(); long start = new Date().getTime();
try { try {
wlOperations.acquire(Helper.WAKELOCK_MAX);
List<TupleOperationEx> partition; List<TupleOperationEx> partition;
synchronized (partitions) { synchronized (partitions) {
partition = partitions.get(key); partition = partitions.get(key);
partitions.remove(key); partitions.remove(key);
} }
for (TupleOperationEx op : partition)
if (EntityOperation.SYNC.equals(op.name)) {
timeout = 24 * 3600 * 1000L;
break;
}
wlOperations.acquire(timeout);
Log.i(account.name + "/" + folder.name + Log.i(account.name + "/" + folder.name +
" executing partition=" + key + " executing partition=" + key +
" serial=" + serial + " serial=" + serial +
@ -2287,7 +2294,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (wlOperations.isHeld()) if (wlOperations.isHeld())
wlOperations.release(); wlOperations.release();
else if (!isOptimizing && !BuildConfig.PLAY_STORE_RELEASE) else if (!isOptimizing && !BuildConfig.PLAY_STORE_RELEASE)
Log.e(key + " released elapse=" + (new Date().getTime() - start)); Log.e(key + " released elapse=" + (new Date().getTime() - start) + " timeout=" + timeout);
} }
} }
}); });