service: minor code cleanups in key retrieval
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user