mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Improve conditional logic around prekey refresh schedule.
This commit is contained in:
@@ -128,9 +128,10 @@ public class ApplicationMigrations {
|
||||
static final int INDEX_DATABASE_MIGRATION = 84;
|
||||
static final int ACCOUNT_CONSISTENCY_CHECK = 85;
|
||||
static final int BACKUP_JITTER = 86;
|
||||
static final int PREKEY_SYNC = 87;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 86;
|
||||
public static final int CURRENT_VERSION = 87;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -576,6 +577,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.BACKUP_JITTER, new BackupJitterMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.PREKEY_SYNC) {
|
||||
jobs.put(Version.PREKEY_SYNC, new PreKeysSyncMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.PreKeysSyncJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
|
||||
/**
|
||||
* Schedules a prekey sync.
|
||||
*/
|
||||
internal class PreKeysSyncMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
val TAG = Log.tag(PreKeysSyncMigrationJob::class.java)
|
||||
const val KEY = "PreKeysSyncIndexMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
SignalStore.misc().lastFullPrekeyRefreshTime = 0
|
||||
PreKeysSyncJob.enqueue()
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<PreKeysSyncMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): PreKeysSyncMigrationJob {
|
||||
return PreKeysSyncMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user