reapply accedentially reverted 5d88672609

This commit is contained in:
Dominik Schürmann 2014-02-24 01:47:53 +01:00
parent 0747a5815f
commit e97630b75e
2 changed files with 20 additions and 2 deletions

View File

@ -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) {

View File

@ -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) {