mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-27 04:04:43 +01:00
Sync whether or not our primary device can send SMS.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package org.thoughtcrime.securesms.migrations;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobs.StorageSyncJob;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
/**
|
||||
* Marks the AccountRecord as dirty and runs a storage sync. Can be enqueued when we've added a new
|
||||
* attribute to the AccountRecord.
|
||||
*/
|
||||
public class AccountRecordMigrationJob extends MigrationJob {
|
||||
|
||||
private static final String TAG = Log.tag(AccountRecordMigrationJob.class);
|
||||
|
||||
public static final String KEY = "AccountRecordMigrationJob";
|
||||
|
||||
AccountRecordMigrationJob() {
|
||||
this(new Parameters.Builder().build());
|
||||
}
|
||||
|
||||
private AccountRecordMigrationJob(@NonNull Parameters parameters) {
|
||||
super(parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUiBlocking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String getFactoryKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performMigration() {
|
||||
if (!TextSecurePreferences.isPushRegistered(context) || TextSecurePreferences.getLocalUuid(context) == null) {
|
||||
Log.w(TAG, "Not registered!");
|
||||
return;
|
||||
}
|
||||
|
||||
DatabaseFactory.getRecipientDatabase(context).markNeedsSync(Recipient.self().getId());
|
||||
ApplicationDependencies.getJobManager().add(new StorageSyncJob());
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean shouldRetry(@NonNull Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class Factory implements Job.Factory<AccountRecordMigrationJob> {
|
||||
@Override
|
||||
public @NonNull AccountRecordMigrationJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
||||
return new AccountRecordMigrationJob(parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class ApplicationMigrations {
|
||||
|
||||
private static final int LEGACY_CANONICAL_VERSION = 455;
|
||||
|
||||
public static final int CURRENT_VERSION = 32;
|
||||
public static final int CURRENT_VERSION = 33;
|
||||
|
||||
private static final class Version {
|
||||
static final int LEGACY = 1;
|
||||
@@ -74,6 +74,7 @@ public class ApplicationMigrations {
|
||||
// Versions 29, 30 accidentally skipped
|
||||
static final int MUTE_SYNC = 31;
|
||||
static final int PROFILE_SHARING_UPDATE = 32;
|
||||
static final int SMS_STORAGE_SYNC = 33;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,6 +313,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.PROFILE_SHARING_UPDATE, new ProfileSharingUpdateMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.SMS_STORAGE_SYNC) {
|
||||
jobs.put(Version.SMS_STORAGE_SYNC, new AccountRecordMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user