mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Add support for AttachmentBackfill sync messages.
This commit is contained in:
@@ -42,6 +42,7 @@ public abstract class Job {
|
||||
private long lastRunAttemptTime;
|
||||
private long nextBackoffInterval;
|
||||
|
||||
private volatile boolean cascadingFailure;
|
||||
private volatile boolean canceled;
|
||||
|
||||
protected Context context;
|
||||
@@ -106,6 +107,16 @@ public abstract class Job {
|
||||
this.canceled = true;
|
||||
}
|
||||
|
||||
/** Indicates that this job is failing because a job earlier in the chain failed. */
|
||||
final void markCascadingFailure() {
|
||||
this.cascadingFailure = true;
|
||||
}
|
||||
|
||||
/** Whether or not this job is failing because a job earlier in the chain failed. */
|
||||
protected boolean isCascadingFailure() {
|
||||
return this.cascadingFailure;
|
||||
}
|
||||
|
||||
/** Provides a default exponential backoff given the current run attempt. */
|
||||
protected final long defaultBackoff() {
|
||||
return BackoffUtil.exponentialBackoff(runAttempt + 1, RemoteConfig.getDefaultMaxBackoff());
|
||||
|
||||
@@ -145,7 +145,10 @@ class JobController {
|
||||
List<Job> dependents = onFailure(job);
|
||||
job.setContext(application);
|
||||
job.onFailure();
|
||||
Stream.of(dependents).forEach(Job::onFailure);
|
||||
for (Job child : dependents) {
|
||||
child.markCascadingFailure();
|
||||
child.onFailure();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -535,18 +535,6 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Chain after(@NonNull Job job) {
|
||||
return after(Collections.singletonList(job));
|
||||
}
|
||||
|
||||
public Chain after(@NonNull List<? extends Job> jobs) {
|
||||
if (!jobs.isEmpty()) {
|
||||
this.jobs.add(0, new ArrayList<>(jobs));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void enqueue() {
|
||||
jobManager.enqueueChain(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user