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

Commit e9ba7c11 authored by Oleg Petšjonkin's avatar Oleg Petšjonkin Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Introducing Display Sythetic modes - used for app request...

Merge "Revert^2 "Introducing Display Sythetic modes - used for app request refresh rate/resolution selection"" into main
parents 9968e958 0db9261d
Loading
Loading
Loading
Loading
+37 −9
Original line number Diff line number Diff line
@@ -1225,9 +1225,22 @@ public final class Display {
    }

    /**
     * Gets the supported modes of this display.
     * Gets the supported modes of this display, might include synthetic modes
     */
    public Mode[] getSupportedModes() {
        synchronized (mLock) {
            updateDisplayInfoLocked();
            final Display.Mode[] modes = mDisplayInfo.appsSupportedModes;
            return Arrays.copyOf(modes, modes.length);
        }
    }

    /**
     * Gets system supported modes of this display,
     * @hide
     */
    @SuppressLint("ArrayReturn")
    public @NonNull Mode[] getSystemSupportedModes() {
        synchronized (mLock) {
            updateDisplayInfoLocked();
            final Display.Mode[] modes = mDisplayInfo.supportedModes;
@@ -2213,6 +2226,7 @@ public final class Display {
        @NonNull
        @HdrCapabilities.HdrType
        private final int[] mSupportedHdrTypes;
        private final boolean mIsSynthetic;

        /**
         * @hide
@@ -2223,13 +2237,6 @@ public final class Display {
                    new int[0]);
        }

        /**
         * @hide
         */
        public Mode(int width, int height, float refreshRate, float vsyncRate) {
            this(INVALID_MODE_ID, width, height, refreshRate, vsyncRate, new float[0], new int[0]);
        }

        /**
         * @hide
         */
@@ -2253,11 +2260,21 @@ public final class Display {
         */
        public Mode(int modeId, int width, int height, float refreshRate, float vsyncRate,
                float[] alternativeRefreshRates, @HdrCapabilities.HdrType int[] supportedHdrTypes) {
            this(modeId, width, height, refreshRate, vsyncRate, false, alternativeRefreshRates,
                    supportedHdrTypes);
        }
        /**
         * @hide
         */
        public Mode(int modeId, int width, int height, float refreshRate, float vsyncRate,
                boolean isSynthetic, float[] alternativeRefreshRates,
                @HdrCapabilities.HdrType int[] supportedHdrTypes) {
            mModeId = modeId;
            mWidth = width;
            mHeight = height;
            mPeakRefreshRate = refreshRate;
            mVsyncRate = vsyncRate;
            mIsSynthetic = isSynthetic;
            mAlternativeRefreshRates =
                    Arrays.copyOf(alternativeRefreshRates, alternativeRefreshRates.length);
            Arrays.sort(mAlternativeRefreshRates);
@@ -2321,6 +2338,15 @@ public final class Display {
            return mVsyncRate;
        }

        /**
         * Returns true if mode is synthetic and does not have corresponding
         * SurfaceControl.DisplayMode
         * @hide
         */
        public boolean isSynthetic() {
            return mIsSynthetic;
        }

        /**
         * Returns an array of refresh rates which can be switched to seamlessly.
         * <p>
@@ -2456,6 +2482,7 @@ public final class Display {
                    .append(", height=").append(mHeight)
                    .append(", fps=").append(mPeakRefreshRate)
                    .append(", vsync=").append(mVsyncRate)
                    .append(", synthetic=").append(mIsSynthetic)
                    .append(", alternativeRefreshRates=")
                    .append(Arrays.toString(mAlternativeRefreshRates))
                    .append(", supportedHdrTypes=")
@@ -2471,7 +2498,7 @@ public final class Display {

        private Mode(Parcel in) {
            this(in.readInt(), in.readInt(), in.readInt(), in.readFloat(), in.readFloat(),
                    in.createFloatArray(), in.createIntArray());
                    in.readBoolean(), in.createFloatArray(), in.createIntArray());
        }

        @Override
@@ -2481,6 +2508,7 @@ public final class Display {
            out.writeInt(mHeight);
            out.writeFloat(mPeakRefreshRate);
            out.writeFloat(mVsyncRate);
            out.writeBoolean(mIsSynthetic);
            out.writeFloatArray(mAlternativeRefreshRates);
            out.writeIntArray(mSupportedHdrTypes);
        }
+21 −1
Original line number Diff line number Diff line
@@ -211,6 +211,12 @@ public final class DisplayInfo implements Parcelable {
     */
    public Display.Mode[] supportedModes = Display.Mode.EMPTY_ARRAY;

    /**
     * The supported modes that will be exposed externally.
     * Might have different set of modes that supportedModes for VRR displays
     */
    public Display.Mode[] appsSupportedModes = Display.Mode.EMPTY_ARRAY;

    /** The active color mode. */
    public int colorMode;

@@ -429,6 +435,7 @@ public final class DisplayInfo implements Parcelable {
                && defaultModeId == other.defaultModeId
                && userPreferredModeId == other.userPreferredModeId
                && Arrays.equals(supportedModes, other.supportedModes)
                && Arrays.equals(appsSupportedModes, other.appsSupportedModes)
                && colorMode == other.colorMode
                && Arrays.equals(supportedColorModes, other.supportedColorModes)
                && Objects.equals(hdrCapabilities, other.hdrCapabilities)
@@ -488,6 +495,8 @@ public final class DisplayInfo implements Parcelable {
        defaultModeId = other.defaultModeId;
        userPreferredModeId = other.userPreferredModeId;
        supportedModes = Arrays.copyOf(other.supportedModes, other.supportedModes.length);
        appsSupportedModes = Arrays.copyOf(
                other.appsSupportedModes, other.appsSupportedModes.length);
        colorMode = other.colorMode;
        supportedColorModes = Arrays.copyOf(
                other.supportedColorModes, other.supportedColorModes.length);
@@ -545,6 +554,11 @@ public final class DisplayInfo implements Parcelable {
        for (int i = 0; i < nModes; i++) {
            supportedModes[i] = Display.Mode.CREATOR.createFromParcel(source);
        }
        int nAppModes = source.readInt();
        appsSupportedModes = new Display.Mode[nAppModes];
        for (int i = 0; i < nAppModes; i++) {
            appsSupportedModes[i] = Display.Mode.CREATOR.createFromParcel(source);
        }
        colorMode = source.readInt();
        int nColorModes = source.readInt();
        supportedColorModes = new int[nColorModes];
@@ -611,6 +625,10 @@ public final class DisplayInfo implements Parcelable {
        for (int i = 0; i < supportedModes.length; i++) {
            supportedModes[i].writeToParcel(dest, flags);
        }
        dest.writeInt(appsSupportedModes.length);
        for (int i = 0; i < appsSupportedModes.length; i++) {
            appsSupportedModes[i].writeToParcel(dest, flags);
        }
        dest.writeInt(colorMode);
        dest.writeInt(supportedColorModes.length);
        for (int i = 0; i < supportedColorModes.length; i++) {
@@ -849,8 +867,10 @@ public final class DisplayInfo implements Parcelable {
        sb.append(defaultModeId);
        sb.append(", userPreferredModeId ");
        sb.append(userPreferredModeId);
        sb.append(", modes ");
        sb.append(", supportedModes ");
        sb.append(Arrays.toString(supportedModes));
        sb.append(", appsSupportedModes ");
        sb.append(Arrays.toString(appsSupportedModes));
        sb.append(", hdrCapabilities ");
        sb.append(hdrCapabilities);
        sb.append(", userDisabledHdrTypes ");
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        // Preferred refresh rate is equal to the first displayMode's refresh rate
        mPreferredRefreshRate = mContext.getDisplay().getSupportedModes()[0].getRefreshRate();
        mPreferredRefreshRate = mContext.getDisplay().getSystemSupportedModes()[0].getRefreshRate();
        overrideResource(
                R.integer.config_keyguardRefreshRate,
                (int) mPreferredRefreshRate
+1 −1
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
                .getInteger(R.integer.config_keyguardRefreshRate);
        float actualPreferredRefreshRate = -1;
        if (desiredPreferredRefreshRate > -1) {
            for (Display.Mode displayMode : context.getDisplay().getSupportedModes()) {
            for (Display.Mode displayMode : context.getDisplay().getSystemSupportedModes()) {
                if (Math.abs(displayMode.getRefreshRate() - desiredPreferredRefreshRate) <= .1) {
                    actualPreferredRefreshRate = displayMode.getRefreshRate();
                    break;
+1 −1
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ abstract class DisplayAdapter {
            float[] alternativeRefreshRates,
            @Display.HdrCapabilities.HdrType int[] supportedHdrTypes) {
        return new Display.Mode(NEXT_DISPLAY_MODE_ID.getAndIncrement(), width, height, refreshRate,
                vsyncRate, alternativeRefreshRates, supportedHdrTypes);
                vsyncRate, false, alternativeRefreshRates, supportedHdrTypes);
    }

    public interface Listener {
Loading