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

Commit f8d9e2fc authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Make all messages in KeyguardViewMediator asynchronous." into jb-mr1-dev

parents 595b6565 109025d7
Loading
Loading
Loading
Loading
+46 −19
Original line number Original line Diff line number Diff line
@@ -123,6 +123,7 @@ public class Handler {
        }
        }
        mQueue = mLooper.mQueue;
        mQueue = mLooper.mQueue;
        mCallback = null;
        mCallback = null;
        mAsynchronous = false;
    }
    }


    /**
    /**
@@ -147,6 +148,7 @@ public class Handler {
        }
        }
        mQueue = mLooper.mQueue;
        mQueue = mLooper.mQueue;
        mCallback = callback;
        mCallback = callback;
        mAsynchronous = false;
    }
    }


    /**
    /**
@@ -156,6 +158,7 @@ public class Handler {
        mLooper = looper;
        mLooper = looper;
        mQueue = looper.mQueue;
        mQueue = looper.mQueue;
        mCallback = null;
        mCallback = null;
        mAsynchronous = false;
    }
    }


    /**
    /**
@@ -166,6 +169,31 @@ public class Handler {
        mLooper = looper;
        mLooper = looper;
        mQueue = looper.mQueue;
        mQueue = looper.mQueue;
        mCallback = callback;
        mCallback = callback;
        mAsynchronous = false;
    }

    /**
     * Use the provided queue instead of the default one and take a callback
     * interface in which to handle messages.  Also set whether the handler
     * should be asynchronous.
     *
     * Handlers are synchronous by default unless this constructor is used to make
     * one that is strictly asynchronous.
     *
     * Asynchronous messages represent interrupts or events that do not require global ordering
     * with represent to synchronous messages.  Asynchronous messages are not subject to
     * the synchronization barriers introduced by {@link MessageQueue#enqueueSyncBarrier(long)}.
     *
     * @param async If true, the handler calls {@link Message#setAsynchronous(boolean)} for
     * each {@link Message} that is sent to it or {@link Runnable} that is posted to it.
     *
     * @hide
     */
    public Handler(Looper looper, Callback callback, boolean async) {
        mLooper = looper;
        mQueue = looper.mQueue;
        mCallback = callback;
        mAsynchronous = async;
    }
    }


    /**
    /**
@@ -464,20 +492,15 @@ public class Handler {
     *         the looper is quit before the delivery time of the message
     *         the looper is quit before the delivery time of the message
     *         occurs then the message will be dropped.
     *         occurs then the message will be dropped.
     */
     */
    public boolean sendMessageAtTime(Message msg, long uptimeMillis)
    public boolean sendMessageAtTime(Message msg, long uptimeMillis) {
    {
        boolean sent = false;
        MessageQueue queue = mQueue;
        MessageQueue queue = mQueue;
        if (queue != null) {
        if (queue == null) {
            msg.target = this;
            sent = queue.enqueueMessage(msg, uptimeMillis);
        }
        else {
            RuntimeException e = new RuntimeException(
            RuntimeException e = new RuntimeException(
                    this + " sendMessageAtTime() called with no mQueue");
                    this + " sendMessageAtTime() called with no mQueue");
            Log.w("Looper", e.getMessage(), e);
            Log.w("Looper", e.getMessage(), e);
            return false;
        }
        }
        return sent;
        return enqueueMessage(queue, msg, uptimeMillis);
    }
    }


    /**
    /**
@@ -492,20 +515,23 @@ public class Handler {
     *         message queue.  Returns false on failure, usually because the
     *         message queue.  Returns false on failure, usually because the
     *         looper processing the message queue is exiting.
     *         looper processing the message queue is exiting.
     */
     */
    public final boolean sendMessageAtFrontOfQueue(Message msg)
    public final boolean sendMessageAtFrontOfQueue(Message msg) {
    {
        boolean sent = false;
        MessageQueue queue = mQueue;
        MessageQueue queue = mQueue;
        if (queue != null) {
        if (queue == null) {
            msg.target = this;
            sent = queue.enqueueMessage(msg, 0);
        }
        else {
            RuntimeException e = new RuntimeException(
            RuntimeException e = new RuntimeException(
                this + " sendMessageAtTime() called with no mQueue");
                this + " sendMessageAtTime() called with no mQueue");
            Log.w("Looper", e.getMessage(), e);
            Log.w("Looper", e.getMessage(), e);
            return false;
        }
        return enqueueMessage(queue, msg, 0);
    }

    private boolean enqueueMessage(MessageQueue queue, Message msg, long uptimeMillis) {
        msg.target = this;
        if (mAsynchronous) {
            msg.setAsynchronous(true);
        }
        }
        return sent;
        return queue.enqueueMessage(msg, uptimeMillis);
    }
    }


    /**
    /**
@@ -618,5 +644,6 @@ public class Handler {
    final MessageQueue mQueue;
    final MessageQueue mQueue;
    final Looper mLooper;
    final Looper mLooper;
    final Callback mCallback;
    final Callback mCallback;
    final boolean mAsynchronous;
    IMessenger mMessenger;
    IMessenger mMessenger;
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import android.media.AudioManager;
import android.media.SoundPool;
import android.media.SoundPool;
import android.os.Handler;
import android.os.Handler;
import android.os.LocalPowerManager;
import android.os.LocalPowerManager;
import android.os.Looper;
import android.os.Message;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -976,7 +977,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback {
     * interacts with the keyguard ui should be posted to this handler, rather
     * interacts with the keyguard ui should be posted to this handler, rather
     * than called directly.
     * than called directly.
     */
     */
    private Handler mHandler = new Handler() {
    private Handler mHandler = new Handler(Looper.myLooper(), null, true /*async*/) {
        @Override
        @Override
        public void handleMessage(Message msg) {
        public void handleMessage(Message msg) {
            switch (msg.what) {
            switch (msg.what) {