Loading core/java/android/os/AsyncTask.java +6 −4 Original line number Original line Diff line number Diff line Loading @@ -195,6 +195,7 @@ public abstract class AsyncTask<Params, Progress, Result> { private volatile Status mStatus = Status.PENDING; private volatile Status mStatus = Status.PENDING; private final AtomicBoolean mCancelled = new AtomicBoolean(); private final AtomicBoolean mTaskInvoked = new AtomicBoolean(); private final AtomicBoolean mTaskInvoked = new AtomicBoolean(); private static class SerialExecutor implements Executor { private static class SerialExecutor implements Executor { Loading Loading @@ -261,6 +262,7 @@ public abstract class AsyncTask<Params, Progress, Result> { mTaskInvoked.set(true); mTaskInvoked.set(true); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); //noinspection unchecked return postResult(doInBackground(mParams)); return postResult(doInBackground(mParams)); } } }; }; Loading @@ -269,9 +271,7 @@ public abstract class AsyncTask<Params, Progress, Result> { @Override @Override protected void done() { protected void done() { try { try { final Result result = get(); postResultIfNotInvoked(get()); postResultIfNotInvoked(result); } catch (InterruptedException e) { } catch (InterruptedException e) { android.util.Log.w(LOG_TAG, e); android.util.Log.w(LOG_TAG, e); } catch (ExecutionException e) { } catch (ExecutionException e) { Loading @@ -295,6 +295,7 @@ public abstract class AsyncTask<Params, Progress, Result> { } } private Result postResult(Result result) { private Result postResult(Result result) { @SuppressWarnings("unchecked") Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT, Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT, new AsyncTaskResult<Result>(this, result)); new AsyncTaskResult<Result>(this, result)); message.sendToTarget(); message.sendToTarget(); Loading Loading @@ -411,7 +412,7 @@ public abstract class AsyncTask<Params, Progress, Result> { * @see #cancel(boolean) * @see #cancel(boolean) */ */ public final boolean isCancelled() { public final boolean isCancelled() { return mFuture.isCancelled(); return mCancelled.get(); } } /** /** Loading Loading @@ -444,6 +445,7 @@ public abstract class AsyncTask<Params, Progress, Result> { * @see #onCancelled(Object) * @see #onCancelled(Object) */ */ public final boolean cancel(boolean mayInterruptIfRunning) { public final boolean cancel(boolean mayInterruptIfRunning) { mCancelled.set(true); return mFuture.cancel(mayInterruptIfRunning); return mFuture.cancel(mayInterruptIfRunning); } } Loading Loading
core/java/android/os/AsyncTask.java +6 −4 Original line number Original line Diff line number Diff line Loading @@ -195,6 +195,7 @@ public abstract class AsyncTask<Params, Progress, Result> { private volatile Status mStatus = Status.PENDING; private volatile Status mStatus = Status.PENDING; private final AtomicBoolean mCancelled = new AtomicBoolean(); private final AtomicBoolean mTaskInvoked = new AtomicBoolean(); private final AtomicBoolean mTaskInvoked = new AtomicBoolean(); private static class SerialExecutor implements Executor { private static class SerialExecutor implements Executor { Loading Loading @@ -261,6 +262,7 @@ public abstract class AsyncTask<Params, Progress, Result> { mTaskInvoked.set(true); mTaskInvoked.set(true); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); //noinspection unchecked return postResult(doInBackground(mParams)); return postResult(doInBackground(mParams)); } } }; }; Loading @@ -269,9 +271,7 @@ public abstract class AsyncTask<Params, Progress, Result> { @Override @Override protected void done() { protected void done() { try { try { final Result result = get(); postResultIfNotInvoked(get()); postResultIfNotInvoked(result); } catch (InterruptedException e) { } catch (InterruptedException e) { android.util.Log.w(LOG_TAG, e); android.util.Log.w(LOG_TAG, e); } catch (ExecutionException e) { } catch (ExecutionException e) { Loading @@ -295,6 +295,7 @@ public abstract class AsyncTask<Params, Progress, Result> { } } private Result postResult(Result result) { private Result postResult(Result result) { @SuppressWarnings("unchecked") Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT, Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT, new AsyncTaskResult<Result>(this, result)); new AsyncTaskResult<Result>(this, result)); message.sendToTarget(); message.sendToTarget(); Loading Loading @@ -411,7 +412,7 @@ public abstract class AsyncTask<Params, Progress, Result> { * @see #cancel(boolean) * @see #cancel(boolean) */ */ public final boolean isCancelled() { public final boolean isCancelled() { return mFuture.isCancelled(); return mCancelled.get(); } } /** /** Loading Loading @@ -444,6 +445,7 @@ public abstract class AsyncTask<Params, Progress, Result> { * @see #onCancelled(Object) * @see #onCancelled(Object) */ */ public final boolean cancel(boolean mayInterruptIfRunning) { public final boolean cancel(boolean mayInterruptIfRunning) { mCancelled.set(true); return mFuture.cancel(mayInterruptIfRunning); return mFuture.cancel(mayInterruptIfRunning); } } Loading