Merge "Fix AsyncTask to handle exceptions in doInBackground" into nyc-mr1-dev

This commit is contained in:
Tony Mantler
2016-08-24 17:00:02 +00:00
committed by Android (Google) Code Review

View File

@@ -298,12 +298,16 @@ public abstract class AsyncTask<Params, Progress, Result> {
mWorker = new WorkerRunnable<Params, Result>() { mWorker = new WorkerRunnable<Params, Result>() {
public Result call() throws Exception { public Result call() throws Exception {
mTaskInvoked.set(true); mTaskInvoked.set(true);
Result result = null;
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); try {
//noinspection unchecked Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
Result result = doInBackground(mParams); //noinspection unchecked
Binder.flushPendingCommands(); result = doInBackground(mParams);
return postResult(result); Binder.flushPendingCommands();
} finally {
postResult(result);
}
return result;
} }
}; };