mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-24 12:01:28 +00:00
feat: force upgrade on check if identity key exists
This commit is contained in:
parent
51061cac0e
commit
11b44a5dde
@ -57,11 +57,26 @@ public class IdentityKeyUtil {
|
|||||||
public static boolean hasIdentityKey(Context context) {
|
public static boolean hasIdentityKey(Context context) {
|
||||||
SharedPreferences preferences = context.getSharedPreferences(MASTER_SECRET_UTIL_PREFERENCES_NAME, 0);
|
SharedPreferences preferences = context.getSharedPreferences(MASTER_SECRET_UTIL_PREFERENCES_NAME, 0);
|
||||||
|
|
||||||
return
|
boolean hasIdentityKey = (preferences.contains(IDENTITY_PUBLIC_KEY_PREF) &&
|
||||||
(preferences.contains(IDENTITY_PUBLIC_KEY_PREF) &&
|
|
||||||
preferences.contains(IDENTITY_PRIVATE_KEY_PREF))
|
preferences.contains(IDENTITY_PRIVATE_KEY_PREF))
|
||||||
|| (preferences.contains(IDENTITY_PUBLIC_KEY_PREF+ENCRYPTED_SUFFIX) &&
|
|| (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) {
|
public static @NonNull IdentityKey getIdentityKey(@NonNull Context context) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user