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

Commit 221a5a1f authored by Ming-Shin Lu's avatar Ming-Shin Lu Committed by Android (Google) Code Review
Browse files

Merge "Notify renderer for CPU hint during process ViewPostImeInputStage" into main

parents c5c9881d 401c061c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -138,6 +138,13 @@ flag {
    bug: "277285195"
}

flag {
    name: "adpf_measure_during_input_event_boost"
    namespace: "game"
    description: "Guards use of a boost when view measures during input events"
    bug: "256549451"
}

flag {
    name: "battery_service_support_current_adb_command"
    namespace: "backstage_power"
+28 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.StateSet;
import android.util.SuperNotCalledException;
import android.util.TimeUtils;
import android.util.TypedValue;
import android.view.AccessibilityIterators.CharacterTextSegmentIterator;
import android.view.AccessibilityIterators.ParagraphTextSegmentIterator;
@@ -18096,6 +18097,24 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return false;
    }
    /**
     * Called by {@link #measure(int, int)} to check if the current frame presentation got
     * delayed by an expensive view mesures during the input event dispatching. (e.g. scrolling)
     */
    private boolean hasExpensiveMeasuresDuringInputEvent() {
        final AttachInfo attachInfo = mAttachInfo;
        if (attachInfo == null || attachInfo.mRootView == null) {
            return false;
        }
        if (!attachInfo.mHandlingPointerEvent) {
            return false;
        }
        final ViewFrameInfo info = attachInfo.mViewRootImpl.mViewFrameInfo;
        final long durationFromVsyncTimeMs = (System.nanoTime()
                - Choreographer.getInstance().getLastFrameTimeNanos()) / TimeUtils.NANOS_PER_MS;
        return durationFromVsyncTimeMs > 3L || info.getAndIncreaseViewMeasuredCount() > 10;
    }
    /**
     * @hide
     */
@@ -28116,6 +28135,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                if (isTraversalTracingEnabled()) {
                    Trace.beginSection(mTracingStrings.onMeasure);
                }
                if (android.os.Flags.adpfMeasureDuringInputEventBoost()) {
                    final boolean notifyRenderer = hasExpensiveMeasuresDuringInputEvent();
                    if (notifyRenderer) {
                        Trace.traceBegin(Trace.TRACE_TAG_VIEW,
                                "CPU_LOAD_UP: " + "hasExpensiveMeasuresDuringInputEvent");
                        getViewRootImpl().notifyRendererOfExpensiveFrame();
                        Trace.traceEnd(Trace.TRACE_TAG_VIEW);
                    }
                }
                // measure ourselves, this should set the measured dimension flag back
                onMeasure(widthMeasureSpec, heightMeasureSpec);
                if (isTraversalTracingEnabled()) {
+10 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ public class ViewFrameInfo {

    private int mInputEventId;

    private int mViewsMeasuredCounts;

    /**
     * Populate the missing fields using the data from ViewFrameInfo
     * @param frameInfo : the structure FrameInfo object to populate
@@ -51,6 +53,7 @@ public class ViewFrameInfo {
        drawStart = 0;
        mInputEventId = IInputConstants.INVALID_INPUT_EVENT_ID;
        flags = 0;
        mViewsMeasuredCounts = 0;
    }

    /**
@@ -60,6 +63,13 @@ public class ViewFrameInfo {
        drawStart = System.nanoTime();
    }

    /**
     * Record the number of view being measured for the current frame.
     */
    public int getAndIncreaseViewMeasuredCount() {
        return ++mViewsMeasuredCounts;
    }

    /**
     * Assign the value for input event id
     * @param eventId the id of the input event