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

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

Merge "HDR should not consume HBM time limit" into main

parents 9e98d6d8 6413e79f
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.display;

import android.annotation.Nullable;
import android.hardware.display.BrightnessInfo;
import android.os.Handler;
import android.os.IBinder;

@@ -121,8 +120,11 @@ class BrightnessRangeController {
    }

    void onBrightnessChanged(float brightness, float unthrottledBrightness,
            @BrightnessInfo.BrightnessMaxReason int throttlingReason) {
        mHbmController.onBrightnessChanged(brightness, unthrottledBrightness, throttlingReason);
            DisplayBrightnessState state) {
        mHbmController.onHdrBoostApplied(
                state.getHdrBrightness() != DisplayBrightnessState.BRIGHTNESS_NOT_SET);
        mHbmController.onBrightnessChanged(brightness, unthrottledBrightness,
                state.getBrightnessMaxReason());
    }

    float getCurrentBrightnessMin() {
+1 −1
Original line number Diff line number Diff line
@@ -1638,7 +1638,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        // brightness sources (such as an app override) are not saved to the setting, but should be
        // reflected in HBM calculations.
        mBrightnessRangeController.onBrightnessChanged(brightnessState, unthrottledBrightnessState,
                clampedState.getBrightnessMaxReason());
                clampedState);

        // Animate the screen brightness when the screen is on or dozing.
        // Skip the animation when the screen is off or suspended.
+14 −1
Original line number Diff line number Diff line
@@ -102,7 +102,8 @@ class HighBrightnessModeController {
        BrightnessInfo.BRIGHTNESS_MAX_REASON_NONE;

    private int mHbmMode = BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF;
    private boolean mIsHdrLayerPresent = false;
    @VisibleForTesting
    boolean mIsHdrLayerPresent = false;
    // mMaxDesiredHdrSdrRatio should only be applied when there is a valid backlight->nits mapping
    private float mMaxDesiredHdrSdrRatio = DEFAULT_MAX_DESIRED_HDR_SDR_RATIO;
    private boolean mForceHbmChangeCallback = false;
@@ -387,6 +388,18 @@ class HighBrightnessModeController {
        mHdrBoostDisabled = true;
        unregisterHdrListener();
    }
    /**
     * Hdr boost can be applied by
     * {@link com.android.server.display.brightness.clamper.HdrBrightnessModifier}, in this case
     * HBMController should not consume HBM time budget
     */
    void onHdrBoostApplied(boolean applied) {
        // We need to update mIsHdrLayerPresent flag only if HDR boost is controlled  by other
        // component and disabled here
        if (mHdrBoostDisabled) {
            mIsHdrLayerPresent = applied;
        }
    }

    private long calculateRemainingTime(long currentTime) {
        if (!deviceSupportsHbm()) {
+19 −0
Original line number Diff line number Diff line
@@ -720,6 +720,25 @@ public class HighBrightnessModeControllerTest {
                        .DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LOW_REQUESTED_BRIGHTNESS));
    }

    @Test
    public void testDoesNotAcceptExternalHdrLayerUpdates_hdrBoostEnabled() {
        final HighBrightnessModeController hbmc = createDefaultHbm();
        assertFalse(hbmc.mIsHdrLayerPresent);

        hbmc.onHdrBoostApplied(true);
        assertFalse(hbmc.mIsHdrLayerPresent);
    }

    @Test
    public void testAcceptsExternalHdrLayerUpdates_hdrBoostDisabled() {
        final HighBrightnessModeController hbmc = createDefaultHbm();
        hbmc.disableHdrBoost();
        assertFalse(hbmc.mIsHdrLayerPresent);

        hbmc.onHdrBoostApplied(true);
        assertTrue(hbmc.mIsHdrLayerPresent);
    }

    private void assertState(HighBrightnessModeController hbmc,
            float brightnessMin, float brightnessMax, int hbmMode) {
        assertEquals(brightnessMin, hbmc.getCurrentBrightnessMin(), EPSILON);