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

Commit 6fe10648 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13556564 from 40283620 to 25Q3-release

Change-Id: I0b9698e0fbf75f743f97d5f465e6cc32bbc485a6
parents fdf29f39 40283620
Loading
Loading
Loading
Loading
+44 −37
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ public final class MessageQueue {
    private static final String TAG_L = "LegacyMessageQueue";
    private static final String TAG_C = "ConcurrentMessageQueue";
    private static final boolean DEBUG = false;
    private static final boolean TRACE = false;

    // True if the message queue can be quit.
    @UnsupportedAppUsage
@@ -263,7 +262,6 @@ public final class MessageQueue {
        }
    }

    /** @hide */
    private void traceMessageCount() {
        PerfettoTrace.counter(PerfettoTrace.MQ_CATEGORY, mMessageCount.get())
                .usingThreadCounterTrack(mTid, mThreadName)
@@ -656,8 +654,7 @@ public final class MessageQueue {

        while (true) {
            if (DEBUG) {
                Log.d(TAG_C, "nextMessage loop #" + i);
                i++;
                Log.d(TAG_C, "nextMessage loop #" + i++);
            }

            mDrainingLock.lock();
@@ -722,20 +719,26 @@ public final class MessageQueue {
            /* Get the first node from each queue */
            MessageNode msgNode = first(mPriorityQueue);
            MessageNode asyncMsgNode = first(mAsyncPriorityQueue);
            final long now = SystemClock.uptimeMillis();

            if (DEBUG) {
                if (msgNode != null) {
                    Message msg = msgNode.mMessage;
                    Log.d(TAG_C, "Next found node what: " + msg.what + " when: " + msg.when
                            + " seq: " + msgNode.mInsertSeq + "barrier: "
                            + msgNode.isBarrier() + " now: " + SystemClock.uptimeMillis());
                    Log.d(TAG_C, "Next found node"
                            + " what: " + msg.what
                            + " when: " + msg.when
                            + " seq: " + msgNode.mInsertSeq
                            + " barrier: " + msgNode.isBarrier()
                            + " now: " + now);
                }
                if (asyncMsgNode != null) {
                    Message msg = asyncMsgNode.mMessage;
                    Log.d(TAG_C, "Next found async node what: " + msg.what + " when: " + msg.when
                            + " seq: " + asyncMsgNode.mInsertSeq + "barrier: "
                            + asyncMsgNode.isBarrier() + " now: "
                            + SystemClock.uptimeMillis());
                    Log.d(TAG_C, "Next found async node"
                            + " what: " + msg.what
                            + " when: " + msg.when
                            + " seq: " + asyncMsgNode.mInsertSeq
                            + " barrier: " + asyncMsgNode.isBarrier()
                            + " now: " + now);
                }
            }

@@ -751,7 +754,6 @@ public final class MessageQueue {
             */
            MessageNode next = null;

            long now = SystemClock.uptimeMillis();
            /*
             * If we have a barrier we should return the async node (if it exists and is ready)
             */
@@ -781,19 +783,25 @@ public final class MessageQueue {
            if (DEBUG) {
                if (found != null) {
                    Message msg = found.mMessage;
                    Log.d(TAG_C, " Will deliver node what: " + msg.what + " when: " + msg.when
                            + " seq: " + found.mInsertSeq + " barrier: " + found.isBarrier()
                            + " async: " + found.isAsync() + " now: "
                            + SystemClock.uptimeMillis());
                    Log.d(TAG_C, "Will deliver node"
                            + " what: " + msg.what
                            + " when: " + msg.when
                            + " seq: " + found.mInsertSeq
                            + " barrier: " + found.isBarrier()
                            + " async: " + found.isAsync()
                            + " now: " + now);
                } else {
                    Log.d(TAG_C, "No node to deliver");
                }
                if (next != null) {
                    Message msg = next.mMessage;
                    Log.d(TAG_C, "Next node what: " + msg.what + " when: " + msg.when + " seq: "
                            + next.mInsertSeq + " barrier: " + next.isBarrier() + " async: "
                            + next.isAsync()
                            + " now: " + SystemClock.uptimeMillis());
                    Log.d(TAG_C, "Next node"
                            + " what: " + msg.what
                            + " when: " + msg.when
                            + " seq: " + next.mInsertSeq
                            + " barrier: " + next.isBarrier()
                            + " async: " + next.isAsync()
                            + " now: " + now);
                } else {
                    Log.d(TAG_C, "No next node");
                }
@@ -830,9 +838,10 @@ public final class MessageQueue {
                    mStackStateTimedPark.mWhenToWake = now + mNextPollTimeoutMillis;
                    nextOp = mStackStateTimedPark;
                    if (DEBUG) {
                        Log.d(TAG_C, "nextMessage next state is StackStateTimedParked timeout ms "
                                + mNextPollTimeoutMillis + " mWhenToWake: "
                                + mStackStateTimedPark.mWhenToWake + " now " + now);
                        Log.d(TAG_C, "nextMessage next state is StackStateTimedParked"
                                + " timeout ms " + mNextPollTimeoutMillis
                                + " mWhenToWake: " + mStackStateTimedPark.mWhenToWake
                                + " now: " + now);
                    }
                }
            }
@@ -852,9 +861,6 @@ public final class MessageQueue {
                        continue;
                    }

                    if (TRACE) {
                        Trace.setCounter("MQ.Delivered", mMessagesDelivered.incrementAndGet());
                    }
                    return found.mMessage;
                }
                return null;
@@ -995,9 +1001,6 @@ public final class MessageQueue {
                            mAsyncMessageCount--;
                        }
                        decAndTraceMessageCount();
                        if (TRACE) {
                            Trace.setCounter("MQ.Delivered", mMessagesDelivered.incrementAndGet());
                        }
                        return msg;
                    }
                } else {
@@ -1460,9 +1463,6 @@ public final class MessageQueue {
                    mAsyncMessageCount--;
                }
                decAndTraceMessageCount();
                if (TRACE) {
                    Trace.setCounter("MQ.Delivered", mMessagesDelivered.incrementAndGet());
                }
                return msg;
            }
        }
@@ -2179,8 +2179,10 @@ public final class MessageQueue {
        Log.d(TAG_C, "* Dump priority queue");
        while (iterator.hasNext()) {
            MessageNode msgNode = iterator.next();
            Log.d(TAG_C, "** MessageNode what: " + msgNode.mMessage.what + " when "
                    + msgNode.mMessage.when + " seq: " + msgNode.mInsertSeq);
            Log.d(TAG_C,
                    "** MessageNode what: " + msgNode.mMessage.what
                    + " when " + msgNode.mMessage.when
                    + " seq: " + msgNode.mInsertSeq);
        }
    }

@@ -2907,9 +2909,13 @@ public final class MessageQueue {
        incAndTraceMessageCount(msg, when);

        if (DEBUG) {
            Log.d(TAG_C, "Insert message what: " + msg.what + " when: " + msg.when + " seq: "
                    + node.mInsertSeq + " barrier: " + node.isBarrier() + " async: "
                    + node.isAsync() + " now: " + SystemClock.uptimeMillis());
            Log.d(TAG_C, "Insert message"
                    + " what: " + msg.what
                    + " when: " + msg.when
                    + " seq: " + node.mInsertSeq
                    + " barrier: " + node.isBarrier()
                    + " async: " + node.isAsync()
                    + " now: " + SystemClock.uptimeMillis());
        }

        final Looper myLooper = Looper.myLooper();
@@ -2920,6 +2926,7 @@ public final class MessageQueue {
                        msg.target + " sending message to a Handler on a dead thread");
                Log.w(TAG_C, e.getMessage(), e);
                msg.recycleUnchecked();
                decAndTraceMessageCount();
                return false;
            }

+3 −0
Original line number Diff line number Diff line
@@ -468,6 +468,9 @@ public final class Looper {
     * at the beginning and ending of each message dispatch, identifying the
     * target Handler and message contents.
     *
     * Message logging introduces a performance penalty, and is disabled by
     * default.
     *
     * @param printer A Printer object that will receive log messages, or
     * null to disable message logging.
     */
+1 −1
Original line number Diff line number Diff line
@@ -4021,7 +4021,7 @@ public class UserManager {
     * {@code android.Manifest.permission#MANAGE_USERS},
     * {@code android.Manifest.permission#QUERY_USERS}, or
     * {@code android.Manifest.permission#INTERACT_ACROSS_USERS}
     * permission, or else the caller must be in the same profile group as the caller.
     * permission, or else the caller must be in the same profile group as the specified user.
     *
     * @param userHandle the user handle of the user whose information is being requested.
     * @return a UserProperties object for a specific user.
+6 −11
Original line number Diff line number Diff line
@@ -55,12 +55,12 @@ public abstract class InputEventReceiver {
    private static native void nativeDispose(long receiverPtr);
    private static native void nativeFinishInputEvent(long receiverPtr, int seq, boolean handled);
    private static native boolean nativeProbablyHasInput(long receiverPtr);
    private static native void nativeReportTimeline(long receiverPtr, int inputEventId,
            long gpuCompletedTime, long presentTime);
    private static native boolean nativeConsumeBatchedInputEvents(long receiverPtr,
            long frameTimeNanos);
    private static native long nativeGetFrameMetricsObserver(long receiverPtr);
    private static native String nativeDump(long receiverPtr, String prefix);


    /**
     * Creates an input event receiver bound to the specified input channel.
     *
@@ -233,15 +233,6 @@ public abstract class InputEventReceiver {
        event.recycleIfNeededAfterDispatch();
    }

    /**
     * Report the timing / latency information for a specific input event.
     */
    public final void reportTimeline(int inputEventId, long gpuCompletedTime, long presentTime) {
        Trace.traceBegin(Trace.TRACE_TAG_INPUT, "reportTimeline");
        nativeReportTimeline(mReceiverPtr, inputEventId, gpuCompletedTime, presentTime);
        Trace.traceEnd(Trace.TRACE_TAG_INPUT);
    }

    /**
     * Consumes all pending batched input events.
     * Must be called on the same Looper thread to which the receiver is attached.
@@ -264,6 +255,10 @@ public abstract class InputEventReceiver {
        return false;
    }

    protected final long getNativeFrameMetricsObserver() {
        return nativeGetFrameMetricsObserver(mReceiverPtr);
    }

    /**
     * @return Returns a token to identify the input channel.
     */
+11 −48
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.content.pm.ActivityInfo.OVERRIDE_SANDBOX_VIEW_BOUNDS_APIS;
import static android.graphics.HardwareRenderer.SYNC_CONTEXT_IS_STOPPED;
import static android.graphics.HardwareRenderer.SYNC_LOST_SURFACE_REWARD_IF_FOUND;
import static android.os.IInputConstants.INVALID_INPUT_EVENT_ID;
import static android.os.Trace.TRACE_TAG_VIEW;
import static android.util.SequenceUtils.getInitSeq;
import static android.util.SequenceUtils.isIncomingSeqStale;
@@ -369,13 +368,6 @@ public final class ViewRootImpl implements ViewParent,
     */
    private static final boolean MT_RENDERER_AVAILABLE = true;
    /**
     * Whether or not to report end-to-end input latency. Can be disabled temporarily as a
     * risk mitigation against potential jank caused by acquiring a weak reference
     * per frame.
     */
    private static final boolean ENABLE_INPUT_LATENCY_TRACKING = true;
    /**
     * Whether the client (system UI) is handling the transient gesture and the corresponding
     * animation.
@@ -1742,14 +1734,8 @@ public final class ViewRootImpl implements ViewParent,
                        mInputQueueCallback.onInputQueueCreated(mInputQueue);
                    }
                    mInputEventReceiver = new WindowInputEventReceiver(inputChannel,
                            Looper.myLooper());
                            Looper.myLooper(), mAttachInfo.mThreadedRenderer);
                    if (ENABLE_INPUT_LATENCY_TRACKING && mAttachInfo.mThreadedRenderer != null) {
                        InputMetricsListener listener = new InputMetricsListener();
                        mHardwareRendererObserver = new HardwareRendererObserver(
                                listener, listener.data, mHandler, true /*waitForPresentTime*/);
                        mAttachInfo.mThreadedRenderer.addObserver(mHardwareRendererObserver);
                    }
                    // Update unbuffered request when set the root view.
                    mUnbufferedInputSource = mView.mUnbufferedInputSource;
                }
@@ -10698,8 +10684,14 @@ public final class ViewRootImpl implements ViewParent,
    final TraversalRunnable mTraversalRunnable = new TraversalRunnable();
    final class WindowInputEventReceiver extends InputEventReceiver {
        public WindowInputEventReceiver(InputChannel inputChannel, Looper looper) {
        private final HardwareRenderer mRenderer;
        WindowInputEventReceiver(InputChannel inputChannel, Looper looper,
                HardwareRenderer renderer) {
            super(inputChannel, looper);
            mRenderer = renderer;
            if (mRenderer != null) {
                mRenderer.addObserver(getNativeFrameMetricsObserver());
            }
        }
        @Override
@@ -10751,43 +10743,14 @@ public final class ViewRootImpl implements ViewParent,
        @Override
        public void dispose() {
            unscheduleConsumeBatchedInput();
            if (mRenderer != null) {
                mRenderer.removeObserver(getNativeFrameMetricsObserver());
            }
            super.dispose();
        }
    }
    private WindowInputEventReceiver mInputEventReceiver;
    final class InputMetricsListener
            implements HardwareRendererObserver.OnFrameMetricsAvailableListener {
        public long[] data = new long[FrameMetrics.Index.FRAME_STATS_COUNT];
        @Override
        public void onFrameMetricsAvailable(int dropCountSinceLastInvocation) {
            final int inputEventId = (int) data[FrameMetrics.Index.INPUT_EVENT_ID];
            if (inputEventId == INVALID_INPUT_EVENT_ID) {
                return;
            }
            final long presentTime = data[FrameMetrics.Index.DISPLAY_PRESENT_TIME];
            if (presentTime <= 0) {
                // Present time is not available for this frame. If the present time is not
                // available, we cannot compute end-to-end input latency metrics.
                return;
            }
            final long gpuCompletedTime = data[FrameMetrics.Index.GPU_COMPLETED];
            if (mInputEventReceiver == null) {
                return;
            }
            if (gpuCompletedTime >= presentTime) {
                final double discrepancyMs = (gpuCompletedTime - presentTime) * 1E-6;
                final long vsyncId = data[FrameMetrics.Index.FRAME_TIMELINE_VSYNC_ID];
                Log.w(TAG, "Not reporting timeline because gpuCompletedTime is " + discrepancyMs
                        + "ms ahead of presentTime. FRAME_TIMELINE_VSYNC_ID=" + vsyncId
                        + ", INPUT_EVENT_ID=" + inputEventId);
                // TODO(b/186664409): figure out why this sometimes happens
                return;
            }
            mInputEventReceiver.reportTimeline(inputEventId, gpuCompletedTime, presentTime);
        }
    }
    HardwareRendererObserver mHardwareRendererObserver;
    final class ConsumeBatchedInputRunnable implements Runnable {
Loading