mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 05:02:26 -05:00
Avoid StrictMode error in OpenPgpApi
E/StrictMode(9278): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. E/StrictMode(9278): java.lang.Throwable: Explicit termination method 'close' not called E/StrictMode(9278): at dalvik.system.CloseGuard.open(CloseGuard.java:184) E/StrictMode(9278): at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:179) E/StrictMode(9278): at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:168) E/StrictMode(9278): at android.os.ParcelFileDescriptor.createPipe(ParcelFileDescriptor.java:362) E/StrictMode(9278): at org.openintents.openpgp.util.ParcelFileDescriptorUtil.pipeFrom(ParcelFileDescriptorUtil.java:34) E/StrictMode(9278): at org.openintents.openpgp.util.OpenPgpApi.executeApi(OpenPgpApi.java:222) E/StrictMode(9278): at org.openintents.openpgp.util.OpenPgpApi$OpenPgpAsyncTask.doInBackground(OpenPgpApi.java:189) E/StrictMode(9278): at org.openintents.openpgp.util.OpenPgpApi$OpenPgpAsyncTask.doInBackground(OpenPgpApi.java:1) E/StrictMode(9278): at android.os.AsyncTask$2.call(AsyncTask.java:288) E/StrictMode(9278): at java.util.concurrent.FutureTask.run(FutureTask.java:237) E/StrictMode(9278): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) E/StrictMode(9278): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) E/StrictMode(9278): at java.lang.Thread.run(Thread.java:841)
This commit is contained in:
parent
5cc4d7c6a9
commit
58efee8be2
@ -25,6 +25,8 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
import org.openintents.openpgp.IOpenPgpService;
|
||||
import org.openintents.openpgp.OpenPgpError;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@ -209,6 +211,7 @@ public class OpenPgpApi {
|
||||
}
|
||||
|
||||
public Intent executeApi(Intent data, InputStream is, OutputStream os) {
|
||||
ParcelFileDescriptor input = null;
|
||||
try {
|
||||
data.putExtra(EXTRA_API_VERSION, OpenPgpApi.API_VERSION);
|
||||
|
||||
@ -219,7 +222,7 @@ public class OpenPgpApi {
|
||||
return result;
|
||||
} else {
|
||||
// pipe the input and output
|
||||
ParcelFileDescriptor input = ParcelFileDescriptorUtil.pipeFrom(is,
|
||||
input = ParcelFileDescriptorUtil.pipeFrom(is,
|
||||
new ParcelFileDescriptorUtil.IThreadListener() {
|
||||
|
||||
@Override
|
||||
@ -255,6 +258,14 @@ public class OpenPgpApi {
|
||||
result.putExtra(RESULT_ERROR,
|
||||
new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, e.getMessage()));
|
||||
return result;
|
||||
} finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(OpenPgpApi.TAG, "Failed to close input file descriptor", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user