|
@ -1549,6 +1549,7 @@ public class ServiceSynchronize extends LifecycleService { |
|
|
|
|
|
|
|
|
private void start() { |
|
|
private void start() { |
|
|
EntityLog.log(ServiceSynchronize.this, "Main start"); |
|
|
EntityLog.log(ServiceSynchronize.this, "Main start"); |
|
|
|
|
|
|
|
|
state = new ServiceState(); |
|
|
state = new ServiceState(); |
|
|
|
|
|
|
|
|
main = new Thread(new Runnable() { |
|
|
main = new Thread(new Runnable() { |
|
@ -1556,9 +1557,9 @@ public class ServiceSynchronize extends LifecycleService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void run() { |
|
|
public void run() { |
|
|
DB db = DB.getInstance(ServiceSynchronize.this); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
|
|
|
DB db = DB.getInstance(ServiceSynchronize.this); |
|
|
|
|
|
|
|
|
outbox = db.folder().getOutbox(); |
|
|
outbox = db.folder().getOutbox(); |
|
|
if (outbox == null) { |
|
|
if (outbox == null) { |
|
|
EntityLog.log(ServiceSynchronize.this, "No outbox, halt"); |
|
|
EntityLog.log(ServiceSynchronize.this, "No outbox, halt"); |
|
@ -1604,11 +1605,12 @@ public class ServiceSynchronize extends LifecycleService { |
|
|
threads.add(t); |
|
|
threads.add(t); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
EntityLog.log(ServiceSynchronize.this, "Main started " + main); |
|
|
|
|
|
|
|
|
EntityLog.log(ServiceSynchronize.this, "Main started"); |
|
|
|
|
|
|
|
|
synchronized (state) { |
|
|
synchronized (state) { |
|
|
try { |
|
|
try { |
|
|
state.wait(); |
|
|
|
|
|
|
|
|
if (state.running) |
|
|
|
|
|
state.wait(); |
|
|
} catch (InterruptedException ex) { |
|
|
} catch (InterruptedException ex) { |
|
|
Log.w(Helper.TAG, "main wait " + ex.toString()); |
|
|
Log.w(Helper.TAG, "main wait " + ex.toString()); |
|
|
} |
|
|
} |
|
@ -1638,7 +1640,8 @@ public class ServiceSynchronize extends LifecycleService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void stop() { |
|
|
private void stop() { |
|
|
EntityLog.log(ServiceSynchronize.this, "Main stop " + main); |
|
|
|
|
|
|
|
|
EntityLog.log(ServiceSynchronize.this, "Main stop"); |
|
|
|
|
|
|
|
|
synchronized (state) { |
|
|
synchronized (state) { |
|
|
state.running = false; |
|
|
state.running = false; |
|
|
state.notifyAll(); |
|
|
state.notifyAll(); |
|
@ -1648,10 +1651,10 @@ public class ServiceSynchronize extends LifecycleService { |
|
|
main.interrupt(); |
|
|
main.interrupt(); |
|
|
join(main); |
|
|
join(main); |
|
|
|
|
|
|
|
|
|
|
|
EntityLog.log(ServiceSynchronize.this, "Main stopped"); |
|
|
|
|
|
|
|
|
main = null; |
|
|
main = null; |
|
|
state = null; |
|
|
state = null; |
|
|
|
|
|
|
|
|
EntityLog.log(ServiceSynchronize.this, "Main stopped " + main); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void restart() { |
|
|
private void restart() { |
|
|