Merge branch 'dev' of https://github.com/oxen-io/session-android into refactor_clean_0

This commit is contained in:
Ryan ZHAO 2021-02-18 10:48:12 +11:00
commit b85c9eb781
4 changed files with 15 additions and 4 deletions

View File

@ -158,8 +158,8 @@ dependencies {
testImplementation 'org.robolectric:shadows-multidex:4.2' testImplementation 'org.robolectric:shadows-multidex:4.2'
} }
def canonicalVersionCode = 139 def canonicalVersionCode = 140
def canonicalVersionName = "1.7.1" def canonicalVersionName = "1.7.2"
def postFixSize = 10 def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1, def abiPostFix = ['armeabi-v7a' : 1,

View File

@ -54,7 +54,6 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV16 = 37; private static final int lokiV16 = 37;
private static final int lokiV17 = 38; private static final int lokiV17 = 38;
private static final int lokiV18_CLEAR_BG_POLL_JOBS = 39; 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 lokiV19 = 40;
private static final int lokiV20 = 41; private static final int lokiV20 = 41;

View File

@ -90,6 +90,7 @@ public class FastJobStorage implements JobStorage {
@Override @Override
public synchronized @NonNull List<JobSpec> getPendingJobsWithNoDependenciesInCreatedOrder(long currentTime) { public synchronized @NonNull List<JobSpec> getPendingJobsWithNoDependenciesInCreatedOrder(long currentTime) {
return Stream.of(jobs) return Stream.of(jobs)
.filter(j -> JobManagerFactories.hasFactoryForKey(j.getFactoryKey()))
.filterNot(JobSpec::isRunning) .filterNot(JobSpec::isRunning)
.filter(this::firstInQueue) .filter(this::firstInQueue)
.filter(j -> !dependenciesByJobId.containsKey(j.getId()) || dependenciesByJobId.get(j.getId()).isEmpty()) .filter(j -> !dependenciesByJobId.containsKey(j.getId()) || dependenciesByJobId.get(j.getId()).isEmpty())

View File

@ -19,15 +19,20 @@ import org.thoughtcrime.securesms.loki.api.ResetThreadSessionJob;
import org.thoughtcrime.securesms.loki.protocol.ClosedGroupUpdateMessageSendJobV2; import org.thoughtcrime.securesms.loki.protocol.ClosedGroupUpdateMessageSendJobV2;
import org.thoughtcrime.securesms.loki.protocol.NullMessageSendJob; import org.thoughtcrime.securesms.loki.protocol.NullMessageSendJob;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public final class JobManagerFactories { public final class JobManagerFactories {
private static Collection<String> factoryKeys = new ArrayList<>();
public static Map<String, Job.Factory> getJobFactories(@NonNull Application application) { public static Map<String, Job.Factory> getJobFactories(@NonNull Application application) {
return new HashMap<String, Job.Factory>() {{ HashMap<String, Job.Factory> factoryHashMap = new HashMap<String, Job.Factory>() {{
put(AttachmentDownloadJob.KEY, new AttachmentDownloadJob.Factory()); put(AttachmentDownloadJob.KEY, new AttachmentDownloadJob.Factory());
put(AttachmentUploadJob.KEY, new AttachmentUploadJob.Factory()); put(AttachmentUploadJob.KEY, new AttachmentUploadJob.Factory());
put(AvatarDownloadJob.KEY, new AvatarDownloadJob.Factory()); put(AvatarDownloadJob.KEY, new AvatarDownloadJob.Factory());
@ -59,6 +64,8 @@ public final class JobManagerFactories {
put(PrepareAttachmentAudioExtrasJob.KEY, new PrepareAttachmentAudioExtrasJob.Factory()); put(PrepareAttachmentAudioExtrasJob.KEY, new PrepareAttachmentAudioExtrasJob.Factory());
put(ResetThreadSessionJob.KEY, new ResetThreadSessionJob.Factory()); put(ResetThreadSessionJob.KEY, new ResetThreadSessionJob.Factory());
}}; }};
factoryKeys.addAll(factoryHashMap.keySet());
return factoryHashMap;
} }
public static Map<String, Constraint.Factory> getConstraintFactories(@NonNull Application application) { public static Map<String, Constraint.Factory> getConstraintFactories(@NonNull Application application) {
@ -75,4 +82,8 @@ public final class JobManagerFactories {
new NetworkConstraintObserver(application), new NetworkConstraintObserver(application),
new SqlCipherMigrationConstraintObserver()); new SqlCipherMigrationConstraintObserver());
} }
public static boolean hasFactoryForKey(String factoryKey) {
return factoryKeys.contains(factoryKey);
}
} }