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

Commit 3508a7fb authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Enable Choreographer on Ravenwood

Bug: 421246454
Flag: TEST_ONLY
Test: atest CtsSurfaceControlTestsRavenwood
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh -s
Change-Id: I51c8bf9026fdc60c82a1d0f4c7dd5c0483df3fe4
parent 8bf6f7d8
Loading
Loading
Loading
Loading
+33 −4
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import android.os.Message;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;
import android.ravenwood.annotation.RavenwoodReplace;
import android.util.Log;
import android.util.TimeUtils;
import android.view.animation.AnimationUtils;
@@ -87,6 +89,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 * to which the choreographer belongs.
 * </p>
 */
@RavenwoodKeepWholeClass
public final class Choreographer {
    private static final String TAG = "Choreographer";

@@ -104,7 +107,17 @@ public final class Choreographer {
    // for jitter and hardware variations).  Regardless of this value, the animation
    // and display loop is ultimately rate-limited by how fast new graphics buffers can
    // be dequeued.
    private static final long DEFAULT_FRAME_DELAY = 10;
    private static final long DEFAULT_FRAME_DELAY = getDefaultFrameDelay();

    @RavenwoodReplace(reason = "run as fast as possible on ravenwood")
    private static long getDefaultFrameDelay() {
        return 10;
    }

    @SuppressWarnings("unused")
    private static long getDefaultFrameDelay$ravenwood() {
        return 1;
    }

    // The number of milliseconds between animation frames.
    private static volatile long sFrameDelay = DEFAULT_FRAME_DELAY;
@@ -143,8 +156,17 @@ public final class Choreographer {

    // Enable/disable vsync for animations and drawing.
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769497)
    private static final boolean USE_VSYNC = SystemProperties.getBoolean(
            "debug.choreographer.vsync", true);
    private static final boolean USE_VSYNC = getUseVsync();

    @RavenwoodReplace(reason = "don't simulate vsync on ravenwood")
    private static boolean getUseVsync() {
        return SystemProperties.getBoolean("debug.choreographer.vsync", true);
    }

    @SuppressWarnings("unused")
    private static boolean getUseVsync$ravenwood() {
        return false;
    }

    // Enable/disable using the frame time instead of returning now.
    private static final boolean USE_FRAME_TIME = SystemProperties.getBoolean(
@@ -353,12 +375,19 @@ public final class Choreographer {
        setFPSDivisor(SystemProperties.getInt(ThreadedRenderer.DEBUG_FPS_DIVISOR, 1));
    }

    @RavenwoodReplace(blockedBy = DisplayManagerGlobal.class,
            reason = "just use fixed refresh rate")
    private static float getRefreshRate() {
        DisplayInfo di = DisplayManagerGlobal.getInstance().getDisplayInfo(
                Display.DEFAULT_DISPLAY);
        return di.getRefreshRate();
    }

    @SuppressWarnings("unused")
    private static float getRefreshRate$ravenwood() {
        return 120f;
    }

    /**
     * Gets the choreographer for the calling thread.  Must be called from
     * a thread that already has a {@link android.os.Looper} associated with it.
@@ -1431,7 +1460,7 @@ public final class Choreographer {
            }

            long newPreferredDeadline = mFrameTimelines[newPreferredIndex].mDeadlineNanos;
            if (newPreferredDeadline < minimumDeadline) {
            if (USE_VSYNC && newPreferredDeadline < minimumDeadline) {
                DisplayEventReceiver.VsyncEventData latestVsyncEventData =
                        displayEventReceiver.getLatestVsyncEventData();
                if (latestVsyncEventData == null) {
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.graphics.FrameInfo;
import android.os.Build;
import android.os.Looper;
import android.os.MessageQueue;
import android.ravenwood.annotation.RavenwoodKeepPartialClass;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
@@ -42,6 +44,7 @@ import java.lang.ref.WeakReference;
 * @hide
 */
@WeaklyReferencedCallback
@RavenwoodKeepPartialClass
public abstract class DisplayEventReceiver {

    /**
@@ -153,6 +156,7 @@ public abstract class DisplayEventReceiver {
     *
     * @hide
     */
    @RavenwoodKeepWholeClass
    public static final class VsyncEventData {
        // The max capacity of frame timeline choices.
        // Must be in sync with VsyncEventData::kFrameTimelinesCapacity in
+8 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import android.content.res.Resources.NotFoundException;
import android.content.res.Resources.Theme;
import android.content.res.XmlResourceParser;
import android.os.SystemClock;
import android.ravenwood.annotation.RavenwoodIgnore;
import android.ravenwood.annotation.RavenwoodKeepPartialClass;
import android.util.AttributeSet;
import android.util.TimeUtils;
import android.util.Xml;
@@ -44,6 +46,9 @@ import java.io.IOException;
 * Defines common utilities for working with animations.
 *
 */
// This class would probably just work as-is on Ravenwood, but until we port the test, we just keep
// the minimal surface for Choreographer.
@RavenwoodKeepPartialClass(comment = "Keeping just enough for Choreographer to work")
public class AnimationUtils {

    /**
@@ -99,6 +104,7 @@ public class AnimationUtils {
     */
    @TestApi
    @FlaggedApi(FLAG_EXPECTED_PRESENTATION_TIME_READ_ONLY)
    @RavenwoodIgnore
    public static void lockAnimationClock(long vsyncMillis, long expectedPresentationTimeNanos) {
        AnimationState state = sAnimationState.get();
        state.animationClockLocked = true;
@@ -136,6 +142,7 @@ public class AnimationUtils {
     * @hide
     */
    @TestApi
    @RavenwoodIgnore
    public static void lockAnimationClock(long vsyncMillis) {
        AnimationState state = sAnimationState.get();
        state.animationClockLocked = true;
@@ -149,6 +156,7 @@ public class AnimationUtils {
     * @hide
     */
    @TestApi
    @RavenwoodIgnore
    public static void unlockAnimationClock() {
        sAnimationState.get().animationClockLocked = false;
    }
+5 −1
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.Trace;
import android.ravenwood.annotation.RavenwoodIgnore;
import android.ravenwood.annotation.RavenwoodKeepPartialClass;
import android.util.Log;
import android.util.TimeUtils;
import android.view.Display;
@@ -82,7 +84,8 @@ import sun.misc.Cleaner;
 * Failure to do so will cause the render thread to stall on that surface, blocking all
 * HardwareRenderer instances.</p>
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
@RavenwoodKeepPartialClass(comment =
        "Hardware graphics not supported. Keeping minimal surface enough for Choreographer")
public class HardwareRenderer {
    private static final String LOG_TAG = "HardwareRenderer";

@@ -1145,6 +1148,7 @@ public class HardwareRenderer {
     *
     * @hide
     */
    @RavenwoodIgnore
    public static void setFPSDivisor(int divisor) {
        nSetRtAnimationsEnabled(divisor <= 1);
    }
+3 −0
Original line number Diff line number Diff line
@@ -562,9 +562,12 @@ android.util.proto.ProtoStream
android.util.proto.ProtoUtils
android.util.proto.WireTypeMismatchException

android.view.animation.AnimationUtils
android.view.Choreographer
android.view.ContextThemeWrapper
android.view.Display
android.view.DisplayAdjustments
android.view.DisplayEventReceiver
android.view.DisplayInfo
android.view.Gravity
android.view.InflateException