From 5d8867260946937498cf9e8d64fea3a9f53d9dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Feb 2014 15:56:58 +0100 Subject: do not serialize async tasks --- .../src/org/openintents/openpgp/util/OpenPgpApi.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenPGP-Keychain-API') diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java index f121c345d..41cbfec59 100644 --- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -18,6 +18,7 @@ package org.openintents.openpgp.util; import android.content.Context; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.util.Log; @@ -127,7 +128,15 @@ public class OpenPgpApi { } private void executeApiAsync(int operationId, Bundle params, InputStream is, OutputStream os, IOpenPgpCallback callback) { - new OpenPgpAsyncTask(operationId, params, is, os, callback).execute((Void[]) null); + OpenPgpAsyncTask task = new OpenPgpAsyncTask(operationId, params, is, os, callback); + + // don't serialize async tasks! + // http://commonsware.com/blog/2012/04/20/asynctask-threading-regression-confirmed.html + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); + } else { + task.execute((Void[]) null); + } } private Bundle executeApi(int operationId, Bundle params, InputStream is, OutputStream os) { -- cgit v1.2.3