use autovalue for UploadKeyringParcel

This commit is contained in:
Vincent Breitmoser
2017-05-22 11:26:38 +02:00
parent 53dcb4102d
commit f1cf759e0a
6 changed files with 25 additions and 66 deletions

View File

@@ -144,7 +144,7 @@ public class EditKeyOperation extends BaseReadWriteOperation<SaveKeyringParcel>
}
UploadKeyringParcel exportKeyringParcel =
new UploadKeyringParcel(saveParcel.getUploadKeyserver(), keyringBytes);
UploadKeyringParcel.createWithKeyringBytes(saveParcel.getUploadKeyserver(), keyringBytes);
UploadResult uploadResult = new UploadOperation(
mContext, mKeyRepository, new ProgressScaler(mProgressable, 60, 80, 100), mCancelled)

View File

@@ -96,7 +96,7 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
ParcelableHkpKeyserver hkpKeyserver;
{
hkpKeyserver = uploadInput.mKeyserver;
hkpKeyserver = uploadInput.getKeyserver();
log.add(LogType.MSG_UPLOAD_SERVER, 1, hkpKeyserver.toString());
}
@@ -110,22 +110,15 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
@Nullable
private CanonicalizedPublicKeyRing getPublicKeyringFromInput(OperationLog log, UploadKeyringParcel uploadInput) {
boolean hasMasterKeyId = uploadInput.mMasterKeyId != null;
boolean hasKeyringBytes = uploadInput.mUncachedKeyringBytes != null;
if (hasMasterKeyId == hasKeyringBytes) {
throw new IllegalArgumentException("either keyid xor bytes must be non-null for this method call!");
}
try {
if (hasMasterKeyId) {
log.add(LogType.MSG_UPLOAD_KEY, 0, KeyFormattingUtils.convertKeyIdToHex(uploadInput.mMasterKeyId));
return mKeyRepository.getCanonicalizedPublicKeyRing(uploadInput.mMasterKeyId);
Long masterKeyId = uploadInput.getMasterKeyId();
if (masterKeyId != null) {
log.add(LogType.MSG_UPLOAD_KEY, 0, KeyFormattingUtils.convertKeyIdToHex(masterKeyId));
return mKeyRepository.getCanonicalizedPublicKeyRing(masterKeyId);
}
CanonicalizedKeyRing canonicalizedRing =
UncachedKeyRing.decodeFromData(uploadInput.mUncachedKeyringBytes)
UncachedKeyRing.decodeFromData(uploadInput.getUncachedKeyringBytes())
.canonicalize(new OperationLog(), 0, true);
if (!CanonicalizedPublicKeyRing.class.isInstance(canonicalizedRing)) {
throw new IllegalArgumentException("keyring bytes must contain public key ring!");