mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 10:20:25 +01:00
Fix bad migration state that could happen during a device transfer.
This commit is contained in:
committed by
Alex Hart
parent
63ce2de3bf
commit
8c707555f2
@@ -0,0 +1,42 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.AccountConsistencyWorkerJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
|
||||
/**
|
||||
* Migration to help address some account consistency issues that resulted under very specific situation post-device-transfer.
|
||||
*/
|
||||
internal class AccountConsistencyMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
const val KEY = "AccountConsistencyMigrationJob"
|
||||
|
||||
val TAG = Log.tag(AccountConsistencyMigrationJob::class.java)
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
if (!SignalStore.account().hasAciIdentityKey()) {
|
||||
Log.i(TAG, "No identity set yet, skipping.")
|
||||
return
|
||||
}
|
||||
|
||||
ApplicationDependencies.getJobManager().add(AccountConsistencyWorkerJob())
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<AccountConsistencyMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): AccountConsistencyMigrationJob {
|
||||
return AccountConsistencyMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,9 +127,10 @@ public class ApplicationMigrations {
|
||||
static final int TO_FROM_RECIPIENTS = 82;
|
||||
static final int REBUILD_MESSAGE_FTS_INDEX_4 = 83;
|
||||
static final int INDEX_DATABASE_MIGRATION = 84;
|
||||
static final int ACCOUNT_CONSISTENCY_CHECK = 85;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 84;
|
||||
public static final int CURRENT_VERSION = 85;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -567,6 +568,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.INDEX_DATABASE_MIGRATION, new DatabaseMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.ACCOUNT_CONSISTENCY_CHECK) {
|
||||
jobs.put(Version.ACCOUNT_CONSISTENCY_CHECK, new AccountConsistencyMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user