Fixed orphan sync threads

pull/200/head
M66B 3 years ago
parent 0a417725eb
commit 2e85b3bc0d

@ -263,14 +263,17 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
boolean sync = current.command.getBoolean("sync", false);
boolean force = current.command.getBoolean("force", false);
if (force)
if (force) {
sync = true;
current.accountState.operations++;
}
int index = accountStates.indexOf(current);
if (index < 0) {
if (current.canRun(force)) {
if (current.canRun()) {
EntityLog.log(ServiceSynchronize.this, "### new " + current +
" start=" + current.canRun(force) +
" force=" + force +
" start=" + current.canRun() +
" sync=" + current.accountState.isEnabled(current.enabled) +
" enabled=" + current.accountState.synchronize +
" ondemand=" + current.accountState.ondemand +
@ -300,14 +303,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
// Some networks disallow email server connections:
// - reload on network type change when disconnected
if (reload ||
prev.canRun(force) != current.canRun(force) ||
prev.canRun() != current.canRun() ||
!prev.accountState.equals(current.accountState)) {
if (prev.canRun(force) || current.canRun(force))
if (prev.canRun() || current.canRun())
EntityLog.log(ServiceSynchronize.this, "### changed " + current +
" reload=" + reload +
" force=" + force +
" stop=" + prev.canRun(force) +
" start=" + current.canRun(force) +
" stop=" + prev.canRun() +
" start=" + current.canRun() +
" sync=" + sync +
" enabled=" + current.accountState.isEnabled(current.enabled) +
" should=" + current.accountState.shouldRun(current.enabled) +
@ -319,11 +322,11 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
" tbd=" + current.accountState.tbd +
" state=" + current.accountState.state +
" active=" + prev.networkState.getActive() + "/" + current.networkState.getActive());
if (prev.canRun(force)) {
if (prev.canRun()) {
event = true;
stop(prev);
}
if (current.canRun(force)) {
if (current.canRun()) {
event = true;
start(current, current.accountState.isEnabled(current.enabled) || sync, force);
}

@ -44,8 +44,8 @@ public class TupleAccountNetworkState {
this.accountState = accountState;
}
public boolean canRun(boolean force) {
return (this.networkState.isSuitable() && this.accountState.shouldRun(enabled || force));
public boolean canRun() {
return (this.networkState.isSuitable() && this.accountState.shouldRun(enabled));
}
@Override

Loading…
Cancel
Save