rename ProviderHelper -> DatabaseInteractor

This commit is contained in:
Vincent Breitmoser
2017-02-20 16:20:20 +01:00
parent 2c8996bbcd
commit d577257bd5
63 changed files with 439 additions and 467 deletions

View File

@@ -53,7 +53,7 @@ import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -86,14 +86,14 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
private static final int INDEX_SECKEY_DATA = 2;
private static final int INDEX_HAS_ANY_SECRET = 3;
public BackupOperation(Context context, ProviderHelper providerHelper, Progressable
public BackupOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
progressable) {
super(context, providerHelper, progressable);
super(context, databaseInteractor, progressable);
}
public BackupOperation(Context context, ProviderHelper providerHelper,
public BackupOperation(Context context, DatabaseInteractor databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, providerHelper, progressable, cancelled);
super(context, databaseInteractor, progressable, cancelled);
}
@NonNull
@@ -170,7 +170,7 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
private PgpSignEncryptResult encryptBackupData(@NonNull BackupKeyringParcel backupInput,
@NonNull CryptoInputParcel cryptoInput, @Nullable OutputStream outputStream, Uri plainUri, long exportedDataSize)
throws FileNotFoundException {
PgpSignEncryptOperation signEncryptOperation = new PgpSignEncryptOperation(mContext, mProviderHelper, mProgressable, mCancelled);
PgpSignEncryptOperation signEncryptOperation = new PgpSignEncryptOperation(mContext, mDatabaseInteractor, mProgressable, mCancelled);
PgpSignEncryptData data = new PgpSignEncryptData();
data.setSymmetricPassphrase(cryptoInput.getPassphrase());
@@ -326,7 +326,7 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
+ " IN (" + placeholders + ")";
}
return mProviderHelper.getContentResolver().query(
return mDatabaseInteractor.getContentResolver().query(
KeyRings.buildUnifiedKeyRingsUri(), PROJECTION, selection, selectionArgs,
Tables.KEYS + "." + KeyRings.MASTER_KEY_ID
);

View File

@@ -26,8 +26,8 @@ import org.sufficientlysecure.keychain.Constants.key;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.util.Passphrase;
@@ -40,7 +40,7 @@ public abstract class BaseOperation <T extends Parcelable> implements Passphrase
final public Progressable mProgressable;
final public AtomicBoolean mCancelled;
final public ProviderHelper mProviderHelper;
final public DatabaseInteractor mDatabaseInteractor;
/** An abstract base class for all *Operation classes. It provides a number
* of common methods for progress, cancellation and passphrase cache handling.
@@ -64,18 +64,18 @@ public abstract class BaseOperation <T extends Parcelable> implements Passphrase
* if there is no prefix it is considered Android-related.
*
*/
public BaseOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
public BaseOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
this.mContext = context;
this.mProgressable = progressable;
this.mProviderHelper = providerHelper;
this.mDatabaseInteractor = databaseInteractor;
mCancelled = null;
}
public BaseOperation(Context context, ProviderHelper providerHelper,
public BaseOperation(Context context, DatabaseInteractor databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
mContext = context;
mProgressable = progressable;
mProviderHelper = providerHelper;
mDatabaseInteractor = databaseInteractor;
mCancelled = cancelled;
}
@@ -114,7 +114,7 @@ public abstract class BaseOperation <T extends Parcelable> implements Passphrase
public Passphrase getCachedPassphrase(long subKeyId) throws NoSecretKeyException {
try {
if (subKeyId != key.symmetric) {
long masterKeyId = mProviderHelper.getMasterKeyId(subKeyId);
long masterKeyId = mDatabaseInteractor.getMasterKeyId(subKeyId);
return getCachedPassphrase(masterKeyId, subKeyId);
}
return getCachedPassphrase(key.symmetric, key.symmetric);

View File

@@ -41,12 +41,11 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags;
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptData;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.BenchmarkInputParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.util.Log;
@@ -56,9 +55,9 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
public BenchmarkOperation(Context context, ProviderHelper providerHelper, Progressable
public BenchmarkOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
progressable) {
super(context, providerHelper, progressable);
super(context, databaseInteractor, progressable);
}
@NonNull
@@ -82,7 +81,7 @@ public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
int i = 0;
do {
SignEncryptOperation op =
new SignEncryptOperation(mContext, mProviderHelper,
new SignEncryptOperation(mContext, mDatabaseInteractor,
new ProgressScaler(mProgressable, i*(50/numRepeats), (i+1)*(50/numRepeats), 100), mCancelled);
PgpSignEncryptData data = new PgpSignEncryptData();
data.setSymmetricPassphrase(passphrase);
@@ -104,7 +103,7 @@ public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
do {
DecryptVerifyResult decryptResult;
PgpDecryptVerifyOperation op =
new PgpDecryptVerifyOperation(mContext, mProviderHelper,
new PgpDecryptVerifyOperation(mContext, mDatabaseInteractor,
new ProgressScaler(mProgressable, 50 +i*(50/numRepeats), 50 +(i+1)*(50/numRepeats), 100));
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(encryptResult.getResultBytes());
input.setAllowSymmetricDecryption(true);

View File

@@ -39,8 +39,8 @@ import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
@@ -62,9 +62,9 @@ import org.sufficientlysecure.keychain.util.Passphrase;
*/
public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
public CertifyOperation(Context context, ProviderHelper providerHelper, Progressable progressable, AtomicBoolean
public CertifyOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable, AtomicBoolean
cancelled) {
super(context, providerHelper, progressable, cancelled);
super(context, databaseInteractor, progressable, cancelled);
}
@NonNull
@@ -81,7 +81,7 @@ public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
log.add(LogType.MSG_CRT_MASTER_FETCH, 1);
CachedPublicKeyRing cachedPublicKeyRing = mProviderHelper.getCachedPublicKeyRing(masterKeyId);
CachedPublicKeyRing cachedPublicKeyRing = mDatabaseInteractor.getCachedPublicKeyRing(masterKeyId);
Passphrase passphrase;
switch (cachedPublicKeyRing.getSecretKeyType(masterKeyId)) {
@@ -121,7 +121,7 @@ public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
// Get actual secret key
CanonicalizedSecretKeyRing secretKeyRing =
mProviderHelper.getCanonicalizedSecretKeyRing(parcel.mMasterKeyId);
mDatabaseInteractor.getCanonicalizedSecretKeyRing(parcel.mMasterKeyId);
certificationKey = secretKeyRing.getSecretKey();
log.add(LogType.MSG_CRT_UNLOCK, 1);
@@ -165,7 +165,7 @@ public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
}
CanonicalizedPublicKeyRing publicRing =
mProviderHelper.getCanonicalizedPublicKeyRing(action.mMasterKeyId);
mDatabaseInteractor.getCanonicalizedPublicKeyRing(action.mMasterKeyId);
PgpCertifyOperation op = new PgpCertifyOperation();
PgpCertifyResult result = op.certify(certificationKey, publicRing,
@@ -206,7 +206,7 @@ public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
// these variables are used inside the following loop, but they need to be created only once
UploadOperation uploadOperation = null;
if (parcel.keyServerUri != null) {
uploadOperation = new UploadOperation(mContext, mProviderHelper, mProgressable, mCancelled);
uploadOperation = new UploadOperation(mContext, mDatabaseInteractor, mProgressable, mCancelled);
}
// Write all certified keys into the database
@@ -222,8 +222,8 @@ public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
log.add(LogType.MSG_CRT_SAVE, 2,
KeyFormattingUtils.convertKeyIdToHex(certifiedKey.getMasterKeyId()));
// store the signed key in our local cache
mProviderHelper.clearLog();
SaveKeyringResult result = mProviderHelper.savePublicKeyRing(certifiedKey);
mDatabaseInteractor.clearLog();
SaveKeyringResult result = mDatabaseInteractor.savePublicKeyRing(certifiedKey);
if (uploadOperation != null) {
UploadKeyringParcel uploadInput =

View File

@@ -29,7 +29,7 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
@@ -38,8 +38,8 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
public ChangeUnlockOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
super(context, providerHelper, progressable);
public ChangeUnlockOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
super(context, databaseInteractor, progressable);
}
@NonNull
@@ -63,7 +63,7 @@ public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
KeyFormattingUtils.convertKeyIdToHex(unlockParcel.mMasterKeyId));
CanonicalizedSecretKeyRing secRing =
mProviderHelper.getCanonicalizedSecretKeyRing(unlockParcel.mMasterKeyId);
mDatabaseInteractor.getCanonicalizedSecretKeyRing(unlockParcel.mMasterKeyId);
modifyResult = keyOperations.modifyKeyRingPassphrase(secRing, cryptoInput, unlockParcel);
if (modifyResult.isPending()) {
@@ -71,7 +71,7 @@ public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
log.add(modifyResult, 1);
return new EditKeyResult(log, modifyResult);
}
} catch (ProviderHelper.NotFoundException e) {
} catch (DatabaseInteractor.NotFoundException e) {
log.add(OperationResult.LogType.MSG_ED_ERROR_KEY_NOT_FOUND, 2);
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
}
@@ -90,7 +90,7 @@ public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
// It's a success, so this must be non-null now
UncachedKeyRing ring = modifyResult.getRing();
SaveKeyringResult saveResult = mProviderHelper
SaveKeyringResult saveResult = mDatabaseInteractor
.saveSecretKeyRing(ring, new ProgressScaler(mProgressable, 70, 95, 100));
log.add(saveResult, 1);

View File

@@ -24,15 +24,15 @@ import android.support.annotation.NonNull;
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.ConsolidateInputParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
public class ConsolidateOperation extends BaseOperation<ConsolidateInputParcel> {
public ConsolidateOperation(Context context, ProviderHelper providerHelper, Progressable
public ConsolidateOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
progressable) {
super(context, providerHelper, progressable);
super(context, databaseInteractor, progressable);
}
@NonNull
@@ -40,9 +40,9 @@ public class ConsolidateOperation extends BaseOperation<ConsolidateInputParcel>
public ConsolidateResult execute(ConsolidateInputParcel consolidateInputParcel,
CryptoInputParcel cryptoInputParcel) {
if (consolidateInputParcel.mConsolidateRecovery) {
return mProviderHelper.consolidateDatabaseStep2(mProgressable);
return mDatabaseInteractor.consolidateDatabaseStep2(mProgressable);
} else {
return mProviderHelper.consolidateDatabaseStep1(mProgressable);
return mDatabaseInteractor.consolidateDatabaseStep1(mProgressable);
}
}
}

View File

@@ -27,7 +27,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.LogTyp
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
import org.sufficientlysecure.keychain.service.DeleteKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -43,8 +43,8 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
*/
public class DeleteOperation extends BaseOperation<DeleteKeyringParcel> {
public DeleteOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
super(context, providerHelper, progressable);
public DeleteOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
super(context, databaseInteractor, progressable);
}
@NonNull
@@ -81,7 +81,7 @@ public class DeleteOperation extends BaseOperation<DeleteKeyringParcel> {
cancelled = true;
break;
}
int count = mProviderHelper.getContentResolver().delete(
int count = mDatabaseInteractor.getContentResolver().delete(
KeyRingData.buildPublicKeyRingUri(masterKeyId), null, null
);
if (count > 0) {
@@ -95,7 +95,7 @@ public class DeleteOperation extends BaseOperation<DeleteKeyringParcel> {
if (isSecret && success > 0) {
log.add(LogType.MSG_DEL_CONSOLIDATE, 1);
ConsolidateResult sub = mProviderHelper.consolidateDatabaseStep1(mProgressable);
ConsolidateResult sub = mDatabaseInteractor.consolidateDatabaseStep1(mProgressable);
log.add(sub, 2);
}

View File

@@ -35,10 +35,9 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -58,9 +57,9 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
*/
public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
public EditKeyOperation(Context context, ProviderHelper providerHelper,
public EditKeyOperation(Context context, DatabaseInteractor databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, providerHelper, progressable, cancelled);
super(context, databaseInteractor, progressable, cancelled);
}
/**
@@ -95,7 +94,7 @@ public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
log.add(LogType.MSG_ED_FETCHING, 1,
KeyFormattingUtils.convertKeyIdToHex(saveParcel.mMasterKeyId));
CanonicalizedSecretKeyRing secRing =
mProviderHelper.getCanonicalizedSecretKeyRing(saveParcel.mMasterKeyId);
mDatabaseInteractor.getCanonicalizedSecretKeyRing(saveParcel.mMasterKeyId);
modifyResult = keyOperations.modifySecretKeyRing(secRing, cryptoInput, saveParcel);
if (modifyResult.isPending()) {
@@ -148,7 +147,7 @@ public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
new UploadKeyringParcel(saveParcel.getUploadKeyserver(), keyringBytes);
UploadResult uploadResult =
new UploadOperation(mContext, mProviderHelper, mProgressable, mCancelled)
new UploadOperation(mContext, mDatabaseInteractor, mProgressable, mCancelled)
.execute(exportKeyringParcel, cryptoInput);
log.add(uploadResult, 2);
@@ -162,7 +161,7 @@ public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
}
// Save the new keyring.
SaveKeyringResult saveResult = mProviderHelper
SaveKeyringResult saveResult = mDatabaseInteractor
.saveSecretKeyRing(ring, new ProgressScaler(mProgressable, 60, 95, 100));
log.add(saveResult, 1);

View File

@@ -39,7 +39,7 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -86,14 +86,14 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
public static final String CACHE_FILE_NAME = "key_import.pcl";
public ImportOperation(Context context, ProviderHelper providerHelper, Progressable
public ImportOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
progressable) {
super(context, providerHelper, progressable);
super(context, databaseInteractor, progressable);
}
public ImportOperation(Context context, ProviderHelper providerHelper,
public ImportOperation(Context context, DatabaseInteractor databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, providerHelper, progressable, cancelled);
super(context, databaseInteractor, progressable, cancelled);
}
// Overloaded functions for using progressable supplied in constructor during import
@@ -314,15 +314,15 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
SaveKeyringResult result;
// synchronizing prevents https://github.com/open-keychain/open-keychain/issues/1221
// and https://github.com/open-keychain/open-keychain/issues/1480
synchronized (mProviderHelper) {
mProviderHelper.clearLog();
synchronized (mDatabaseInteractor) {
mDatabaseInteractor.clearLog();
ProgressScaler progressScaler = new ProgressScaler(progressable, (int) (position * progSteps),
(int) ((position + 1) * progSteps), 100);
if (key.isSecret()) {
result = mProviderHelper.saveSecretKeyRing(key, progressScaler,
result = mDatabaseInteractor.saveSecretKeyRing(key, progressScaler,
canKeyRings, skipSave);
} else {
result = mProviderHelper.savePublicKeyRing(key, progressScaler,
result = mDatabaseInteractor.savePublicKeyRing(key, progressScaler,
entry.mExpectedFingerprint, canKeyRings, skipSave);
}
}
@@ -343,7 +343,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
// synonymous to isDownloadFromKeyserver.
// If no byte data was supplied, import from keyserver took place
// this prevents file imports being noted as keyserver imports
mProviderHelper.renewKeyLastUpdatedTime(key.getMasterKeyId(),
mDatabaseInteractor.renewKeyLastUpdatedTime(key.getMasterKeyId(),
GregorianCalendar.getInstance().getTimeInMillis(),
TimeUnit.MILLISECONDS);
}
@@ -365,8 +365,8 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
if (!skipSave && (secret > 0)) {
setPreventCancel();
ConsolidateResult result;
synchronized (mProviderHelper) {
result = mProviderHelper.consolidateDatabaseStep1(progressable);
synchronized (mDatabaseInteractor) {
result = mDatabaseInteractor.consolidateDatabaseStep1(progressable);
}
log.add(result, 1);
}

View File

@@ -50,7 +50,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
import org.sufficientlysecure.keychain.service.InputDataParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -71,8 +71,8 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
private final byte[] buf = new byte[256];
public InputDataOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
super(context, providerHelper, progressable);
public InputDataOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
super(context, databaseInteractor, progressable);
}
Uri mSignedDataUri;
@@ -101,7 +101,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
log.add(LogType.MSG_DATA_OPENPGP, 1);
PgpDecryptVerifyOperation op =
new PgpDecryptVerifyOperation(mContext, mProviderHelper, mProgressable);
new PgpDecryptVerifyOperation(mContext, mDatabaseInteractor, mProgressable);
decryptInput.setInputUri(input.getInputUri());
@@ -269,7 +269,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
decryptInput.setDetachedSignature(detachedSig.toByteArray());
PgpDecryptVerifyOperation op =
new PgpDecryptVerifyOperation(mContext, mProviderHelper, mProgressable);
new PgpDecryptVerifyOperation(mContext, mDatabaseInteractor, mProgressable);
DecryptVerifyResult verifyResult = op.execute(decryptInput, cryptoInput);
log.addByMerge(verifyResult, 4);

View File

@@ -36,7 +36,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.KeybaseVerificationParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
@@ -59,9 +59,9 @@ import de.measite.minidns.record.TXT;
public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificationParcel> {
public KeybaseVerificationOperation(Context context, ProviderHelper providerHelper,
public KeybaseVerificationOperation(Context context, DatabaseInteractor databaseInteractor,
Progressable progressable) {
super(context, providerHelper, progressable);
super(context, databaseInteractor, progressable);
}
@NonNull
@@ -147,7 +147,7 @@ public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificat
}
}
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(mContext, mProviderHelper, mProgressable);
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(mContext, mDatabaseInteractor, mProgressable);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(messageBytes)
.setRequiredSignerFingerprint(requiredFingerprint);

View File

@@ -33,8 +33,8 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKey;
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
@@ -49,9 +49,9 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
*/
public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
public PromoteKeyOperation(Context context, ProviderHelper providerHelper,
public PromoteKeyOperation(Context context, DatabaseInteractor databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, providerHelper, progressable, cancelled);
super(context, databaseInteractor, progressable, cancelled);
}
@NonNull
@@ -70,7 +70,7 @@ public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
log.add(LogType.MSG_PR_FETCHING, 1,
KeyFormattingUtils.convertKeyIdToHex(promoteKeyringParcel.mKeyRingId));
CanonicalizedPublicKeyRing pubRing =
mProviderHelper.getCanonicalizedPublicKeyRing(promoteKeyringParcel.mKeyRingId);
mDatabaseInteractor.getCanonicalizedPublicKeyRing(promoteKeyringParcel.mKeyRingId);
if (promoteKeyringParcel.mSubKeyIds == null) {
log.add(LogType.MSG_PR_ALL, 1);
@@ -114,7 +114,7 @@ public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
setPreventCancel();
// Save the new keyring.
SaveKeyringResult saveResult = mProviderHelper
SaveKeyringResult saveResult = mDatabaseInteractor
.saveSecretKeyRing(promotedRing, new ProgressScaler(mProgressable, 60, 95, 100));
log.add(saveResult, 1);

View File

@@ -32,7 +32,7 @@ import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.RevokeKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -41,8 +41,8 @@ import org.sufficientlysecure.keychain.util.Log;
public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
public RevokeOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
super(context, providerHelper, progressable);
public RevokeOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
super(context, databaseInteractor, progressable);
}
@NonNull
@@ -62,7 +62,7 @@ public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
try {
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(masterKeyId);
CachedPublicKeyRing keyRing = mProviderHelper.getCachedPublicKeyRing(secretUri);
CachedPublicKeyRing keyRing = mDatabaseInteractor.getCachedPublicKeyRing(secretUri);
// check if this is a master secret key we can work with
switch (keyRing.getSecretKeyType(masterKeyId)) {
@@ -81,7 +81,7 @@ public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
saveKeyringParcel.mRevokeSubKeys.add(masterKeyId);
EditKeyResult revokeAndUploadResult = new EditKeyOperation(mContext,
mProviderHelper, mProgressable, mCancelled).execute(saveKeyringParcel, cryptoInputParcel);
mDatabaseInteractor, mProgressable, mCancelled).execute(saveKeyringParcel, cryptoInputParcel);
if (revokeAndUploadResult.isPending()) {
return revokeAndUploadResult;
@@ -97,7 +97,7 @@ public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);
}
} catch (PgpKeyNotFoundException | ProviderHelper.NotFoundException e) {
} catch (PgpKeyNotFoundException | DatabaseInteractor.NotFoundException e) {
Log.e(Constants.TAG, "could not find key to revoke", e);
log.add(OperationResult.LogType.MSG_REVOKE_ERROR_KEY_FAIL, 1);
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);

View File

@@ -33,7 +33,7 @@ import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.SecurityTokenSignOperationsBuilder;
@@ -55,9 +55,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
public SignEncryptOperation(Context context, ProviderHelper providerHelper,
public SignEncryptOperation(Context context, DatabaseInteractor databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, providerHelper, progressable, cancelled);
super(context, databaseInteractor, progressable, cancelled);
}
@@ -81,7 +81,7 @@ public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
if (data.getSignatureMasterKeyId() != Constants.key.none
&& data.getSignatureSubKeyId() == null) {
try {
long signKeyId = mProviderHelper.getCachedPublicKeyRing(
long signKeyId = mDatabaseInteractor.getCachedPublicKeyRing(
data.getSignatureMasterKeyId()).getSecretSignId();
data.setSignatureSubKeyId(signKeyId);
} catch (PgpKeyNotFoundException e) {
@@ -96,7 +96,7 @@ public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
return new SignEncryptResult(SignEncryptResult.RESULT_CANCELLED, log, results);
}
PgpSignEncryptOperation op = new PgpSignEncryptOperation(mContext, mProviderHelper,
PgpSignEncryptOperation op = new PgpSignEncryptOperation(mContext, mDatabaseInteractor,
new ProgressScaler(mProgressable, 100 * count / total, 100 * ++count / total, 100), mCancelled);
PgpSignEncryptInputParcel inputParcel = new PgpSignEncryptInputParcel(input.getData());
if (inputBytes != null) {

View File

@@ -37,7 +37,7 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
@@ -58,9 +58,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
public UploadOperation(Context context, ProviderHelper providerHelper,
public UploadOperation(Context context, DatabaseInteractor databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, providerHelper, progressable, cancelled);
super(context, databaseInteractor, progressable, cancelled);
}
@NonNull
@@ -120,7 +120,7 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
if (hasMasterKeyId) {
log.add(LogType.MSG_UPLOAD_KEY, 0, KeyFormattingUtils.convertKeyIdToHex(uploadInput.mMasterKeyId));
return mProviderHelper.getCanonicalizedPublicKeyRing(uploadInput.mMasterKeyId);
return mDatabaseInteractor.getCanonicalizedPublicKeyRing(uploadInput.mMasterKeyId);
}
CanonicalizedKeyRing canonicalizedRing =
@@ -132,7 +132,7 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
log.add(LogType.MSG_UPLOAD_KEY, 0, KeyFormattingUtils.convertKeyIdToHex(canonicalizedRing.getMasterKeyId()));
return (CanonicalizedPublicKeyRing) canonicalizedRing;
} catch (ProviderHelper.NotFoundException e) {
} catch (DatabaseInteractor.NotFoundException e) {
log.add(LogType.MSG_UPLOAD_ERROR_NOT_FOUND, 1);
return null;
} catch (IOException | PgpGeneralException e) {