summaryrefslogtreecommitdiff
path: root/core/java/android/os/AsyncTask.java
diff options
context:
space:
mode:
authorDmitri Plotnikov <dplotnikov@google.com>2010-06-16 15:38:07 -0700
committerDmitri Plotnikov <dplotnikov@google.com>2010-06-16 15:38:07 -0700
commitbef9c7a59dc020c5cdcbd555b5212ae5a10e8045 (patch)
tree584103dc584ee9dc1ab5997595ebb913c5b70ed7 /core/java/android/os/AsyncTask.java
parentce718947db0d305a8cf015c29e68907d42e1b6cd (diff)
Preventing cursor leaks when a query is interrupted
Re-ran runtest cts-os Change-Id: I518a2a4f842b01d082078e16643aa377a4575237
Diffstat (limited to 'core/java/android/os/AsyncTask.java')
-rw-r--r--core/java/android/os/AsyncTask.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/java/android/os/AsyncTask.java b/core/java/android/os/AsyncTask.java
index 823134b5cab9..832ce84f52ef 100644
--- a/core/java/android/os/AsyncTask.java
+++ b/core/java/android/os/AsyncTask.java
@@ -187,6 +187,17 @@ public abstract class AsyncTask<Params, Progress, Result> {
};
mFuture = new FutureTask<Result>(mWorker) {
+
+ @Override
+ protected void set(Result v) {
+ super.set(v);
+ if (isCancelled()) {
+ Message message = sHandler.obtainMessage(MESSAGE_POST_CANCEL,
+ new AsyncTaskResult<Result>(AsyncTask.this, (Result[]) null));
+ message.sendToTarget();
+ }
+ }
+
@Override
protected void done() {
Message message;
@@ -401,7 +412,7 @@ public abstract class AsyncTask<Params, Progress, Result> {
* publish updates on the UI thread while the background computation is
* still running. Each call to this method will trigger the execution of
* {@link #onProgressUpdate} on the UI thread.
- *
+ *
* {@link #onProgressUpdate} will note be called if the task has been
* canceled.
*