Log prematurely released operation wakelock

pull/209/head
M66B 2 years ago
parent 91641e7d94
commit 724a7b4a4e

@ -2082,6 +2082,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
@Override @Override
public void run() { public void run() {
super.run(); super.run();
long start = new Date().getTime();
long timeout = 0;
try { try {
List<TupleOperationEx> partition; List<TupleOperationEx> partition;
synchronized (partitions) { synchronized (partitions) {
@ -2090,7 +2093,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} }
// Estimate maximum execution duration // Estimate maximum execution duration
long timeout = 0;
if (mapFolders.get(folder) == null) { if (mapFolders.get(folder) == null) {
// Connect, sync folder list -> 3 minutes // Connect, sync folder list -> 3 minutes
timeout += WAKELOCK_ACCOUNT_MAX; timeout += WAKELOCK_ACCOUNT_MAX;
@ -2104,8 +2106,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
int hours = (folder.initialize == 0 ? 30 : folder.initialize) * 24; int hours = (folder.initialize == 0 ? 30 : folder.initialize) * 24;
timeout += WAKELOCK_OPERATION_MAX * hours * MESSAGES_HOUR_AVG; timeout += WAKELOCK_OPERATION_MAX * hours * MESSAGES_HOUR_AVG;
} else { } else {
long now = new Date().getTime(); long hours = (start - folder.last_sync) / (3600 * 1000L) + 1;
long hours = (now - folder.last_sync) / (3600 * 1000L) + 1;
// 10 messages/hour -> 100 seconds // 10 messages/hour -> 100 seconds
timeout += WAKELOCK_OPERATION_MAX * hours * MESSAGES_HOUR_AVG; timeout += WAKELOCK_OPERATION_MAX * hours * MESSAGES_HOUR_AVG;
} }
@ -2253,6 +2254,12 @@ 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;
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug,
key + " prematurely released" +
" elapsed=" + elapsed + " timeout=" + timeout);
}
wlOperations.release(); wlOperations.release();
} }
} }

Loading…
Cancel
Save