Keep device awake during long syncs

pull/209/head
M66B 3 years ago
parent ddb69341e3
commit 145e4771fd

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

Loading…
Cancel
Save