mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 19:29:54 +01:00
Update the storage service.
This commit is contained in:
@@ -40,7 +40,7 @@ public class ApplicationMigrations {
|
||||
|
||||
private static final int LEGACY_CANONICAL_VERSION = 455;
|
||||
|
||||
public static final int CURRENT_VERSION = 10;
|
||||
public static final int CURRENT_VERSION = 11;
|
||||
|
||||
private static final class Version {
|
||||
static final int LEGACY = 1;
|
||||
@@ -53,6 +53,7 @@ public class ApplicationMigrations {
|
||||
static final int STICKERS_LAUNCH = 8;
|
||||
static final int TEST_ARGON2 = 9;
|
||||
static final int SWOON_STICKERS = 10;
|
||||
static final int STORAGE_SERVICE = 11;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,6 +206,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.SWOON_STICKERS, new StickerAdditionMigrationJob(BlessedPacks.SWOON_HANDS, BlessedPacks.SWOON_FACES));
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.STORAGE_SERVICE) {
|
||||
jobs.put(Version.STORAGE_SERVICE, new StorageServiceMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package org.thoughtcrime.securesms.migrations;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceKeysUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.StickerPackDownloadJob;
|
||||
import org.thoughtcrime.securesms.jobs.StorageSyncJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.stickers.BlessedPacks;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class StorageServiceMigrationJob extends MigrationJob {
|
||||
|
||||
private static final String TAG = Log.tag(StorageServiceMigrationJob.class);
|
||||
|
||||
public static final String KEY = "StorageServiceMigrationJob";
|
||||
|
||||
StorageServiceMigrationJob() {
|
||||
this(new Parameters.Builder().build());
|
||||
}
|
||||
|
||||
private StorageServiceMigrationJob(@NonNull Parameters parameters) {
|
||||
super(parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUiBlocking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String getFactoryKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performMigration() {
|
||||
JobManager jobManager = ApplicationDependencies.getJobManager();
|
||||
|
||||
if (TextSecurePreferences.isMultiDevice(context)) {
|
||||
Log.i(TAG, "Multi-device.");
|
||||
jobManager.startChain(new MultiDeviceKeysUpdateJob())
|
||||
.then(new StorageSyncJob())
|
||||
.enqueue();
|
||||
} else {
|
||||
Log.i(TAG, "Single-device.");
|
||||
jobManager.add(new StorageSyncJob());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean shouldRetry(@NonNull Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class Factory implements Job.Factory<StorageServiceMigrationJob> {
|
||||
@Override
|
||||
public @NonNull StorageServiceMigrationJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
||||
return new StorageServiceMigrationJob(parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user