From 0095df6d8997b911c8dd3608ff8596f4ed1f2d41 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Mon, 22 May 2017 12:24:38 +0200 Subject: [PATCH] use autovalue for PromoteKeyringParcel --- .../operations/PromoteKeyOperation.java | 13 +++-- .../service/PromoteKeyringParcel.java | 53 +++++-------------- .../ui/ViewKeySecurityTokenFragment.java | 2 +- .../operations/PromoteKeyOperationTest.java | 13 +++-- 4 files changed, 29 insertions(+), 52 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperation.java index 80a787859..22b96db6a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperation.java @@ -38,7 +38,6 @@ import org.sufficientlysecure.keychain.provider.KeyWritableRepository; import org.sufficientlysecure.keychain.service.PromoteKeyringParcel; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.ProgressScaler; /** An operation which promotes a public key ring to a secret one. * @@ -67,17 +66,18 @@ public class PromoteKeyOperation extends BaseReadWriteOperation CREATOR = new Parcelable.Creator() { - @Override - public PromoteKeyringParcel createFromParcel(Parcel in) { - return new PromoteKeyringParcel(in); - } - - @Override - public PromoteKeyringParcel[] newArray(int size) { - return new PromoteKeyringParcel[size]; - } - }; } \ No newline at end of file diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeySecurityTokenFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeySecurityTokenFragment.java index 4a7f4861d..bbea3973b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeySecurityTokenFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeySecurityTokenFragment.java @@ -213,7 +213,7 @@ public class ViewKeySecurityTokenFragment @Override public PromoteKeyringParcel createOperationInput() { - return new PromoteKeyringParcel(mMasterKeyId, mCardAid, mSubKeyIds); + return PromoteKeyringParcel.createPromoteKeyringParcel(mMasterKeyId, mCardAid, mSubKeyIds); } @Override diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java index 9b58ab511..00e6bc94e 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java @@ -106,7 +106,8 @@ public class PromoteKeyOperationTest { PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application, KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null); - PromoteKeyResult result = op.execute(new PromoteKeyringParcel(mStaticRing.getMasterKeyId(), null, null), null); + PromoteKeyResult result = op.execute( + PromoteKeyringParcel.createPromoteKeyringParcel(mStaticRing.getMasterKeyId(), null, null), null); Assert.assertTrue("promotion must succeed", result.success()); @@ -132,7 +133,8 @@ public class PromoteKeyOperationTest { byte[] aid = Hex.decode("D2760001240102000000012345670000"); - PromoteKeyResult result = op.execute(new PromoteKeyringParcel(mStaticRing.getMasterKeyId(), aid, null), null); + PromoteKeyResult result = op.execute( + PromoteKeyringParcel.createPromoteKeyringParcel(mStaticRing.getMasterKeyId(), aid, null), null); Assert.assertTrue("promotion must succeed", result.success()); @@ -160,9 +162,10 @@ public class PromoteKeyOperationTest { // only promote the first, rest stays dummy long keyId = KeyringTestingHelper.getSubkeyId(mStaticRing, 1); - PromoteKeyResult result = op.execute(new PromoteKeyringParcel(mStaticRing.getMasterKeyId(), aid, new long[] { - keyId - }), null); + PromoteKeyResult result = op.execute( + PromoteKeyringParcel.createPromoteKeyringParcel(mStaticRing.getMasterKeyId(), aid, new long[] { + keyId + }), null); Assert.assertTrue("promotion must succeed", result.success());