mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Fix issue where we could enqueue unsatisfiable jobs during registration.
This commit is contained in:
@@ -103,6 +103,10 @@ class JobController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chainContainsUnsatisfiableConditions(chain)) {
|
||||||
|
throw new AssertionError("Unsatisfiable conditions found in job chain!");
|
||||||
|
}
|
||||||
|
|
||||||
insertJobChain(chain);
|
insertJobChain(chain);
|
||||||
scheduleJobs(chain.get(0));
|
scheduleJobs(chain.get(0));
|
||||||
}
|
}
|
||||||
@@ -402,6 +406,20 @@ class JobController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
private boolean chainContainsUnsatisfiableConditions(@NonNull List<List<Job>> chain) {
|
||||||
|
int firstGlobalPriority = chain.get(0).get(0).getParameters().getGlobalPriority();
|
||||||
|
for (List<Job> segment : chain) {
|
||||||
|
for (Job job : segment) {
|
||||||
|
if (job.getParameters().getGlobalPriority() > firstGlobalPriority) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private boolean exceedsMaximumInstances(@NonNull Job job) {
|
private boolean exceedsMaximumInstances(@NonNull Job job) {
|
||||||
boolean exceedsFactory = job.getParameters().getMaxInstancesForFactory() != Job.Parameters.UNLIMITED &&
|
boolean exceedsFactory = job.getParameters().getMaxInstancesForFactory() != Job.Parameters.UNLIMITED &&
|
||||||
|
|||||||
@@ -878,7 +878,7 @@ class RegistrationViewModel : ViewModel() {
|
|||||||
stopwatch.split("account-restore")
|
stopwatch.split("account-restore")
|
||||||
|
|
||||||
AppDependencies.jobManager
|
AppDependencies.jobManager
|
||||||
.startChain(StorageSyncJob.forRemoteChange())
|
.startChain(StorageSyncJob.forAccountRestore())
|
||||||
.then(ReclaimUsernameAndLinkJob())
|
.then(ReclaimUsernameAndLinkJob())
|
||||||
.enqueueAndBlockUntilCompletion(TimeUnit.SECONDS.toMillis(10))
|
.enqueueAndBlockUntilCompletion(TimeUnit.SECONDS.toMillis(10))
|
||||||
stopwatch.split("storage-sync")
|
stopwatch.split("storage-sync")
|
||||||
|
|||||||
Reference in New Issue
Block a user