Simplification, fix

pull/169/head
M66B 5 years ago
parent 12bc106a75
commit 46d5289756

@ -100,7 +100,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private static final int BACKOFF_ERROR_AFTER = 16; // seconds
private static final List<String> PREF_EVAL = Collections.unmodifiableList(Arrays.asList(
"enabled", "poll_interval"
"enabled", "poll_interval" // restart account(s)
));
private static final List<String> PREF_RELOAD = Collections.unmodifiableList(Arrays.asList(
@ -179,16 +179,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
long now = new Date().getTime();
boolean scheduled = (schedule == null || now >= schedule[0] && now < schedule[1]);
Long account = null;
if (command != null) {
account = command.getLong("account", -1);
if (account < 0)
account = null;
if (command == null) {
command = new Bundle();
command.putString("name", "eval");
}
List<TupleAccountNetworkState> result = new ArrayList<>();
for (TupleAccountState accountState : accountStates)
if (account == null || account.equals(accountState.id))
result.add(new TupleAccountNetworkState(
enabled && pollInterval == 0 && scheduled,
command,
@ -271,6 +268,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (current.accountState.synchronize)
operations += current.accountState.operations;
long account = current.command.getLong("account", -1);
if (account > 0 && !current.accountState.id.equals(account))
continue;
int index = accountStates.indexOf(current);
if (index < 0) {
if (current.canRun()) {
@ -284,7 +285,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
state.setNetworkState(current.networkState);
boolean reload = false;
if (current.command != null)
switch (current.command.getString("name")) {
case "reload":
reload = true;
@ -296,7 +296,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.i("### waking up " + current);
state.release();
}
continue;
break;
}
accountStates.remove(index);

@ -26,11 +26,18 @@ import androidx.annotation.Nullable;
public class TupleAccountNetworkState {
public boolean enabled;
@NonNull
public Bundle command;
@NonNull
public ConnectionHelper.NetworkState networkState;
@NonNull
public TupleAccountState accountState;
public TupleAccountNetworkState(boolean enabled, Bundle command, ConnectionHelper.NetworkState networkState, TupleAccountState accountState) {
public TupleAccountNetworkState(
boolean enabled,
@NonNull Bundle command,
@NonNull ConnectionHelper.NetworkState networkState,
@NonNull TupleAccountState accountState) {
this.enabled = enabled;
this.command = command;
this.networkState = networkState;

Loading…
Cancel
Save