From 2bd0afe0f0cee475ecc79a49528c6802a84df4ee Mon Sep 17 00:00:00 2001 From: Rachel Lee Date: Tue, 26 Dec 2023 17:34:44 -0800 Subject: Add new HIGH_INTERACTIVE frame rate category Bug: 315071842 Test: atest CtsSurfaceControlTestsStaging Change-Id: Ia9bb1c03d3758f2e1bf023f20612eae96198ccef --- core/java/android/view/Surface.java | 15 +++++++++++++-- .../view/surfacecontroltests/GraphicsActivity.java | 1 + .../view/surfacecontroltests/SurfaceControlTest.java | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index ad0bf7c95c70..785055441d59 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -274,7 +274,8 @@ public class Surface implements Parcelable { @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = {"FRAME_RATE_CATEGORY_"}, value = {FRAME_RATE_CATEGORY_DEFAULT, FRAME_RATE_CATEGORY_NO_PREFERENCE, - FRAME_RATE_CATEGORY_LOW, FRAME_RATE_CATEGORY_NORMAL, FRAME_RATE_CATEGORY_HIGH}) + FRAME_RATE_CATEGORY_LOW, FRAME_RATE_CATEGORY_NORMAL, + FRAME_RATE_CATEGORY_HIGH_HINT, FRAME_RATE_CATEGORY_HIGH}) public @interface FrameRateCategory {} // From native_window.h or window.h. Keep these in sync. @@ -307,12 +308,22 @@ public class Surface implements Parcelable { */ public static final int FRAME_RATE_CATEGORY_NORMAL = 3; + /** + * Hints that, as a result of a user interaction, an animation is likely to start. + * This category is a signal that a user interaction heuristic determined the need of a + * high refresh rate, and is not an explicit request from the app. + * As opposed to {@link #FRAME_RATE_CATEGORY_HIGH}, this vote may be ignored in favor of + * more explicit votes. + * @hide + */ + public static final int FRAME_RATE_CATEGORY_HIGH_HINT = 4; + /** * Indicates a frame rate suitable for animations that require a high frame rate, which may * increase smoothness but may also increase power usage. * @hide */ - public static final int FRAME_RATE_CATEGORY_HIGH = 4; + public static final int FRAME_RATE_CATEGORY_HIGH = 5; /** * Create an empty surface, which will later be filled in by readFromParcel(). diff --git a/tests/CtsSurfaceControlTestsStaging/src/main/java/android/view/surfacecontroltests/GraphicsActivity.java b/tests/CtsSurfaceControlTestsStaging/src/main/java/android/view/surfacecontroltests/GraphicsActivity.java index 60b5ce75e2f7..80c1e5be3a32 100644 --- a/tests/CtsSurfaceControlTestsStaging/src/main/java/android/view/surfacecontroltests/GraphicsActivity.java +++ b/tests/CtsSurfaceControlTestsStaging/src/main/java/android/view/surfacecontroltests/GraphicsActivity.java @@ -810,6 +810,7 @@ public class GraphicsActivity extends Activity { private FpsRange convertCategory(int category) { switch (category) { + case Surface.FRAME_RATE_CATEGORY_HIGH_HINT: case Surface.FRAME_RATE_CATEGORY_HIGH: return FRAME_RATE_CATEGORY_HIGH; case Surface.FRAME_RATE_CATEGORY_NORMAL: diff --git a/tests/CtsSurfaceControlTestsStaging/src/main/java/android/view/surfacecontroltests/SurfaceControlTest.java b/tests/CtsSurfaceControlTestsStaging/src/main/java/android/view/surfacecontroltests/SurfaceControlTest.java index 4b56c107cf22..caaee634c57a 100644 --- a/tests/CtsSurfaceControlTestsStaging/src/main/java/android/view/surfacecontroltests/SurfaceControlTest.java +++ b/tests/CtsSurfaceControlTestsStaging/src/main/java/android/view/surfacecontroltests/SurfaceControlTest.java @@ -92,6 +92,12 @@ public class SurfaceControlTest { activity.testSurfaceControlFrameRateCategory(Surface.FRAME_RATE_CATEGORY_HIGH); } + @Test + public void testSurfaceControlFrameRateCategoryHighHint() throws InterruptedException { + GraphicsActivity activity = mActivityRule.getActivity(); + activity.testSurfaceControlFrameRateCategory(Surface.FRAME_RATE_CATEGORY_HIGH_HINT); + } + @Test public void testSurfaceControlFrameRateCategoryNormal() throws InterruptedException { GraphicsActivity activity = mActivityRule.getActivity(); -- cgit v1.2.3-59-g8ed1b