Loading core/java/android/view/ViewRootImpl.java +37 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ import static android.view.accessibility.Flags.reduceWindowContentChangedEventTh import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER; import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER; import static android.view.flags.Flags.toolkitSetFrameRateReadOnly; import static android.view.flags.Flags.toolkitMetricsForFrameRateDecision; import static com.android.input.flags.Flags.enablePointerChoreographer; Loading Loading @@ -370,6 +371,8 @@ public final class ViewRootImpl implements ViewParent, */ private static final int KEEP_CLEAR_AREA_REPORT_RATE_MILLIS = 100; private static final long NANOS_PER_SEC = 1000000000; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>(); Loading Loading @@ -824,6 +827,8 @@ public final class ViewRootImpl implements ViewParent, private boolean mInsetsAnimationRunning; private long mPreviousFrameDrawnTime = -1; /** * The resolved pointer icon type requested by this window. * A null value indicates the resolved pointer icon has not yet been calculated. Loading Loading @@ -1061,11 +1066,14 @@ public final class ViewRootImpl implements ViewParent, private boolean mChildBoundingInsetsChanged = false; private String mTag = TAG; private String mFpsTraceName; private static boolean sToolkitSetFrameRateReadOnlyFlagValue; private static boolean sToolkitMetricsForFrameRateDecisionFlagValue; static { sToolkitSetFrameRateReadOnlyFlagValue = toolkitSetFrameRateReadOnly(); sToolkitMetricsForFrameRateDecisionFlagValue = toolkitMetricsForFrameRateDecision(); } // The latest input event from the gesture that was used to resolve the pointer icon. Loading Loading @@ -1309,6 +1317,7 @@ public final class ViewRootImpl implements ViewParent, attrs = mWindowAttributes; setTag(); mFpsTraceName = "FPS of " + getTitle(); if (DEBUG_KEEP_SCREEN_ON && (mClientWindowLayoutFlags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0 Loading Loading @@ -4732,6 +4741,31 @@ public final class ViewRootImpl implements ViewParent, } } /** * Called from draw() to collect metrics for frame rate decision. */ private void collectFrameRateDecisionMetrics() { if (!Trace.isEnabled()) { if (mPreviousFrameDrawnTime > 0) mPreviousFrameDrawnTime = -1; return; } if (mPreviousFrameDrawnTime < 0) { mPreviousFrameDrawnTime = mChoreographer.getExpectedPresentationTimeNanos(); return; } long expectedDrawnTime = mChoreographer.getExpectedPresentationTimeNanos(); long timeDiff = expectedDrawnTime - mPreviousFrameDrawnTime; if (timeDiff <= 0) { return; } long fps = NANOS_PER_SEC / timeDiff; Trace.setCounter(mFpsTraceName, fps); mPreviousFrameDrawnTime = expectedDrawnTime; } private void reportDrawFinished(@Nullable Transaction t, int seqId) { if (DEBUG_BLAST) { Log.d(mTag, "reportDrawFinished"); Loading Loading @@ -5050,6 +5084,9 @@ public final class ViewRootImpl implements ViewParent, if (DEBUG_FPS) { trackFPS(); } if (sToolkitMetricsForFrameRateDecisionFlagValue) { collectFrameRateDecisionMetrics(); } if (!sFirstDrawComplete) { synchronized (sFirstDrawHandlers) { Loading core/java/android/view/flags/refresh_rate_flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -43,3 +43,11 @@ flag { description: "Enable the `setFrameRate` callback" bug: "299946220" } flag { name: "toolkit_metrics_for_frame_rate_decision" namespace: "toolkit" description: "Feature flag for toolkit metrics collecting for frame rate decision" bug: "301343249" is_fixed_read_only: true } No newline at end of file Loading
core/java/android/view/ViewRootImpl.java +37 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ import static android.view.accessibility.Flags.reduceWindowContentChangedEventTh import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER; import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER; import static android.view.flags.Flags.toolkitSetFrameRateReadOnly; import static android.view.flags.Flags.toolkitMetricsForFrameRateDecision; import static com.android.input.flags.Flags.enablePointerChoreographer; Loading Loading @@ -370,6 +371,8 @@ public final class ViewRootImpl implements ViewParent, */ private static final int KEEP_CLEAR_AREA_REPORT_RATE_MILLIS = 100; private static final long NANOS_PER_SEC = 1000000000; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>(); Loading Loading @@ -824,6 +827,8 @@ public final class ViewRootImpl implements ViewParent, private boolean mInsetsAnimationRunning; private long mPreviousFrameDrawnTime = -1; /** * The resolved pointer icon type requested by this window. * A null value indicates the resolved pointer icon has not yet been calculated. Loading Loading @@ -1061,11 +1066,14 @@ public final class ViewRootImpl implements ViewParent, private boolean mChildBoundingInsetsChanged = false; private String mTag = TAG; private String mFpsTraceName; private static boolean sToolkitSetFrameRateReadOnlyFlagValue; private static boolean sToolkitMetricsForFrameRateDecisionFlagValue; static { sToolkitSetFrameRateReadOnlyFlagValue = toolkitSetFrameRateReadOnly(); sToolkitMetricsForFrameRateDecisionFlagValue = toolkitMetricsForFrameRateDecision(); } // The latest input event from the gesture that was used to resolve the pointer icon. Loading Loading @@ -1309,6 +1317,7 @@ public final class ViewRootImpl implements ViewParent, attrs = mWindowAttributes; setTag(); mFpsTraceName = "FPS of " + getTitle(); if (DEBUG_KEEP_SCREEN_ON && (mClientWindowLayoutFlags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0 Loading Loading @@ -4732,6 +4741,31 @@ public final class ViewRootImpl implements ViewParent, } } /** * Called from draw() to collect metrics for frame rate decision. */ private void collectFrameRateDecisionMetrics() { if (!Trace.isEnabled()) { if (mPreviousFrameDrawnTime > 0) mPreviousFrameDrawnTime = -1; return; } if (mPreviousFrameDrawnTime < 0) { mPreviousFrameDrawnTime = mChoreographer.getExpectedPresentationTimeNanos(); return; } long expectedDrawnTime = mChoreographer.getExpectedPresentationTimeNanos(); long timeDiff = expectedDrawnTime - mPreviousFrameDrawnTime; if (timeDiff <= 0) { return; } long fps = NANOS_PER_SEC / timeDiff; Trace.setCounter(mFpsTraceName, fps); mPreviousFrameDrawnTime = expectedDrawnTime; } private void reportDrawFinished(@Nullable Transaction t, int seqId) { if (DEBUG_BLAST) { Log.d(mTag, "reportDrawFinished"); Loading Loading @@ -5050,6 +5084,9 @@ public final class ViewRootImpl implements ViewParent, if (DEBUG_FPS) { trackFPS(); } if (sToolkitMetricsForFrameRateDecisionFlagValue) { collectFrameRateDecisionMetrics(); } if (!sFirstDrawComplete) { synchronized (sFirstDrawHandlers) { Loading
core/java/android/view/flags/refresh_rate_flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -43,3 +43,11 @@ flag { description: "Enable the `setFrameRate` callback" bug: "299946220" } flag { name: "toolkit_metrics_for_frame_rate_decision" namespace: "toolkit" description: "Feature flag for toolkit metrics collecting for frame rate decision" bug: "301343249" is_fixed_read_only: true } No newline at end of file