Small improvements

This commit is contained in:
M66B 2018-12-06 12:38:09 +01:00
parent 3351a2efbe
commit fe43910b93
1 changed files with 8 additions and 10 deletions

View File

@ -2318,6 +2318,9 @@ public class ServiceSynchronize extends LifecycleService {
private boolean started = false; private boolean started = false;
private int queued = 0; private int queued = 0;
private long lastLost = 0; private long lastLost = 0;
PowerManager pm = getSystemService(PowerManager.class);
PowerManager.WakeLock wl = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":manage");
private ExecutorService queue = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); private ExecutorService queue = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
@Override @Override
@ -2576,18 +2579,14 @@ public class ServiceSynchronize extends LifecycleService {
queued++; queued++;
queue.submit(new Runnable() { queue.submit(new Runnable() {
PowerManager pm = getSystemService(PowerManager.class);
PowerManager.WakeLock wl = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":manage");
@Override @Override
public void run() { public void run() {
EntityLog.log(ServiceSynchronize.this, "Reload " +
" stop=" + doStop + " start=" + doStart + " queued=" + queued + " " + reason);
try { try {
wl.acquire(); wl.acquire();
EntityLog.log(ServiceSynchronize.this, "Reload " +
" stop=" + doStop + " start=" + doStart + " queued=" + queued + " " + reason);
if (doStop) if (doStop)
stop(); stop();
@ -2597,8 +2596,6 @@ public class ServiceSynchronize extends LifecycleService {
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
} finally { } finally {
wl.release();
queued--; queued--;
EntityLog.log(ServiceSynchronize.this, "Reload done queued=" + queued); EntityLog.log(ServiceSynchronize.this, "Reload done queued=" + queued);
@ -2612,6 +2609,8 @@ public class ServiceSynchronize extends LifecycleService {
stopSelf(); stopSelf();
} }
} }
wl.release();
} }
} }
}); });
@ -2635,7 +2634,6 @@ public class ServiceSynchronize extends LifecycleService {
new Intent(context, ServiceSynchronize.class) new Intent(context, ServiceSynchronize.class)
.setAction("reload") .setAction("reload")
.putExtra("reason", reason)); .putExtra("reason", reason));
JobDaily.schedule(context);
} }
private class ServiceState { private class ServiceState {