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

Commit 7d0663db authored by petsjonkin's avatar petsjonkin Committed by Oleg Petšjonkin
Browse files

New vote for low power mode

Part of VRR support for DisplayManager.
If vrr supported and new low power mode is enabled, then
use SupportedModeVote instead of RenderFrameRateVote

Bug: b/314920284
Test: atest SettingsObserverTest

Change-Id: I1cff72e316c29f78d1e3239d306c9571198561d3
parent ff5a7caa
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4255,6 +4255,9 @@
    -->
    <bool name="config_wallpaperTopApp">false</bool>

    <!-- True if the device supports dVRR  -->
    <bool name="config_supportsDvrr">false</bool>

    <!-- True if the device supports at least one form of multi-window.
         E.g. freeform, split-screen, picture-in-picture. -->
    <bool name="config_supportsMultiWindow">true</bool>
+1 −0
Original line number Diff line number Diff line
@@ -404,6 +404,7 @@
  <java-symbol type="bool" name="config_supportAudioSourceUnprocessed" />
  <java-symbol type="bool" name="config_freeformWindowManagement" />
  <java-symbol type="bool" name="config_supportsBubble" />
  <java-symbol type="bool" name="config_supportsDvrr" />
  <java-symbol type="bool" name="config_supportsMultiWindow" />
  <java-symbol type="bool" name="config_supportsSplitScreenMultiWindow" />
  <java-symbol type="bool" name="config_supportsMultiDisplay" />
+8 −1
Original line number Diff line number Diff line
@@ -93,6 +93,10 @@ public class DisplayManagerFlags {
            Flags.FLAG_ENABLE_EXTERNAL_VSYNC_PROXIMITY_VOTE,
            Flags::enableExternalVsyncProximityVote);

    private final FlagState mVsyncLowPowerVote = new FlagState(
            Flags.FLAG_ENABLE_VSYNC_LOW_POWER_VOTE,
            Flags::enableVsyncLowPowerVote);

    private final FlagState mBrightnessWearBedtimeModeClamperFlagState = new FlagState(
            Flags.FLAG_BRIGHTNESS_WEAR_BEDTIME_MODE_CLAMPER,
            Flags::brightnessWearBedtimeModeClamper);
@@ -125,7 +129,6 @@ public class DisplayManagerFlags {
        return mPowerThrottlingClamperFlagState.isEnabled();
    }


    /**
     * Returns whether adaptive tone improvements are enabled
     */
@@ -198,6 +201,10 @@ public class DisplayManagerFlags {
        return mVsyncProximityVote.isEnabled();
    }

    public boolean isVsyncLowPowerVoteEnabled() {
        return mVsyncLowPowerVote.isEnabled();
    }

    public boolean isBrightnessWearBedtimeModeClamperEnabled() {
        return mBrightnessWearBedtimeModeClamperFlagState.isEnabled();
    }
+8 −0
Original line number Diff line number Diff line
@@ -129,6 +129,14 @@ flag {
    is_fixed_read_only: true
}

flag {
    name: "enable_vsync_low_power_vote"
    namespace: "display_manager"
    description: "Feature flag for vsync low power vote"
    bug: "314920284"
    is_fixed_read_only: true
}

