Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95565259 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "AsyncTask now uses the poll executor for apps up through HC MR1 and the...

Merge "AsyncTask now uses the poll executor for apps up through HC MR1 and the serialized one after that."
parents 45a746a1 d630f105
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.graphics.Canvas;
import android.net.IConnectivityManager;
import android.net.Proxy;
import android.net.ProxyProperties;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
@@ -3427,6 +3428,14 @@ public final class ActivityThread {
        Process.setArgV0(data.processName);
        android.ddm.DdmHandleAppName.setAppName(data.processName);

        // If the app is Honeycomb MR1 or earlier, switch its AsyncTask
        // implementation to use the pool executor.  Normally, we use the
        // serialized executor as the default. This has to happen in the
        // main thread so the main looper is set right.
        if (data.appInfo.targetSdkVersion <= 12) {
            AsyncTask.setDefaultExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }

        /*
         * Before spawning a new process, reset the time zone to be the system time zone.
         * This needs to be done because the system time zone could have changed after the
+8 −3
Original line number Diff line number Diff line
@@ -153,7 +153,6 @@ public abstract class AsyncTask<Params, Progress, Result> {
    private static final int MAXIMUM_POOL_SIZE = 128;
    private static final int KEEP_ALIVE = 1;


    private static final ThreadFactory sThreadFactory = new ThreadFactory() {
        private final AtomicInteger mCount = new AtomicInteger(1);

@@ -183,6 +182,7 @@ public abstract class AsyncTask<Params, Progress, Result> {

    private static final InternalHandler sHandler = new InternalHandler();

    private static volatile Executor sDefaultExecutor = SERIAL_EXECUTOR;
    private final WorkerRunnable<Params, Result> mWorker;
    private final FutureTask<Result> mFuture;

@@ -240,6 +240,11 @@ public abstract class AsyncTask<Params, Progress, Result> {
        sHandler.getLooper();
    }

    /** @hide */
    public static void setDefaultExecutor(Executor exec) {
        sDefaultExecutor = exec;
    }

    /**
     * Creates a new asynchronous task. This constructor must be invoked on the UI thread.
     */
@@ -496,7 +501,7 @@ public abstract class AsyncTask<Params, Progress, Result> {
     *         {@link AsyncTask.Status#RUNNING} or {@link AsyncTask.Status#FINISHED}.
     */
    public final AsyncTask<Params, Progress, Result> execute(Params... params) {
        return executeOnExecutor(THREAD_POOL_EXECUTOR, params);
        return executeOnExecutor(sDefaultExecutor, params);
    }

    /**
@@ -559,7 +564,7 @@ public abstract class AsyncTask<Params, Progress, Result> {
     * a simple Runnable object.
     */
    public static void execute(Runnable runnable) {
        THREAD_POOL_EXECUTOR.execute(runnable);
        sDefaultExecutor.execute(runnable);
    }

    /**