mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Fix deadlock in JobManager initialization.
This commit is contained in:
@@ -54,7 +54,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
@GuardedBy("emptyQueueListeners")
|
||||
private final Set<EmptyQueueListener> emptyQueueListeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
private volatile boolean initialized;
|
||||
private volatile boolean initialized = false;
|
||||
|
||||
public JobManager(@NonNull Application application, @NonNull Configuration configuration) {
|
||||
this.application = application;
|
||||
@@ -73,6 +73,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
|
||||
executor.execute(() -> {
|
||||
synchronized (this) {
|
||||
Log.d(TAG, "Starting initialization: " + Thread.currentThread());
|
||||
JobStorage jobStorage = configuration.getJobStorage();
|
||||
jobStorage.init();
|
||||
|
||||
@@ -91,6 +92,10 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
|
||||
initialized = true;
|
||||
notifyAll();
|
||||
|
||||
jobController.wakeUp();
|
||||
|
||||
Log.d(TAG, "Initialized");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -343,6 +348,11 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
|
||||
@Override
|
||||
public void onConstraintMet(@NonNull String reason) {
|
||||
if (!initialized) {
|
||||
Log.d(TAG, "Ignoring early onConstraintMet(" + reason + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG, "onConstraintMet(" + reason + ")");
|
||||
wakeUp();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user