From 820e183ca76d0f7feb5d7584d5eddcd49a4e7d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 28 Aug 2015 17:03:15 +0200 Subject: Fix and improve OpenPgpService2 code --- .../java/org/openintents/openpgp/example/OpenPgpApiActivity.java | 4 ++-- .../src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl | 8 +++++--- .../src/main/aidl/org/openintents/openpgp/IOpenPgpService2.aidl | 9 ++++++++- .../org/openintents/openpgp/util/ParcelFileDescriptorUtil.java | 9 ++++----- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java b/example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java index 1c3ab1e..823c202 100644 --- a/example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java +++ b/example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java @@ -30,7 +30,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.Toast; -import org.openintents.openpgp.IOpenPgpService; +import org.openintents.openpgp.IOpenPgpService2; import org.openintents.openpgp.OpenPgpDecryptionResult; import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpSignatureResult; @@ -148,7 +148,7 @@ public class OpenPgpApiActivity extends Activity { providerPackageName, new OpenPgpServiceConnection.OnBound() { @Override - public void onBound(IOpenPgpService service) { + public void onBound(IOpenPgpService2 service) { Log.d(OpenPgpApi.TAG, "onBound!"); } diff --git a/openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl b/openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl index 8fa619b..3689d17 100644 --- a/openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl +++ b/openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl @@ -13,13 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + package org.openintents.openpgp; interface IOpenPgpService { - // see OpenPgpApi for documentation - //DEPRECATED, do NOT use this, data returned from the service through "output" may be truncated + /** + * do NOT use this, data returned from the service through "output" may be truncated + * @deprecated + */ Intent execute(in Intent data, in ParcelFileDescriptor input, in ParcelFileDescriptor output); } \ No newline at end of file diff --git a/openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService2.aidl b/openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService2.aidl index 39c24e5..8aa4dd2 100644 --- a/openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService2.aidl +++ b/openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService2.aidl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2015 Dominik Schürmann + * Copyright (C) 2015 Dominik Schürmann * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,13 @@ package org.openintents.openpgp; interface IOpenPgpService2 { + /** + * see org.openintents.openpgp.util.OpenPgpApi for documentation + */ ParcelFileDescriptor createOutputPipe(in int pipeId); + + /** + * see org.openintents.openpgp.util.OpenPgpApi for documentation + */ Intent execute(in Intent data, in ParcelFileDescriptor input, int pipeId); } diff --git a/openpgp-api/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java b/openpgp-api/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java index 461a5ba..931ed84 100644 --- a/openpgp-api/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java +++ b/openpgp-api/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java @@ -18,6 +18,7 @@ package org.openintents.openpgp.util; import android.os.ParcelFileDescriptor; +import android.util.Log; import java.io.IOException; import java.io.InputStream; @@ -69,17 +70,15 @@ public class ParcelFileDescriptorUtil { mOut.write(buf, 0, len); } } catch (IOException e) { - e.printStackTrace(); + Log.e(OpenPgpApi.TAG, "IOException when writing to out", e); } finally { try { mIn.close(); - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException ignored) { } try { mOut.close(); - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException ignored) { } } } -- cgit v1.2.3