flag {
    name: "brightness_wear_bedtime_mode_clamper"
    namespace: "display_manager"
+20 −7
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public class DisplayModeDirector {

    private final boolean mIsBackUpSmoothDisplayAndForcePeakRefreshRateEnabled;

    private final boolean mVsyncProximityVoteEnabled;
    private final boolean mDvrrSupported;


    public DisplayModeDirector(@NonNull Context context, @NonNull Handler handler,
@@ -190,6 +190,8 @@ public class DisplayModeDirector {
    public DisplayModeDirector(@NonNull Context context, @NonNull Handler handler,
            @NonNull Injector injector,
            @NonNull DisplayManagerFlags displayManagerFlags) {
        mDvrrSupported = context.getResources().getBoolean(
                com.android.internal.R.bool.config_supportsDvrr);
        mIsDisplayResolutionRangeVotingEnabled = displayManagerFlags
                .isDisplayResolutionRangeVotingEnabled();
        mIsUserPreferredModeVoteEnabled = displayManagerFlags.isUserPreferredModeVoteEnabled();
@@ -199,7 +201,6 @@ public class DisplayModeDirector {
            .isDisplaysRefreshRatesSynchronizationEnabled();
        mIsBackUpSmoothDisplayAndForcePeakRefreshRateEnabled = displayManagerFlags
                .isBackUpSmoothDisplayAndForcePeakRefreshRateEnabled();
        mVsyncProximityVoteEnabled = displayManagerFlags.isVsyncProximityVoteEnabled();
        mContext = context;
        mHandler = new DisplayModeDirectorHandler(handler.getLooper());
        mInjector = injector;
@@ -208,7 +209,8 @@ public class DisplayModeDirector {
        mAppRequestObserver = new AppRequestObserver();
        mConfigParameterProvider = new DeviceConfigParameterProvider(injector.getDeviceConfig());
        mDeviceConfigDisplaySettings = new DeviceConfigDisplaySettings();
        mSettingsObserver = new SettingsObserver(context, handler);
        mSettingsObserver = new SettingsObserver(context, handler, mDvrrSupported,
                displayManagerFlags);
        mBrightnessObserver = new BrightnessObserver(context, handler, injector);
        mDefaultDisplayDeviceConfig = null;
        mUdfpsObserver = new UdfpsObserver();
@@ -290,7 +292,7 @@ public class DisplayModeDirector {
            List<Display.Mode> availableModes = new ArrayList<>();
            availableModes.add(defaultMode);
            VoteSummary primarySummary = new VoteSummary(mIsDisplayResolutionRangeVotingEnabled,
                    mVsyncProximityVoteEnabled, mLoggingEnabled, mSupportsFrameRateOverride);
                    mDvrrSupported, mLoggingEnabled, mSupportsFrameRateOverride);
            int lowestConsideredPriority = Vote.MIN_PRIORITY;
            int highestConsideredPriority = Vote.MAX_PRIORITY;

@@ -330,7 +332,7 @@ public class DisplayModeDirector {
            }

            VoteSummary appRequestSummary = new VoteSummary(mIsDisplayResolutionRangeVotingEnabled,
                    mVsyncProximityVoteEnabled, mLoggingEnabled, mSupportsFrameRateOverride);
                    mDvrrSupported, mLoggingEnabled, mSupportsFrameRateOverride);

            appRequestSummary.applyVotes(votes,
                    Vote.APP_REQUEST_REFRESH_RATE_RANGE_PRIORITY_CUTOFF,
@@ -818,13 +820,17 @@ public class DisplayModeDirector {
        private final Uri mMatchContentFrameRateSetting =
                Settings.Secure.getUriFor(Settings.Secure.MATCH_CONTENT_FRAME_RATE);

        private final boolean mVsynLowPowerVoteEnabled;

        private final Context mContext;
        private float mDefaultPeakRefreshRate;
        private float mDefaultRefreshRate;

        SettingsObserver(@NonNull Context context, @NonNull Handler handler) {
        SettingsObserver(@NonNull Context context, @NonNull Handler handler, boolean dvrrSupported,
                DisplayManagerFlags flags) {
            super(handler);
            mContext = context;
            mVsynLowPowerVoteEnabled = dvrrSupported && flags.isVsyncLowPowerVoteEnabled();
            // We don't want to load from the DeviceConfig while constructing since this leads to
            // a spike in the latency of DisplayManagerService startup. This happens because
            // reading from the DeviceConfig is an intensive IO operation and having it in the
@@ -936,7 +942,14 @@ public class DisplayModeDirector {
            boolean inLowPowerMode = Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.LOW_POWER_MODE, 0 /*default*/) != 0;
            final Vote vote;
            if (inLowPowerMode) {
            if (inLowPowerMode && mVsynLowPowerVoteEnabled) {
                vote = Vote.forSupportedModes(List.of(
                        new SupportedModesVote.SupportedMode(/* peakRefreshRate= */ 60f,
                                /* vsyncRate= */ 240f),
                        new SupportedModesVote.SupportedMode(/* peakRefreshRate= */ 60f,
                                /* vsyncRate= */ 60f)
                ));
            } else if (inLowPowerMode) {
                vote = Vote.forRenderFrameRates(0f, 60f);
            } else {
                vote = null;
Loading