From 518898d9e66770fd64d54b94628b9ad8fbde8a92 Mon Sep 17 00:00:00 2001 From: Kriti Dang Date: Thu, 11 Mar 2021 11:33:13 +0100 Subject: Exposing public API to retrieve current setting of 'Match Content Frame Rate'. Bug: 182148347 Test: atest MatchContentFrameRateTest Change-Id: Iaa4364fc868a712fd71a48e6efad0df05eb4a6a4 --- .../android/hardware/display/DisplayManager.java | 68 +++++++++++++++++++--- 1 file changed, 61 insertions(+), 7 deletions(-) (limited to 'core/java/android') diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java index 216e7b079f6b..6c2d1402b303 100644 --- a/core/java/android/hardware/display/DisplayManager.java +++ b/core/java/android/hardware/display/DisplayManager.java @@ -38,6 +38,7 @@ import android.media.projection.MediaProjection; import android.os.Build; import android.os.Handler; import android.util.Pair; +import android.util.Slog; import android.util.SparseArray; import android.view.Display; import android.view.Surface; @@ -347,6 +348,37 @@ public final class DisplayManager { public static final int VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP = 1 << 11; + /** @hide */ + @IntDef(prefix = {"MATCH_CONTENT_FRAMERATE_"}, value = { + MATCH_CONTENT_FRAMERATE_UNKNOWN, + MATCH_CONTENT_FRAMERATE_NEVER, + MATCH_CONTENT_FRAMERATE_SEAMLESSS_ONLY, + MATCH_CONTENT_FRAMERATE_ALWAYS, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface MatchContentFrameRateType {} + + /** + * Match content frame rate user preference is unknown. + */ + public static final int MATCH_CONTENT_FRAMERATE_UNKNOWN = -1; + + /** + * No mode switching is allowed. + */ + public static final int MATCH_CONTENT_FRAMERATE_NEVER = 0; + + /** + * Only refresh rate switches without visual interruptions are allowed. + */ + public static final int MATCH_CONTENT_FRAMERATE_SEAMLESSS_ONLY = 1; + + /** + * Refresh rate switches between all refresh rates are allowed even if they have visual + * interruptions for the user. + */ + public static final int MATCH_CONTENT_FRAMERATE_ALWAYS = 2; + /** @hide */ @IntDef(prefix = {"SWITCHING_TYPE_"}, value = { SWITCHING_TYPE_NONE, @@ -1076,14 +1108,36 @@ public final class DisplayManager { } /** - * Returns the refresh rate switching type. - * - * @hide + * Returns the user preference for "Match content frame rate". + *

+ * Never: Even if the app requests it, the device will never try to match its output to the + * original frame rate of the content. + *

+ * Seamless: If the app requests it, the device will match its output to the original frame + * rate of the content, ONLY if the display can transition seamlessly. + *

+ * Always: If the app requests it, the device will match its output to the original + * frame rate of the content. This may cause the screen to go blank for a + * second when exiting or entering a video playback. + *

*/ - @TestApi - @RequiresPermission(Manifest.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE) - @SwitchingType public int getRefreshRateSwitchingType() { - return mGlobal.getRefreshRateSwitchingType(); + @MatchContentFrameRateType public int getMatchContentFrameRateUserPreference() { + return toMatchContentFrameRateSetting(mGlobal.getRefreshRateSwitchingType()); + } + + @MatchContentFrameRateType + private int toMatchContentFrameRateSetting(@SwitchingType int switchingType) { + switch (switchingType) { + case SWITCHING_TYPE_NONE: + return MATCH_CONTENT_FRAMERATE_NEVER; + case SWITCHING_TYPE_WITHIN_GROUPS: + return MATCH_CONTENT_FRAMERATE_SEAMLESSS_ONLY; + case SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS: + return MATCH_CONTENT_FRAMERATE_ALWAYS; + default: + Slog.e(TAG, switchingType + " is not a valid value of switching type."); + return MATCH_CONTENT_FRAMERATE_UNKNOWN; + } } /** -- cgit v1.2.3