Fixed FTS / unmetered accounts only

This commit is contained in:
M66B 2022-06-22 17:27:15 +02:00
parent 20a1211518
commit 8aaf4c9102
2 changed files with 10 additions and 3 deletions

View File

@ -273,6 +273,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
int accounts = 0;
int operations = 0;
boolean event = false;
boolean runFts = true;
boolean runService = false;
for (TupleAccountNetworkState current : accountNetworkStates) {
Log.d("### evaluating " + current);
@ -292,6 +293,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}
if (current.accountState.synchronize)
operations += current.accountState.operations;
if (current.accountState.operations > 0 && current.canConnect())
runFts = false;
long account = current.command.getLong("account", -1);
if (account > 0 && !current.accountState.id.equals(account))
@ -410,7 +413,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (lastAccounts != accounts || lastOperations != operations) {
lastAccounts = accounts;
lastOperations = operations;
if (operations == 0) {
if (runFts) {
fts = true;
WorkerFts.init(ServiceSynchronize.this, false);
} else if (fts) {

View File

@ -61,9 +61,13 @@ public class TupleAccountNetworkState {
this.enabled = false;
}
public boolean canRun() {
public boolean canConnect() {
boolean unmetered = jconditions.optBoolean("unmetered");
if (unmetered && !this.networkState.isUnmetered())
return (!unmetered || this.networkState.isUnmetered());
}
public boolean canRun() {
if (!canConnect())
return false;
return (this.networkState.isSuitable() && this.accountState.shouldRun(enabled));