Address issues with PNI app migration.

fork-5.53.8
Greyson Parrelli 2022-02-18 23:03:24 -05:00
rodzic a207bf965a
commit 4f1aa34a46
3 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -162,6 +162,10 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
.commit()
}
fun hasPniIdentityKey(): Boolean {
return store.containsKey(KEY_PNI_IDENTITY_PUBLIC_KEY)
}
/** Generates and saves an identity key pair for the PNI identity. Should only be done once. */
fun generatePniIdentityKey() {
Log.i(TAG, "Generating a new PNI identity key pair.")

Wyświetl plik

@ -98,9 +98,10 @@ public class ApplicationMigrations {
static final int CHANGE_NUMBER_CAPABILITY_4 = 54;
static final int KBS_MIGRATION = 55;
static final int PNI_IDENTITY = 56;
static final int PNI_IDENTITY_2 = 57;
}
public static final int CURRENT_VERSION = 56;
public static final int CURRENT_VERSION = 57;
/**
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
@ -426,6 +427,10 @@ public class ApplicationMigrations {
jobs.put(Version.PNI_IDENTITY, new PniAccountInitializationMigrationJob());
}
if (lastSeenVersion < Version.PNI_IDENTITY_2) {
jobs.put(Version.PNI_IDENTITY_2, new PniAccountInitializationMigrationJob());
}
return jobs;
}

Wyświetl plik

@ -63,6 +63,11 @@ public class PniAccountInitializationMigrationJob extends MigrationJob {
return;
}
if (SignalStore.account().hasPniIdentityKey()) {
Log.w(TAG, "Already generated the PNI identity. Skipping.");
return;
}
SignalStore.account().generatePniIdentityKey();
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();