diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/DeleteOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/DeleteOperation.java index ce023f627..f473a6117 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/DeleteOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/DeleteOperation.java @@ -95,10 +95,9 @@ public class DeleteOperation extends BaseReadWriteOperation } if (isSecret && success > 0) { - log.add(LogType.MSG_DEL_CONSOLIDATE, 1); UpdateTrustResult sub = mKeyWritableRepository.updateTrustDb( Collections.singletonList(masterKeyIds[0]), mProgressable); -// log.add(sub, 2); + log.add(sub, 1); } int result = DeleteResult.RESULT_OK; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java index 0dd60388f..db4f52166 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java @@ -264,11 +264,10 @@ public class ImportOperation extends BaseReadWriteOperation // and re-inserts keys, which could conflict with a parallel db key update if (!skipSave && !secretMasterKeyIds.isEmpty()) { setPreventCancel(); - UpdateTrustResult result; synchronized (mKeyRepository) { - result = mKeyWritableRepository.updateTrustDb(secretMasterKeyIds, progressable); + UpdateTrustResult result = mKeyWritableRepository.updateTrustDb(secretMasterKeyIds, progressable); + log.add(result, 1); } - // log.add(result, 1); } // Special: make sure new data is synced into contacts diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java index 4ce17fb7e..999391506 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java @@ -798,9 +798,8 @@ public abstract class OperationResult implements Parcelable { MSG_DEL_ERROR_EMPTY (LogLevel.ERROR, R.string.msg_del_error_empty), MSG_DEL_ERROR_MULTI_SECRET (LogLevel.ERROR, R.string.msg_del_error_multi_secret), MSG_DEL (LogLevel.START, R.plurals.msg_del), - MSG_DEL_KEY (LogLevel.DEBUG, R.string.msg_del_key), + MSG_DEL_KEY (LogLevel.INFO, R.string.msg_del_key), MSG_DEL_KEY_FAIL (LogLevel.WARN, R.string.msg_del_key_fail), - MSG_DEL_CONSOLIDATE (LogLevel.DEBUG, R.string.msg_del_consolidate), MSG_DEL_OK (LogLevel.OK, R.plurals.msg_del_ok), MSG_DEL_FAIL (LogLevel.WARN, R.plurals.msg_del_fail), @@ -910,6 +909,12 @@ public abstract class OperationResult implements Parcelable { MSG_RET_URI_NULL (LogLevel.ERROR, R.string.msg_ret_uri_null), MSG_RET_URI_TEST (LogLevel.DEBUG, R.string.msg_ret_uri_test), + MSG_TRUST (LogLevel.START, R.string.msg_trust), + MSG_TRUST_OK (LogLevel.OK, R.string.msg_trust_ok), + MSG_TRUST_KEY (LogLevel.INFO, R.string.msg_trust_key), + MSG_TRUST_INITIALIZE (LogLevel.INFO, R.string.msg_trust_initialize), + MSG_TRUST_COUNT_NONE (LogLevel.DEBUG, R.string.msg_trust_count_none), + MSG_TRUST_COUNT (LogLevel.DEBUG, R.plurals.msg_trust_count); ; public final int mMsgId; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java index 1b0484290..f7c2abb44 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java @@ -40,6 +40,7 @@ import android.support.v4.util.LongSparseArray; import org.openintents.openpgp.util.OpenPgpUtils; import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult; @@ -1019,16 +1020,20 @@ public class KeyWritableRepository extends KeyRepository { public UpdateTrustResult updateTrustDb(List signerMasterKeyIds, Progressable progress) { OperationLog log = new OperationLog(); + log.add(LogType.MSG_TRUST, 0); + Cursor cursor; Preferences preferences = Preferences.getPreferences(mContext); boolean isTrustDbInitialized = preferences.isKeySignaturesTableInitialized(); if (!isTrustDbInitialized) { + log.add(LogType.MSG_TRUST_INITIALIZE, 1); cursor = mContentResolver.query(KeyRings.buildUnifiedKeyRingsUri(), new String[] { KeyRings.MASTER_KEY_ID }, null, null, null); } else { String[] signerMasterKeyIdStrings = new String[signerMasterKeyIds.size()]; int i = 0; for (Long masterKeyId : signerMasterKeyIds) { + log.add(LogType.MSG_TRUST_KEY, 1, KeyFormattingUtils.beautifyKeyId(masterKeyId)); signerMasterKeyIdStrings[i++] = Long.toString(masterKeyId); } @@ -1040,6 +1045,16 @@ public class KeyWritableRepository extends KeyRepository { throw new IllegalStateException(); } + int totalKeys = cursor.getCount(); + int processedKeys = 0; + + if (totalKeys == 0) { + log.add(LogType.MSG_TRUST_COUNT_NONE, 1); + } else { + progress.setProgress(R.string.progress_update_trust, 0, totalKeys); + log.add(LogType.MSG_TRUST_COUNT, 1, totalKeys); + } + try { while (cursor.moveToNext()) { try { @@ -1047,9 +1062,12 @@ public class KeyWritableRepository extends KeyRepository { byte[] pubKeyData = loadPublicKeyRingData(masterKeyId); UncachedKeyRing uncachedKeyRing = UncachedKeyRing.decodeFromData(pubKeyData); + + clearLog(); SaveKeyringResult result = savePublicKeyRing(uncachedKeyRing, true); log.add(result, 1); + progress.setProgress(processedKeys++, totalKeys); } catch (NotFoundException | PgpGeneralException | IOException e) { Log.e(Constants.TAG, "Error updating trust database", e); return new UpdateTrustResult(UpdateTrustResult.RESULT_ERROR, log); @@ -1060,6 +1078,7 @@ public class KeyWritableRepository extends KeyRepository { preferences.setKeySignaturesTableInitialized(); } + log.add(LogType.MSG_TRUST_OK, 1); return new UpdateTrustResult(UpdateTrustResult.RESULT_OK, log); } finally { cursor.close(); diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index c5ad67df0..2e406015f 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -493,9 +493,7 @@ "verifying integrity…" "deleting '%s' securely…" "deleting keys…" - - "consolidate: saving to cache…" - "consolidate: reimporting…" + "updating trust info…" "verifying connection…" @@ -1351,7 +1349,6 @@ "Deleting key %s" "Failed deleting key %s" - "Consolidating database after deletion of secret key" "Successfully deleted key" "Successfully deleted %d keys" @@ -1952,4 +1949,14 @@ "No Uri saved on Security Token" "Checking if found key matches: %s" + "Updating trust information…" + "Update operation successful!" + "Initializing key signature cache" + "Updating keys signed by %s" + "No keys to update" + + "Updating 1 key" + "Updating %d keys" + +