summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorKriti Dang <kritidang@google.com>2021-03-30 11:39:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-03-30 11:39:06 +0000
commit2f0f6a3a46dab3122e80ee282c32f3b2f86dcc25 (patch)
tree66254a22fca6883ad4c849b7205439b86b96bf9e /core/java/android
parent352fa3bd455081cbd64d1b21114e0d264ee26744 (diff)
parent518898d9e66770fd64d54b94628b9ad8fbde8a92 (diff)
Merge "Exposing public API to retrieve current setting of 'Match Content Frame Rate'." into sc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/hardware/display/DisplayManager.java68
1 files changed, 61 insertions, 7 deletions
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;
@@ -348,6 +349,37 @@ public final class DisplayManager {
/** @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,
SWITCHING_TYPE_WITHIN_GROUPS,
@@ -1076,14 +1108,36 @@ public final class DisplayManager {
}
/**
- * Returns the refresh rate switching type.
- *
- * @hide
+ * Returns the user preference for "Match content frame rate".
+ * <p>
+ * Never: Even if the app requests it, the device will never try to match its output to the
+ * original frame rate of the content.
+ * </p><p>
+ * 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.
+ * </p><p>
+ * 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.
+ * </p>
*/
- @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;
+ }
}
/**