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

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

Merge "Cache flag value for AnmationUtils" into main

parents 07a7e3ed 0ee66882
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -54519,8 +54519,8 @@ package android.view.animation {
  public class AnimationUtils {
    ctor public AnimationUtils();
    method public static long currentAnimationTimeMillis();
    method @FlaggedApi("android.view.flags.expected_presentation_time_api") public static long getExpectedPresentationTimeMillis();
    method @FlaggedApi("android.view.flags.expected_presentation_time_api") public static long getExpectedPresentationTimeNanos();
    method @FlaggedApi("android.view.flags.expected_presentation_time_read_only") public static long getExpectedPresentationTimeMillis();
    method @FlaggedApi("android.view.flags.expected_presentation_time_read_only") public static long getExpectedPresentationTimeNanos();
    method public static android.view.animation.Animation loadAnimation(android.content.Context, @AnimRes int) throws android.content.res.Resources.NotFoundException;
    method public static android.view.animation.Interpolator loadInterpolator(android.content.Context, @AnimRes @InterpolatorRes int) throws android.content.res.Resources.NotFoundException;
    method public static android.view.animation.LayoutAnimationController loadLayoutAnimation(android.content.Context, @AnimRes int) throws android.content.res.Resources.NotFoundException;
+1 −1
Original line number Diff line number Diff line
@@ -3622,7 +3622,7 @@ package android.view.accessibility {
package android.view.animation {

  public class AnimationUtils {
    method @FlaggedApi("android.view.flags.expected_presentation_time_api") public static void lockAnimationClock(long, long);
    method @FlaggedApi("android.view.flags.expected_presentation_time_read_only") public static void lockAnimationClock(long, long);
    method public static void unlockAnimationClock();
  }

+12 −7
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.view.animation;

import static android.view.flags.Flags.FLAG_EXPECTED_PRESENTATION_TIME_API;
import static android.view.flags.Flags.expectedPresentationTimeApi;
import static android.view.flags.Flags.FLAG_EXPECTED_PRESENTATION_TIME_READ_ONLY;
import static android.view.flags.Flags.expectedPresentationTimeReadOnly;

import android.annotation.AnimRes;
import android.annotation.FlaggedApi;
@@ -67,6 +67,11 @@ public class AnimationUtils {
    @Overridable
    public static final long OVERRIDE_ENABLE_EXPECTED_PRSENTATION_TIME = 278730197L;

    private static boolean sExpectedPresentationTimeFlagValue;
    static {
        sExpectedPresentationTimeFlagValue = expectedPresentationTimeReadOnly();
    }

    private static class AnimationState {
        boolean animationClockLocked;
        long currentVsyncTimeMillis;
@@ -108,12 +113,12 @@ public class AnimationUtils {
     * @hide
     */
    @TestApi
    @FlaggedApi(FLAG_EXPECTED_PRESENTATION_TIME_API)
    @FlaggedApi(FLAG_EXPECTED_PRESENTATION_TIME_READ_ONLY)
    public static void lockAnimationClock(long vsyncMillis, long expectedPresentationTimeNanos) {
        AnimationState state = sAnimationState.get();
        state.animationClockLocked = true;
        state.currentVsyncTimeMillis = vsyncMillis;
        if (!expectedPresentationTimeApi()) {
        if (!sExpectedPresentationTimeFlagValue) {
            state.mExpectedPresentationTimeNanos = expectedPresentationTimeNanos;
        }
    }
@@ -158,9 +163,9 @@ public class AnimationUtils {
     * @return the expected presentation time of a frame in the
     *         {@link System#nanoTime()} time base.
     */
    @FlaggedApi(FLAG_EXPECTED_PRESENTATION_TIME_API)
    @FlaggedApi(FLAG_EXPECTED_PRESENTATION_TIME_READ_ONLY)
    public static long getExpectedPresentationTimeNanos() {
        if (!expectedPresentationTimeApi()) {
        if (!sExpectedPresentationTimeFlagValue) {
            return SystemClock.uptimeMillis();
        }

@@ -176,7 +181,7 @@ public class AnimationUtils {
     * @return the expected presentation time of a frame in the
     *         {@link SystemClock#uptimeMillis()} time base.
     */
    @FlaggedApi(FLAG_EXPECTED_PRESENTATION_TIME_API)
    @FlaggedApi(FLAG_EXPECTED_PRESENTATION_TIME_READ_ONLY)
    public static long getExpectedPresentationTimeMillis() {
        return getExpectedPresentationTimeNanos() / TimeUtils.NANOS_PER_MS;
    }
+8 −0
Original line number Diff line number Diff line
@@ -21,6 +21,14 @@ flag {
    bug: "278730197"
}

flag {
    name: "expected_presentation_time_read_only"
    namespace: "toolkit"
    description: "Feature flag for using expected presentation time of the Choreographer"
    bug: "278730197"
    is_fixed_read_only: true
}

flag {
  name: "set_frame_rate_callback"
  namespace: "core_graphics"