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

Commit 8df049f9 authored by Jian-Syuan (Shane) Wong's avatar Jian-Syuan (Shane) Wong
Browse files

Add a getter method for expectedPresentationTimeNanos

Add a getter method for expectedPresentationTimeNanos since it offers a
more accurate frame time than frameTimeNanos

Bug: 283122385
Test: atest ChoreographerTest
Change-Id: If7494bada7696efae28fb5a45003abfca234c0ca
parent ec5e4ee6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3415,7 +3415,9 @@ package android.view {
  }

  public final class Choreographer {
    method public long getExpectedPresentationTimeNanos();
    method public static long getFrameDelay();
    method public long getFrameTimeNanos();
    method public void postCallback(int, Runnable, Object);
    method public void postCallbackDelayed(int, Runnable, Object, long);
    method public void removeCallbacks(int, Runnable, Object);
+22 −0
Original line number Diff line number Diff line
@@ -693,6 +693,7 @@ public final class Choreographer {
     * @throws IllegalStateException if no frame is in progress.
     * @hide
     */
    @TestApi
    @UnsupportedAppUsage
    public long getFrameTimeNanos() {
        synchronized (mLock) {
@@ -716,6 +717,27 @@ public final class Choreographer {
        }
    }

    /**
     * Gets the time in {@link System#nanoTime()} timebase which the current frame
     * is expected to be presented.
     * <p>
     * This time should be used to advance any animation clocks.
     * Prefer using this method over {@link #getFrameTimeNanos()}.
     * </p><p>
     * This method should only be called from within a callback.
     * </p>
     *
     * @return The frame start time, in the {@link System#nanoTime()} time base.
     *
     * @throws IllegalStateException if no frame is in progress.
     * @hide
     */
    @TestApi
    @UnsupportedAppUsage
    public long getExpectedPresentationTimeNanos() {
        return mFrameData.getPreferredFrameTimeline().getExpectedPresentationTimeNanos();
    }

    private void scheduleFrameLocked(long now) {
        if (!mFrameScheduled) {
            mFrameScheduled = true;