From ea953db5217bb574b4c20fbf9768921f82ba58d0 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 3 Mar 2017 16:52:06 +0100 Subject: [PATCH] extract creation of error result intent into method --- .../keychain/remote/OpenPgpService.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 667dbdc7d..2f44423ad 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -305,19 +305,12 @@ public class OpenPgpService extends Service { private Intent getDryRunStatusResult(KeyIdResult keyIdResult) { switch (keyIdResult.getStatus()) { case MISSING: { - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.OPPORTUNISTIC_MISSING_KEYS, "missing keys in opportunistic mode")); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; + return createErrorResultIntent(OpenPgpError.OPPORTUNISTIC_MISSING_KEYS, + "missing keys in opportunistic mode"); } case NO_KEYS: case NO_KEYS_ERROR: { - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.NO_USER_IDS, "empty recipient list")); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; + return createErrorResultIntent(OpenPgpError.NO_USER_IDS, "empty recipient list"); } case DUPLICATE: { Intent result = new Intent(); @@ -796,11 +789,7 @@ public class OpenPgpService extends Service { return result; } catch (Exception e) { Log.d(Constants.TAG, "exception in updateTrustIdKeyImpl", e); - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; + return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, e.getMessage()); } }