aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java17
1 files changed, 5 insertions, 12 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 7dfb3f3f6..d6ef1be85 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -701,24 +701,17 @@ public class OpenPgpService extends RemoteService {
Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
- // return public key if requested by defining a output stream
- if (outputStream != null) {
- boolean requestAsciiArmor =
- data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, false);
+ boolean requestedKeyData = outputStream != null;
+ if (requestedKeyData) {
+ boolean requestAsciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, false);
- ArmoredOutputStream arOutStream = null;
try {
if (requestAsciiArmor) {
- arOutStream = new ArmoredOutputStream(outputStream);
- keyRing.encode(arOutStream);
- } else {
- keyRing.encode(outputStream);
+ outputStream = new ArmoredOutputStream(outputStream);
}
+ keyRing.encode(outputStream);
} finally {
try {
- if (arOutStream != null) {
- arOutStream.close();
- }
outputStream.close();
} catch (IOException e) {
Log.e(Constants.TAG, "IOException when closing OutputStream", e);