From 6db86eb958d51010284f43bbc0bc2c5280a47d2c Mon Sep 17 00:00:00 2001 From: jubb Date: Thu, 18 Feb 2021 10:10:27 +1100 Subject: [PATCH 1/2] fix: filter jobs that can be executed with the current factories --- .../thoughtcrime/securesms/jobs/FastJobStorage.java | 1 + .../securesms/jobs/JobManagerFactories.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/FastJobStorage.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/FastJobStorage.java index 697309aeff..3b50dc2733 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/FastJobStorage.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/FastJobStorage.java @@ -90,6 +90,7 @@ public class FastJobStorage implements JobStorage { @Override public synchronized @NonNull List getPendingJobsWithNoDependenciesInCreatedOrder(long currentTime) { return Stream.of(jobs) + .filter(j -> JobManagerFactories.hasFactoryForKey(j.getFactoryKey())) .filterNot(JobSpec::isRunning) .filter(this::firstInQueue) .filter(j -> !dependenciesByJobId.containsKey(j.getId()) || dependenciesByJobId.get(j.getId()).isEmpty()) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/JobManagerFactories.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/JobManagerFactories.java index b5ab7a0e66..e011323647 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/JobManagerFactories.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/JobManagerFactories.java @@ -20,15 +20,20 @@ import org.thoughtcrime.securesms.loki.protocol.ClosedGroupUpdateMessageSendJob; import org.thoughtcrime.securesms.loki.protocol.ClosedGroupUpdateMessageSendJobV2; import org.thoughtcrime.securesms.loki.protocol.NullMessageSendJob; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; public final class JobManagerFactories { + private static Collection factoryKeys = new ArrayList<>(); + public static Map getJobFactories(@NonNull Application application) { - return new HashMap() {{ + HashMap factoryHashMap = new HashMap() {{ put(AttachmentDownloadJob.KEY, new AttachmentDownloadJob.Factory()); put(AttachmentUploadJob.KEY, new AttachmentUploadJob.Factory()); put(AvatarDownloadJob.KEY, new AvatarDownloadJob.Factory()); @@ -61,6 +66,8 @@ public final class JobManagerFactories { put(PrepareAttachmentAudioExtrasJob.KEY, new PrepareAttachmentAudioExtrasJob.Factory()); put(ResetThreadSessionJob.KEY, new ResetThreadSessionJob.Factory()); }}; + factoryKeys.addAll(factoryHashMap.keySet()); + return factoryHashMap; } public static Map getConstraintFactories(@NonNull Application application) { @@ -77,4 +84,8 @@ public final class JobManagerFactories { new NetworkConstraintObserver(application), new SqlCipherMigrationConstraintObserver()); } + + public static boolean hasFactoryForKey(String factoryKey) { + return factoryKeys.contains(factoryKey); + } } From f45a2851412e9ec6a3a3679353b1fdf71e1ea0bc Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Thu, 18 Feb 2021 10:30:21 +1100 Subject: [PATCH 2/2] Update version number --- app/build.gradle | 4 ++-- .../securesms/database/helpers/SQLCipherOpenHelper.java | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6727cdf697..4e1a2e6974 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -158,8 +158,8 @@ dependencies { testImplementation 'org.robolectric:shadows-multidex:4.2' } -def canonicalVersionCode = 139 -def canonicalVersionName = "1.7.1" +def canonicalVersionCode = 140 +def canonicalVersionName = "1.7.2" def postFixSize = 10 def abiPostFix = ['armeabi-v7a' : 1, diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index 4549490782..650d688a65 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -54,7 +54,6 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { private static final int lokiV16 = 37; private static final int lokiV17 = 38; private static final int lokiV18_CLEAR_BG_POLL_JOBS = 39; - //TODO Merge all "refactor" migrations to one before pushing to the main repo. private static final int lokiV19 = 40; private static final int lokiV20 = 41;