mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Retrieve profiles in parallel.
This commit is contained in:
@@ -3,9 +3,13 @@ package org.thoughtcrime.securesms.jobmanager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Data {
|
||||
@@ -76,6 +80,14 @@ public class Data {
|
||||
return stringArrays.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for {@link #getStringArray(String)} that returns the value as a list.
|
||||
*/
|
||||
public List<String> getStringArrayAsList(@NonNull String key) {
|
||||
throwIfAbsent(stringArrays, key);
|
||||
return Arrays.asList(stringArrays.get(key));
|
||||
}
|
||||
|
||||
|
||||
public boolean hasInt(@NonNull String key) {
|
||||
return integers.containsKey(key);
|
||||
@@ -255,6 +267,14 @@ public class Data {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for {@link #putStringArray(String, String[])} that takes a list.
|
||||
*/
|
||||
public Builder putStringListAsArray(@NonNull String key, @NonNull List<String> value) {
|
||||
stringArrays.put(key, value.toArray(new String[0]));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder putInt(@NonNull String key, int value) {
|
||||
integers.put(key, value);
|
||||
return this;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
|
||||
private static final String TAG = JobManager.class.getSimpleName();
|
||||
|
||||
public static final int CURRENT_VERSION = 6;
|
||||
public static final int CURRENT_VERSION = 7;
|
||||
|
||||
private final Application application;
|
||||
private final Configuration configuration;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.migrations;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobMigration;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class RetrieveProfileJobMigration extends JobMigration {
|
||||
|
||||
private static final String TAG = Log.tag(RetrieveProfileJobMigration.class);
|
||||
|
||||
public RetrieveProfileJobMigration() {
|
||||
super(7);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
Log.i(TAG, "Running.");
|
||||
|
||||
if ("RetrieveProfileJob".equals(jobData.getFactoryKey())) {
|
||||
return migrateRetrieveProfileJob(jobData);
|
||||
}
|
||||
return jobData;
|
||||
}
|
||||
|
||||
private static @NonNull JobData migrateRetrieveProfileJob(@NonNull JobData jobData) {
|
||||
Data data = jobData.getData();
|
||||
|
||||
if (data.hasString("recipient")) {
|
||||
Log.i(TAG, "Migrating job.");
|
||||
|
||||
String recipient = data.getString("recipient");
|
||||
return jobData.withData(new Data.Builder()
|
||||
.putStringArray("recipients", new String[] { recipient })
|
||||
.build());
|
||||
} else {
|
||||
return jobData;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user