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

Commit 0e4a0aa5 authored by petsjonkin's avatar petsjonkin Committed by Oleg Petšjonkin
Browse files

Adding new SYSTEM_REQUESTED priority to DisplayModeDirector voting

Added new SYSTEM_REQUESTED_MODE priority
Added new Vote type
Renamed SupportedModesVote to SupportedRefreshRatesVote to better reflect its purpose

Test: atest VotesStorageTest atest VoteSummaryTest, atest DisplayModeDirectorTest, atest SupportedModesVoteTest
Bug: b/309466682
Change-Id: I41237a993a8b53cc65026719f605501578369b2f
parent 4e4a9174
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.display.mode;

import android.annotation.NonNull;

import java.util.Objects;

class BaseModeRefreshRateVote implements Vote {
@@ -31,7 +33,7 @@ class BaseModeRefreshRateVote implements Vote {
    }

    @Override
    public void updateSummary(VoteSummary summary) {
    public void updateSummary(@NonNull VoteSummary summary) {
        if (summary.appRequestBaseModeRefreshRate == 0f
                && mAppRequestBaseModeRefreshRate > 0f) {
            summary.appRequestBaseModeRefreshRate = mAppRequestBaseModeRefreshRate;
+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.display.mode;

import android.annotation.NonNull;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -28,7 +30,7 @@ class CombinedVote implements Vote {
    }

    @Override
    public void updateSummary(VoteSummary summary) {
    public void updateSummary(@NonNull VoteSummary summary) {
        mVotes.forEach(vote -> vote.updateSummary(summary));
    }

+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.display.mode;

import android.annotation.NonNull;

import java.util.Objects;

class DisableRefreshRateSwitchingVote implements Vote {
@@ -31,7 +33,7 @@ class DisableRefreshRateSwitchingVote implements Vote {
    }

    @Override
    public void updateSummary(VoteSummary summary) {
    public void updateSummary(@NonNull VoteSummary summary) {
        summary.disableRefreshRateSwitching =
                summary.disableRefreshRateSwitching || mDisableRefreshRateSwitching;
    }
+6 −6
Original line number Diff line number Diff line
@@ -988,10 +988,10 @@ public class DisplayModeDirector {
                    Settings.Global.LOW_POWER_MODE, 0 /*default*/) != 0;
            final Vote vote;
            if (inLowPowerMode && mVsynLowPowerVoteEnabled) {
                vote = Vote.forSupportedModes(List.of(
                        new SupportedModesVote.SupportedMode(/* peakRefreshRate= */ 60f,
                vote = Vote.forSupportedRefreshRates(List.of(
                        new SupportedRefreshRatesVote.RefreshRates(/* peakRefreshRate= */ 60f,
                                /* vsyncRate= */ 240f),
                        new SupportedModesVote.SupportedMode(/* peakRefreshRate= */ 60f,
                        new SupportedRefreshRatesVote.RefreshRates(/* peakRefreshRate= */ 60f,
                                /* vsyncRate= */ 60f)
                ));
            } else if (inLowPowerMode) {
@@ -2176,11 +2176,11 @@ public class DisplayModeDirector {
                }

                if (mVsyncLowLightBlockingVoteEnabled) {
                    refreshRateSwitchingVote = Vote.forSupportedModesAndDisableRefreshRateSwitching(
                    refreshRateSwitchingVote = Vote.forSupportedRefreshRatesAndDisableSwitching(
                            List.of(
                                    new SupportedModesVote.SupportedMode(
                                    new SupportedRefreshRatesVote.RefreshRates(
                                            /* peakRefreshRate= */ 60f, /* vsyncRate= */ 60f),
                                    new SupportedModesVote.SupportedMode(
                                    new SupportedRefreshRatesVote.RefreshRates(
                                            /* peakRefreshRate= */120f, /* vsyncRate= */ 120f)));
                } else {
                    refreshRateSwitchingVote = Vote.forDisableRefreshRateSwitching();
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.display.mode;

import android.annotation.NonNull;

import java.util.Objects;


@@ -64,7 +66,7 @@ abstract class RefreshRateVote implements Vote {
         *  Vote: min(ignored)     min(applied)  min(applied+physical)  max(applied)  max(ignored)
         */
        @Override
        public void updateSummary(VoteSummary summary) {
        public void updateSummary(@NonNull VoteSummary summary) {
            summary.minRenderFrameRate = Math.max(summary.minRenderFrameRate, mMinRefreshRate);
            summary.maxRenderFrameRate = Math.min(summary.maxRenderFrameRate, mMaxRefreshRate);
            // Physical refresh rate cannot be lower than the minimal render frame rate.
@@ -97,7 +99,7 @@ abstract class RefreshRateVote implements Vote {
         *  Vote: min(ignored) min(applied)  max(applied+render)     max(applied)  max(ignored)
         */
        @Override
        public void updateSummary(VoteSummary summary) {
        public void updateSummary(@NonNull VoteSummary summary) {
            summary.minPhysicalRefreshRate = Math.max(summary.minPhysicalRefreshRate,
                    mMinRefreshRate);
            summary.maxPhysicalRefreshRate = Math.min(summary.maxPhysicalRefreshRate,
Loading