mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Initialize WorkManager ourself.
This gives us more control over when it happens, as well as lets us set things like the debug level. Also let's us get rid of the synchronized block we had in Application#onCreate().
This commit is contained in:
parent
4da1af9a7b
commit
07d7af6e75
@ -572,6 +572,12 @@
|
||||
android:authorities="org.thoughtcrime.securesms.database.attachment"
|
||||
android:exported="false" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.work.impl.WorkManagerInitializer"
|
||||
android:authorities="${applicationId}.workmanager-init"
|
||||
android:exported="false"
|
||||
tools:node="remove" />
|
||||
|
||||
<receiver android:name=".service.BootReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
|
@ -61,6 +61,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.work.Configuration;
|
||||
import androidx.work.WorkManager;
|
||||
import dagger.ObjectGraph;
|
||||
|
||||
@ -80,7 +81,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
private JobManager jobManager;
|
||||
private ObjectGraph objectGraph;
|
||||
private PersistentLogger persistentLogger;
|
||||
private boolean initialized;
|
||||
|
||||
private volatile boolean isAppVisible;
|
||||
|
||||
@ -90,33 +90,20 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
synchronized (this) {
|
||||
super.onCreate();
|
||||
initializeRandomNumberFix();
|
||||
initializeLogging();
|
||||
initializeCrashHandling();
|
||||
initializeDependencyInjection();
|
||||
initializeJobManager();
|
||||
initializeExpiringMessageManager();
|
||||
initializeGcmCheck();
|
||||
initializeSignedPreKeyCheck();
|
||||
initializePeriodicTasks();
|
||||
initializeCircumvention();
|
||||
initializeWebRtc();
|
||||
NotificationChannels.create(this);
|
||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
||||
|
||||
initialized = true;
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureInitialized() {
|
||||
synchronized (this) {
|
||||
while (!initialized) {
|
||||
Util.wait(this, 0);
|
||||
}
|
||||
}
|
||||
super.onCreate();
|
||||
initializeRandomNumberFix();
|
||||
initializeLogging();
|
||||
initializeCrashHandling();
|
||||
initializeDependencyInjection();
|
||||
initializeJobManager();
|
||||
initializeExpiringMessageManager();
|
||||
initializeGcmCheck();
|
||||
initializeSignedPreKeyCheck();
|
||||
initializePeriodicTasks();
|
||||
initializeCircumvention();
|
||||
initializeWebRtc();
|
||||
NotificationChannels.create(this);
|
||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -172,6 +159,10 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
}
|
||||
|
||||
private void initializeJobManager() {
|
||||
WorkManager.initialize(this, new Configuration.Builder()
|
||||
.setMinimumLoggingLevel(android.util.Log.DEBUG)
|
||||
.build());
|
||||
|
||||
this.jobManager = new JobManager(WorkManager.getInstance());
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,6 @@ public abstract class Job extends Worker implements Serializable {
|
||||
|
||||
log("doWork()" + logSuffix());
|
||||
|
||||
ApplicationContext.getInstance(getApplicationContext()).ensureInitialized();
|
||||
ApplicationContext.getInstance(getApplicationContext()).injectDependencies(this);
|
||||
|
||||
if (this instanceof ContextDependent) {
|
||||
|
Loading…
Reference in New Issue
Block a user