Merge "Forces AsyncTask to use the main looper Bug #5333924"
This commit is contained in:
@@ -237,6 +237,7 @@ public abstract class AsyncTask<Params, Progress, Result> {
|
|||||||
|
|
||||||
/** @hide Used to force static handler to be created. */
|
/** @hide Used to force static handler to be created. */
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
// TODO: This doesn't do anything, we should get rid of it
|
||||||
sHandler.getLooper();
|
sHandler.getLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,6 +255,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));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -288,7 +290,7 @@ public abstract class AsyncTask<Params, Progress, Result> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Result postResult(Result result) {
|
private Result postResult(Result result) {
|
||||||
Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT,
|
@SuppressWarnings({"unchecked"}) Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT,
|
||||||
new AsyncTaskResult<Result>(this, result));
|
new AsyncTaskResult<Result>(this, result));
|
||||||
message.sendToTarget();
|
message.sendToTarget();
|
||||||
return result;
|
return result;
|
||||||
@@ -598,6 +600,10 @@ public abstract class AsyncTask<Params, Progress, Result> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class InternalHandler extends Handler {
|
private static class InternalHandler extends Handler {
|
||||||
|
InternalHandler() {
|
||||||
|
super(Looper.getMainLooper());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
|
@SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
|
|||||||
Reference in New Issue
Block a user