Loading core/java/android/os/flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -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" Loading core/java/android/view/View.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 */ Loading Loading @@ -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()) { core/java/android/view/ViewFrameInfo.java +10 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -51,6 +53,7 @@ public class ViewFrameInfo { drawStart = 0; mInputEventId = IInputConstants.INVALID_INPUT_EVENT_ID; flags = 0; mViewsMeasuredCounts = 0; } /** Loading @@ -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 Loading Loading
core/java/android/os/flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -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" Loading
core/java/android/view/View.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 */ Loading Loading @@ -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()) {
core/java/android/view/ViewFrameInfo.java +10 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -51,6 +53,7 @@ public class ViewFrameInfo { drawStart = 0; mInputEventId = IInputConstants.INVALID_INPUT_EVENT_ID; flags = 0; mViewsMeasuredCounts = 0; } /** Loading @@ -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 Loading