diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index f8f0d2ac3..a32c14ca0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -80,8 +80,6 @@ public final class Constants { public static final String FIRST_TIME = "firstTime"; public static final String SHOW_ADVANCED_TABS = "showAdvancedTabs"; public static final String CACHED_CONSOLIDATE = "cachedConsolidate"; - public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets"; - public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics"; public static final String SEARCH_KEYSERVER = "search_keyserver_pref"; public static final String SEARCH_KEYBASE = "search_keybase_pref"; public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin"; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index d4aabc1b5..0ca9c60c6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -925,8 +925,6 @@ public class ProviderHelper { return new ConsolidateResult(ConsolidateResult.RESULT_ERROR, mLog); } - Preferences.getPreferences(mContext).setCachedConsolidateNumSecrets(cursor.getCount()); - ParcelableFileCache cache = new ParcelableFileCache(mContext, "consolidate_secret.pcl"); cache.writeCache(cursor.getCount(), new Iterator() { @@ -987,8 +985,6 @@ public class ProviderHelper { return new ConsolidateResult(ConsolidateResult.RESULT_ERROR, mLog); } - Preferences.getPreferences(mContext).setCachedConsolidateNumPublics(cursor.getCount()); - ParcelableFileCache cache = new ParcelableFileCache(mContext, "consolidate_public.pcl"); cache.writeCache(cursor.getCount(), new Iterator() { @@ -1057,16 +1053,8 @@ public class ProviderHelper { try { Preferences prefs = Preferences.getPreferences(mContext); - // Set flag that we have a cached consolidation here - int numSecrets = prefs.getCachedConsolidateNumSecrets(); - int numPublics = prefs.getCachedConsolidateNumPublics(); - if (recovery) { - if (numSecrets >= 0 && numPublics >= 0) { - log(LogType.MSG_CON_RECOVER, numSecrets, numPublics); - } else { - log(LogType.MSG_CON_RECOVER_UNKNOWN); - } + log(LogType.MSG_CON_RECOVER); mIndent += 1; } @@ -1084,14 +1072,24 @@ public class ProviderHelper { ParcelableFileCache cachePublic = new ParcelableFileCache(mContext, "consolidate_public.pcl"); - // 3. Re-Import secret keyrings from cache - if (numSecrets > 0) try { + // Set flag that we have a cached consolidation here + try { + Iterator itSecrets = cacheSecret.readCache(false); + int numSecrets = cacheSecret.getNumEntries(); + log(LogType.MSG_CON_REIMPORT_SECRET, numSecrets); mIndent += 1; - new PgpImportExport(mContext, this, - new ProgressFixedScaler(progress, 10, 25, 100, R.string.progress_con_reimport)) - .importKeyRings(cacheSecret.readCache(false), numSecrets); + // 3. Re-Import secret keyrings from cache + if (numSecrets > 0) { + + new PgpImportExport(mContext, this, + new ProgressFixedScaler(progress, 10, 25, 100, R.string.progress_con_reimport)) + .importKeyRings(itSecrets, numSecrets); + } else { + log(LogType.MSG_CON_REIMPORT_SECRET_SKIP); + } + } catch (IOException e) { Log.e(Constants.TAG, "error importing secret", e); log(LogType.MSG_CON_ERROR_SECRET); @@ -1099,18 +1097,25 @@ public class ProviderHelper { } finally { mIndent -= 1; } - else { - log(LogType.MSG_CON_REIMPORT_SECRET_SKIP); - } - // 4. Re-Import public keyrings from cache - if (numPublics > 0) try { + try { + + Iterator itPublics = cachePublic.readCache(); + int numPublics = cachePublic.getNumEntries(); + log(LogType.MSG_CON_REIMPORT_PUBLIC, numPublics); mIndent += 1; - new PgpImportExport(mContext, this, - new ProgressFixedScaler(progress, 25, 99, 100, R.string.progress_con_reimport)) - .importKeyRings(cachePublic.readCache(false), numPublics); + // 4. Re-Import public keyrings from cache + if (numPublics > 0) { + + new PgpImportExport(mContext, this, + new ProgressFixedScaler(progress, 25, 99, 100, R.string.progress_con_reimport)) + .importKeyRings(itPublics, numPublics); + } else { + log(LogType.MSG_CON_REIMPORT_PUBLIC_SKIP); + } + } catch (IOException e) { Log.e(Constants.TAG, "error importing public", e); log(LogType.MSG_CON_ERROR_PUBLIC); @@ -1118,9 +1123,6 @@ public class ProviderHelper { } finally { mIndent -= 1; } - else { - log(LogType.MSG_CON_REIMPORT_PUBLIC_SKIP); - } log(LogType.MSG_CON_CRITICAL_OUT); Preferences.getPreferences(mContext).setCachedConsolidate(false); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java index 0a4d9649f..b9b4cfddb 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java @@ -439,7 +439,6 @@ public abstract class OperationResult implements Parcelable { MSG_CON_ERROR_PUBLIC (LogLevel.ERROR, R.string.msg_con_error_public), MSG_CON_ERROR_SECRET (LogLevel.ERROR, R.string.msg_con_error_secret), MSG_CON_RECOVER (LogLevel.DEBUG, R.plurals.msg_con_recover), - MSG_CON_RECOVER_UNKNOWN (LogLevel.DEBUG, R.string.msg_con_recover_unknown), MSG_CON_REIMPORT_PUBLIC (LogLevel.DEBUG, R.plurals.msg_con_reimport_public), MSG_CON_REIMPORT_PUBLIC_SKIP (LogLevel.DEBUG, R.string.msg_con_reimport_public_skip), MSG_CON_REIMPORT_SECRET (LogLevel.DEBUG, R.plurals.msg_con_reimport_secret), diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java index d4cd9b385..bdb7c65fc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java @@ -177,26 +177,6 @@ public class Preferences { editor.commit(); } - public int getCachedConsolidateNumPublics() { - return mSharedPreferences.getInt(Pref.CACHED_CONSOLIDATE_PUBLICS, -1); - } - - public void setCachedConsolidateNumPublics(int value) { - SharedPreferences.Editor editor = mSharedPreferences.edit(); - editor.putInt(Pref.CACHED_CONSOLIDATE_PUBLICS, value); - editor.commit(); - } - - public int getCachedConsolidateNumSecrets() { - return mSharedPreferences.getInt(Pref.CACHED_CONSOLIDATE_SECRETS, -1); - } - - public void setCachedConsolidateNumSecrets(int value) { - SharedPreferences.Editor editor = mSharedPreferences.edit(); - editor.putInt(Pref.CACHED_CONSOLIDATE_SECRETS, value); - editor.commit(); - } - public boolean isFirstTime() { return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true); } diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index a44aaf2a6..297d53dce 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -790,10 +790,7 @@ "IO error writing secret keys to cache!" "Error reimporting public keys!" "Error reimporting secret keys!" - - "Recovering consolidation with %1$d secret and %2$d public keys" - "Recovering consolidation with %1$d secret and %2$d public keys" - + "Recovering consolidation" "Recovering from unknown state" "Reimporting one public key"