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
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 35c8a58..7a1d4c2 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -3415,7 +3415,9 @@
   }
 
   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);
diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java
index b15169f..ef1c377 100644
--- a/core/java/android/view/Choreographer.java
+++ b/core/java/android/view/Choreographer.java
@@ -693,6 +693,7 @@
      * @throws IllegalStateException if no frame is in progress.
      * @hide
      */
+    @TestApi
     @UnsupportedAppUsage
     public long getFrameTimeNanos() {
         synchronized (mLock) {
@@ -716,6 +717,27 @@
         }
     }
 
+    /**
+     * 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;