diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index 167b01c97..0be3862e2 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -147,8 +147,6 @@ public class ApplicationContext extends MultiDexApplication implements DefaultLi } private void initializeJobManager() { - this.jobManager = JobManager.newBuilder(this) - .withConsumerThreads(5) - .build(); + this.jobManager = new JobManager(this, 5); } } diff --git a/src/org/thoughtcrime/securesms/jobmanager/JobManager.java b/src/org/thoughtcrime/securesms/jobmanager/JobManager.java index fad09d39e..15e468363 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/JobManager.java +++ b/src/org/thoughtcrime/securesms/jobmanager/JobManager.java @@ -3,11 +3,6 @@ package org.thoughtcrime.securesms.jobmanager; import android.content.Context; import android.os.PowerManager; -import org.thoughtcrime.securesms.jobmanager.requirements.RequirementListener; -import org.thoughtcrime.securesms.jobmanager.requirements.RequirementProvider; - -import java.util.LinkedList; -import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; @@ -16,40 +11,22 @@ import java.util.concurrent.Executors; * that are executed once a Job's {@link org.thoughtcrime.securesms.jobmanager.requirements.Requirement}s * are met. */ -public class JobManager implements RequirementListener { +public class JobManager { private final JobQueue jobQueue = new JobQueue(); private final Executor eventExecutor = Executors.newSingleThreadExecutor(); private final Context context; - private final List requirementProviders; - private JobManager(Context context, - List requirementProviders, - int consumers) + public JobManager(Context context, int consumers) { this.context = context; - this.requirementProviders = requirementProviders; - - if (requirementProviders != null && !requirementProviders.isEmpty()) { - for (RequirementProvider provider : requirementProviders) { - provider.setListener(this); - } - } for (int i=0;i requirementProviders; - private int consumerThreads; - - Builder(Context context) { - this.context = context; - this.consumerThreads = 5; - } - - /** - * Set the number of threads dedicated to consuming Jobs from the queue and executing them. - * - * @param consumerThreads The number of threads. - * @return The builder. - */ - public Builder withConsumerThreads(int consumerThreads) { - this.consumerThreads = consumerThreads; - return this; - } - - /** - * @return A constructed JobManager. - */ - public JobManager build() { - if (requirementProviders == null) { - requirementProviders = new LinkedList<>(); - } - - return new JobManager(context, requirementProviders, - consumerThreads); - } - } - } diff --git a/src/org/thoughtcrime/securesms/jobmanager/JobQueue.java b/src/org/thoughtcrime/securesms/jobmanager/JobQueue.java index acd8919ee..1b01bd6e6 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/JobQueue.java +++ b/src/org/thoughtcrime/securesms/jobmanager/JobQueue.java @@ -20,7 +20,6 @@ import androidx.annotation.NonNull; import java.util.HashMap; import java.util.LinkedList; -import java.util.List; import java.util.ListIterator; import java.util.Map; @@ -29,10 +28,6 @@ class JobQueue { private final Map activeGroupIds = new HashMap<>(); private final LinkedList jobQueue = new LinkedList<>(); - synchronized void onRequirementStatusChanged() { - notifyAll(); - } - synchronized void add(Job job) { jobQueue.add(job); processJobAddition(job); diff --git a/src/org/thoughtcrime/securesms/jobmanager/requirements/RequirementListener.java b/src/org/thoughtcrime/securesms/jobmanager/requirements/RequirementListener.java deleted file mode 100644 index a548adfb9..000000000 --- a/src/org/thoughtcrime/securesms/jobmanager/requirements/RequirementListener.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (C) 2014 Open Whisper Systems - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.thoughtcrime.securesms.jobmanager.requirements; - -public interface RequirementListener { - public void onRequirementStatusChanged(); -} diff --git a/src/org/thoughtcrime/securesms/jobmanager/requirements/RequirementProvider.java b/src/org/thoughtcrime/securesms/jobmanager/requirements/RequirementProvider.java deleted file mode 100644 index 95e1c19af..000000000 --- a/src/org/thoughtcrime/securesms/jobmanager/requirements/RequirementProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (C) 2014 Open Whisper Systems - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.thoughtcrime.securesms.jobmanager.requirements; - -/** - * Notifies listeners when a {@link org.thoughtcrime.securesms.jobmanager.requirements.Requirement}'s - * state is likely to have changed. - */ -public interface RequirementProvider { - - /** - * The {@link org.thoughtcrime.securesms.jobmanager.requirements.RequirementListener} to call when - * a {@link org.thoughtcrime.securesms.jobmanager.requirements.Requirement}'s status is likely to - * have changed. - * - * @param listener The listener to call. - */ - public void setListener(RequirementListener listener); -}