remember if key signatures table has been initialized
This commit is contained in:
parent
678a5c1562
commit
a6f97cf46e
|
@ -146,6 +146,8 @@ public final class Constants {
|
||||||
public static final String EXPERIMENTAL_SMARTPGP_VERIFY_AUTHORITY = "smartpgp_authorities_pref";
|
public static final String EXPERIMENTAL_SMARTPGP_VERIFY_AUTHORITY = "smartpgp_authorities_pref";
|
||||||
public static final String EXPERIMENTAL_SMARTPGP_AUTHORITIES = "smartpgp_authorities";
|
public static final String EXPERIMENTAL_SMARTPGP_AUTHORITIES = "smartpgp_authorities";
|
||||||
|
|
||||||
|
public static final String KEY_SIGNATURES_TABLE_INITIALIZED = "key_signatures_table_initialized";
|
||||||
|
|
||||||
public static final class Theme {
|
public static final class Theme {
|
||||||
public static final String LIGHT = "light";
|
public static final String LIGHT = "light";
|
||||||
public static final String DARK = "dark";
|
public static final String DARK = "dark";
|
||||||
|
|
|
@ -68,6 +68,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.Utf8Util;
|
import org.sufficientlysecure.keychain.util.Utf8Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,6 +84,8 @@ import org.sufficientlysecure.keychain.util.Utf8Util;
|
||||||
public class KeyWritableRepository extends KeyRepository {
|
public class KeyWritableRepository extends KeyRepository {
|
||||||
private static final int MAX_CACHED_KEY_SIZE = 1024 * 50;
|
private static final int MAX_CACHED_KEY_SIZE = 1024 * 50;
|
||||||
|
|
||||||
|
private final Context mContext;
|
||||||
|
|
||||||
public static KeyWritableRepository create(Context context) {
|
public static KeyWritableRepository create(Context context) {
|
||||||
LocalPublicKeyStorage localPublicKeyStorage = LocalPublicKeyStorage.getInstance(context);
|
LocalPublicKeyStorage localPublicKeyStorage = LocalPublicKeyStorage.getInstance(context);
|
||||||
|
|
||||||
|
@ -97,6 +100,8 @@ public class KeyWritableRepository extends KeyRepository {
|
||||||
private KeyWritableRepository(
|
private KeyWritableRepository(
|
||||||
Context context, LocalPublicKeyStorage localPublicKeyStorage, OperationLog log, int indent) {
|
Context context, LocalPublicKeyStorage localPublicKeyStorage, OperationLog log, int indent) {
|
||||||
super(context.getContentResolver(), localPublicKeyStorage, log, indent);
|
super(context.getContentResolver(), localPublicKeyStorage, log, indent);
|
||||||
|
|
||||||
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LongSparseArray<CanonicalizedPublicKey> getTrustedMasterKeys() {
|
private LongSparseArray<CanonicalizedPublicKey> getTrustedMasterKeys() {
|
||||||
|
@ -1015,8 +1020,9 @@ public class KeyWritableRepository extends KeyRepository {
|
||||||
OperationLog log = new OperationLog();
|
OperationLog log = new OperationLog();
|
||||||
|
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
boolean needsSigningDbUpdate = false; // TODO remember if we ever refreshed all keys everything
|
Preferences preferences = Preferences.getPreferences(mContext);
|
||||||
if (needsSigningDbUpdate) {
|
boolean isTrustDbInitialized = preferences.isKeySignaturesTableInitialized();
|
||||||
|
if (!isTrustDbInitialized) {
|
||||||
cursor = mContentResolver.query(KeyRings.buildUnifiedKeyRingsUri(),
|
cursor = mContentResolver.query(KeyRings.buildUnifiedKeyRingsUri(),
|
||||||
new String[] { KeyRings.MASTER_KEY_ID }, null, null, null);
|
new String[] { KeyRings.MASTER_KEY_ID }, null, null, null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1050,6 +1056,10 @@ public class KeyWritableRepository extends KeyRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isTrustDbInitialized) {
|
||||||
|
preferences.setKeySignaturesTableInitialized();
|
||||||
|
}
|
||||||
|
|
||||||
return new UpdateTrustResult(UpdateTrustResult.RESULT_OK, log);
|
return new UpdateTrustResult(UpdateTrustResult.RESULT_OK, log);
|
||||||
} finally {
|
} finally {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
|
|
@ -42,6 +42,8 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.OverriddenWarni
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UpdatedKeysColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UpdatedKeysColumns;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPacketsColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPacketsColumns;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQLite Datatypes (from http://www.sqlite.org/datatype3.html)
|
* SQLite Datatypes (from http://www.sqlite.org/datatype3.html)
|
||||||
|
@ -234,6 +236,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
||||||
db.execSQL("CREATE INDEX verified_certs ON certs ("
|
db.execSQL("CREATE INDEX verified_certs ON certs ("
|
||||||
+ CertsColumns.VERIFIED + ", " + CertsColumns.MASTER_KEY_ID + ");");
|
+ CertsColumns.VERIFIED + ", " + CertsColumns.MASTER_KEY_ID + ");");
|
||||||
|
|
||||||
|
Preferences.getPreferences(mContext).setKeySignaturesTableInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,6 +28,7 @@ import android.annotation.SuppressLint;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -318,6 +319,16 @@ public class Preferences {
|
||||||
getPreferredKeyserver());
|
getPreferredKeyserver());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isKeySignaturesTableInitialized() {
|
||||||
|
return mSharedPreferences.getBoolean(Pref.KEY_SIGNATURES_TABLE_INITIALIZED, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeySignaturesTableInitialized() {
|
||||||
|
Editor editor = mSharedPreferences.edit();
|
||||||
|
editor.putBoolean(Pref.KEY_SIGNATURES_TABLE_INITIALIZED, true);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
public static class CloudSearchPrefs implements Parcelable {
|
public static class CloudSearchPrefs implements Parcelable {
|
||||||
public final boolean searchKeyserver;
|
public final boolean searchKeyserver;
|
||||||
public final boolean searchKeybase;
|
public final boolean searchKeybase;
|
||||||
|
|
Loading…
Reference in a new issue