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

Commit eadefb25 authored by Jeff Brown's avatar Jeff Brown Committed by android-build-merger
Browse files

am bba231d7: Explicitly bind AsyncTask to main looper.

automerge: dfe7d219

* commit 'dfe7d219':
  Explicitly bind AsyncTask to main looper.
parents 60af60c4 dfe7d219
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -5223,8 +5223,6 @@ public final class ActivityThread {
            sMainThreadHandler = thread.getHandler();
            sMainThreadHandler = thread.getHandler();
        }
        }


        AsyncTask.init();

        if (false) {
        if (false) {
            Looper.myLooper().setMessageLogging(new
            Looper.myLooper().setMessageLogging(new
                    LogPrinter(Log.DEBUG, "ActivityThread"));
                    LogPrinter(Log.DEBUG, "ActivityThread"));
+0 −6
Original line number Original line Diff line number Diff line
@@ -1659,12 +1659,6 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
    }
    }


    private void attachInfo(Context context, ProviderInfo info, boolean testing) {
    private void attachInfo(Context context, ProviderInfo info, boolean testing) {
        /*
         * We may be using AsyncTask from binder threads.  Make it init here
         * so its static handler is on the main thread.
         */
        AsyncTask.init();

        mNoPerms = testing;
        mNoPerms = testing;


        /*
        /*
+16 −8
Original line number Original line Diff line number Diff line
@@ -209,9 +209,9 @@ public abstract class AsyncTask<Params, Progress, Result> {
    private static final int MESSAGE_POST_RESULT = 0x1;
    private static final int MESSAGE_POST_RESULT = 0x1;
    private static final int MESSAGE_POST_PROGRESS = 0x2;
    private static final int MESSAGE_POST_PROGRESS = 0x2;


    private static final InternalHandler sHandler = new InternalHandler();

    private static volatile Executor sDefaultExecutor = SERIAL_EXECUTOR;
    private static volatile Executor sDefaultExecutor = SERIAL_EXECUTOR;
    private static InternalHandler sHandler;

    private final WorkerRunnable<Params, Result> mWorker;
    private final WorkerRunnable<Params, Result> mWorker;
    private final FutureTask<Result> mFuture;
    private final FutureTask<Result> mFuture;


@@ -265,9 +265,13 @@ public abstract class AsyncTask<Params, Progress, Result> {
        FINISHED,
        FINISHED,
    }
    }


    /** @hide Used to force static handler to be created. */
    private static Handler getHandler() {
    public static void init() {
        synchronized (AsyncTask.class) {
        sHandler.getLooper();
            if (sHandler == null) {
                sHandler = new InternalHandler();
            }
            return sHandler;
        }
    }
    }


    /** @hide */
    /** @hide */
@@ -315,7 +319,7 @@ public abstract class AsyncTask<Params, Progress, Result> {


    private Result postResult(Result result) {
    private Result postResult(Result result) {
        @SuppressWarnings("unchecked")
        @SuppressWarnings("unchecked")
        Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT,
        Message message = getHandler().obtainMessage(MESSAGE_POST_RESULT,
                new AsyncTaskResult<Result>(this, result));
                new AsyncTaskResult<Result>(this, result));
        message.sendToTarget();
        message.sendToTarget();
        return result;
        return result;
@@ -620,7 +624,7 @@ public abstract class AsyncTask<Params, Progress, Result> {
     */
     */
    protected final void publishProgress(Progress... values) {
    protected final void publishProgress(Progress... values) {
        if (!isCancelled()) {
        if (!isCancelled()) {
            sHandler.obtainMessage(MESSAGE_POST_PROGRESS,
            getHandler().obtainMessage(MESSAGE_POST_PROGRESS,
                    new AsyncTaskResult<Progress>(this, values)).sendToTarget();
                    new AsyncTaskResult<Progress>(this, values)).sendToTarget();
        }
        }
    }
    }
@@ -635,10 +639,14 @@ public abstract class AsyncTask<Params, Progress, Result> {
    }
    }


    private static class InternalHandler extends Handler {
    private static class InternalHandler extends Handler {
        public InternalHandler() {
            super(Looper.getMainLooper());
        }

        @SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
        @SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
        @Override
        @Override
        public void handleMessage(Message msg) {
        public void handleMessage(Message msg) {
            AsyncTaskResult result = (AsyncTaskResult) msg.obj;
            AsyncTaskResult<?> result = (AsyncTaskResult<?>) msg.obj;
            switch (msg.what) {
            switch (msg.what) {
                case MESSAGE_POST_RESULT:
                case MESSAGE_POST_RESULT:
                    // There is only one result
                    // There is only one result