service: minor code cleanups in key retrieval

This commit is contained in:
Vincent Breitmoser
2015-11-09 02:10:13 +01:00
parent cf8d61f41e
commit 816dce0334

View File

@@ -701,24 +701,17 @@ public class OpenPgpService extends RemoteService {
Intent result = new Intent(); Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
// return public key if requested by defining a output stream boolean requestedKeyData = outputStream != null;
if (outputStream != null) { if (requestedKeyData) {
boolean requestAsciiArmor = boolean requestAsciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, false);
data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, false);
ArmoredOutputStream arOutStream = null;
try { try {
if (requestAsciiArmor) { if (requestAsciiArmor) {
arOutStream = new ArmoredOutputStream(outputStream); outputStream = new ArmoredOutputStream(outputStream);
keyRing.encode(arOutStream);
} else {
keyRing.encode(outputStream);
} }
keyRing.encode(outputStream);
} finally { } finally {
try { try {
if (arOutStream != null) {
arOutStream.close();
}
outputStream.close(); outputStream.close();
} catch (IOException e) { } catch (IOException e) {
Log.e(Constants.TAG, "IOException when closing OutputStream", e); Log.e(Constants.TAG, "IOException when closing OutputStream", e);