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

Commit 3f145a2f authored by Michael Wright's avatar Michael Wright
Browse files

Add supported refresh rate to displays

Change-Id: I51231dd6dd231d57dd1ac499349d6335121f07d5
parent 06c41a3e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -33013,6 +33013,7 @@ package android.view {
    method public int getRotation();
    method public void getSize(android.graphics.Point);
    method public int getState();
    method public float[] getSupportedRefreshRates();
    method public deprecated int getWidth();
    method public boolean isValid();
    field public static final int DEFAULT_DISPLAY = 0; // 0x0
@@ -35656,6 +35657,7 @@ package android.view {
    field public float horizontalWeight;
    field public deprecated int memoryType;
    field public java.lang.String packageName;
    field public float preferredRefreshRate;
    field public int rotationAnimation;
    field public float screenBrightness;
    field public int screenOrientation;
+14 −5
Original line number Diff line number Diff line
@@ -106,21 +106,30 @@ public abstract class DisplayManagerInternal {
    public abstract void performTraversalInTransactionFromWindowManager();

    /**
     * Tells the display manager whether there is interesting unique content on the
     * specified logical display.  This is used to control automatic mirroring.
     * Tells the display manager about properties of the display that depend on the windows on it.
     * This includes whether there is interesting unique content on the specified logical display,
     * and whether the one of the windows has a preferred refresh rate.
     * <p>
     * If the display has unique content, then the display manager arranges for it
     * to be presented on a physical display if appropriate.  Otherwise, the display manager
     * may choose to make the physical display mirror some other logical display.
     * </p>
     *
     * <p>
     * If one of the windows on the display has a preferred refresh rate that's supported by the
     * display, then the display manager will request its use.
     * </p>
     *
     * @param displayId The logical display id to update.
     * @param hasContent True if the logical display has content.
     * @param hasContent True if the logical display has content. This is used to control automatic
     * mirroring.
     * @param requestedRefreshRate The preferred refresh rate for the top-most visible window that
     * has a preference.
     * @param inTraversal True if called from WindowManagerService during a window traversal
     * prior to call to performTraversalInTransactionFromWindowManager.
     */
    public abstract void setDisplayHasContent(int displayId, boolean hasContent,
            boolean inTraversal);
    public abstract void setDisplayProperties(int displayId, boolean hasContent,
            float requestedRefreshRate, boolean inTraversal);

    /**
     * Describes the requested power state of the display.
+13 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.os.SystemClock;
import android.util.DisplayMetrics;
import android.util.Log;

import java.util.Arrays;

/**
 * Provides information about the size and density of a logical display.
 * <p>
@@ -612,6 +614,17 @@ public final class Display {
        }
    }

    /**
     * Get the supported refresh rates of this display in frames per second.
     */
    public float[] getSupportedRefreshRates() {
        synchronized (this) {
            updateDisplayInfoLocked();
            final float[] refreshRates = mDisplayInfo.supportedRefreshRates;
            return Arrays.copyOf(refreshRates, refreshRates.length);
        }
    }

    /**
     * Gets the app VSYNC offset, in nanoseconds.  This is a positive value indicating
     * the phase offset of the VSYNC events provided by Choreographer relative to the
+15 −1
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.util.DisplayMetrics;

import java.util.Arrays;

import libcore.util.EmptyArray;
import libcore.util.Objects;

/**
@@ -155,6 +158,11 @@ public final class DisplayInfo implements Parcelable {
     */
    public float refreshRate;

    /**
     * The supported refresh rates of this display at the current resolution in frames per second.
     */
    public float[] supportedRefreshRates = EmptyArray.FLOAT;

    /**
     * The logical display density which is the basis for density-independent
     * pixels.
@@ -299,6 +307,8 @@ public final class DisplayInfo implements Parcelable {
        overscanBottom = other.overscanBottom;
        rotation = other.rotation;
        refreshRate = other.refreshRate;
        supportedRefreshRates = Arrays.copyOf(
                other.supportedRefreshRates, other.supportedRefreshRates.length);
        logicalDensityDpi = other.logicalDensityDpi;
        physicalXDpi = other.physicalXDpi;
        physicalYDpi = other.physicalYDpi;
@@ -329,6 +339,7 @@ public final class DisplayInfo implements Parcelable {
        overscanBottom = source.readInt();
        rotation = source.readInt();
        refreshRate = source.readFloat();
        supportedRefreshRates = source.createFloatArray();
        logicalDensityDpi = source.readInt();
        physicalXDpi = source.readFloat();
        physicalYDpi = source.readFloat();
@@ -360,6 +371,7 @@ public final class DisplayInfo implements Parcelable {
        dest.writeInt(overscanBottom);
        dest.writeInt(rotation);
        dest.writeFloat(refreshRate);
        dest.writeFloatArray(supportedRefreshRates);
        dest.writeInt(logicalDensityDpi);
        dest.writeFloat(physicalXDpi);
        dest.writeFloat(physicalYDpi);
@@ -462,7 +474,9 @@ public final class DisplayInfo implements Parcelable {
        sb.append(smallestNominalAppHeight);
        sb.append(", ");
        sb.append(refreshRate);
        sb.append(" fps, rotation ");
        sb.append(" fps, supportedRefreshRates ");
        sb.append(Arrays.toString(supportedRefreshRates));
        sb.append(", rotation ");
        sb.append(rotation);
        sb.append(", density ");
        sb.append(logicalDensityDpi);
+23 −0
Original line number Diff line number Diff line
@@ -1417,6 +1417,16 @@ public interface WindowManager extends ViewManager {
         */
        public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

        /**
         * The preferred refresh rate for the window.
         *
         * This must be one of the supported refresh rates obtained for the display(s) the window
         * is on.
         *
         * @see Display#getSupportedRefreshRates()
         */
        public float preferredRefreshRate;

        /**
         * Control the visibility of the status bar.
         *
@@ -1576,6 +1586,7 @@ public interface WindowManager extends ViewManager {
            out.writeString(packageName);
            TextUtils.writeToParcel(mTitle, out, parcelableFlags);
            out.writeInt(screenOrientation);
            out.writeFloat(preferredRefreshRate);
            out.writeInt(systemUiVisibility);
            out.writeInt(subtreeSystemUiVisibility);
            out.writeInt(hasSystemUiListeners ? 1 : 0);
@@ -1622,6 +1633,7 @@ public interface WindowManager extends ViewManager {
            packageName = in.readString();
            mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
            screenOrientation = in.readInt();
            preferredRefreshRate = in.readFloat();
            systemUiVisibility = in.readInt();
            subtreeSystemUiVisibility = in.readInt();
            hasSystemUiListeners = in.readInt() != 0;
@@ -1664,6 +1676,8 @@ public interface WindowManager extends ViewManager {
        /** {@hide} */
        public static final int SURFACE_INSETS_CHANGED = 1<<20;
        /** {@hide} */
        public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21;
        /** {@hide} */
        public static final int EVERYTHING_CHANGED = 0xffffffff;

        // internal buffer to backup/restore parameters under compatibility mode.
@@ -1776,6 +1790,11 @@ public interface WindowManager extends ViewManager {
                changes |= SCREEN_ORIENTATION_CHANGED;
            }

            if (preferredRefreshRate != o.preferredRefreshRate) {
                preferredRefreshRate = o.preferredRefreshRate;
                changes |= PREFERRED_REFRESH_RATE_CHANGED;
            }

            if (systemUiVisibility != o.systemUiVisibility
                    || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
                systemUiVisibility = o.systemUiVisibility;
@@ -1884,6 +1903,10 @@ public interface WindowManager extends ViewManager {
                sb.append(" rotAnim=");
                sb.append(rotationAnimation);
            }
            if (preferredRefreshRate != 0) {
                sb.append(" preferredRefreshRate=");
                sb.append(preferredRefreshRate);
            }
            if (systemUiVisibility != 0) {
                sb.append(" sysui=0x");
                sb.append(Integer.toHexString(systemUiVisibility));
Loading