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

Commit c4c0ca1e authored by Jian-Syuan (Shane) Wong's avatar Jian-Syuan (Shane) Wong Committed by Android (Google) Code Review
Browse files

Merge "Handle when AnimationUtils getExpectedPresentationTimeNanos is not...

Merge "Handle when AnimationUtils getExpectedPresentationTimeNanos is not called in a callback" into main
parents 78add906 444cb5e4
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.TimeUtils;
import android.util.Xml;
import android.view.Choreographer;
import android.view.InflateException;

import org.xmlpull.v1.XmlPullParser;
@@ -153,8 +154,14 @@ public class AnimationUtils {
     */
    public static long getExpectedPresentationTimeNanos() {
        AnimationState state = sAnimationState.get();
        if (state.animationClockLocked) {
            return state.mExpectedPresentationTimeNanos;
        }
        // When this methoed is called outside of a Choreographer callback,
        // we obtain the value of expectedPresentTimeNanos from the Choreographer.
        // This helps avoid returning a time that could potentially be earlier than current time.
        return Choreographer.getInstance().getLatestExpectedPresentTimeNanos();
    }

    /**
     * The expected presentation time of a frame in the {@link SystemClock#uptimeMillis()}.