feat: force upgrade on check if identity key exists

This commit is contained in:
Harris 2021-06-09 10:35:24 +10:00
parent 51061cac0e
commit 11b44a5dde

View File

@ -57,11 +57,26 @@ public class IdentityKeyUtil {
public static boolean hasIdentityKey(Context context) {
SharedPreferences preferences = context.getSharedPreferences(MASTER_SECRET_UTIL_PREFERENCES_NAME, 0);
return
(preferences.contains(IDENTITY_PUBLIC_KEY_PREF) &&
preferences.contains(IDENTITY_PRIVATE_KEY_PREF))
boolean hasIdentityKey = (preferences.contains(IDENTITY_PUBLIC_KEY_PREF) &&
preferences.contains(IDENTITY_PRIVATE_KEY_PREF))
|| (preferences.contains(IDENTITY_PUBLIC_KEY_PREF+ENCRYPTED_SUFFIX) &&
preferences.contains(IDENTITY_PRIVATE_KEY_PREF+ENCRYPTED_SUFFIX));
preferences.contains(IDENTITY_PRIVATE_KEY_PREF+ENCRYPTED_SUFFIX));
// check if any keys are not migrated
if (hasIdentityKey) {
checkUpdate(context);
}
return hasIdentityKey;
}
private static void checkUpdate(Context context) {
// retrieve will force upgrade if available
retrieve(context,IDENTITY_PUBLIC_KEY_PREF);
retrieve(context,IDENTITY_PRIVATE_KEY_PREF);
retrieve(context,ED25519_PUBLIC_KEY);
retrieve(context,ED25519_SECRET_KEY);
retrieve(context,LOKI_SEED);
}
public static @NonNull IdentityKey getIdentityKey(@NonNull Context context) {