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

Commit fcd98c4a authored by Piotr Wilczyński's avatar Piotr Wilczyński
Browse files

Pass ambient lux to the HBM controllers of the follower DPCs

- set the state of the HBM controller independently of the state of the ABC

Bug: 241307705
Test: atest AutomaticBrightnessControllerTest
Test: atest DisplayPowerControllerTest
Test: atest DisplayPowerController2Test
Change-Id: Ie1254aadd1d6a42b1305e1b18f51575ada61a60d
parent 32338521
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -402,7 +402,6 @@ class AutomaticBrightnessController {
            boolean userChangedAutoBrightnessAdjustment, int displayPolicy,
            boolean shouldResetShortTermModel) {
        mState = state;
        mHbmController.setAutoBrightnessEnabled(mState);
        // While dozing, the application processor may be suspended which will prevent us from
        // receiving new information from the light sensor. On some devices, we may be able to
        // switch to a wake-up light sensor instead but for now we will simply disable the sensor
@@ -466,7 +465,6 @@ class AutomaticBrightnessController {
        mHandler.sendEmptyMessage(MSG_RUN_UPDATE);
    }

    @VisibleForTesting
    float getAmbientLux() {
        return mAmbientLux;
    }
+11 −3
Original line number Diff line number Diff line
@@ -719,7 +719,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    }

    @Override
    public void setBrightnessToFollow(float leadDisplayBrightness, float nits) {
    public void setBrightnessToFollow(float leadDisplayBrightness, float nits, float ambientLux) {
        mHbmController.onAmbientLuxChange(ambientLux);
        if (mAutomaticBrightnessController == null || nits < 0) {
            mBrightnessToFollow = leadDisplayBrightness;
        } else {
@@ -751,7 +752,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        }
        for (int i = 0; i < followers.size(); i++) {
            DisplayPowerControllerInterface follower = followers.valueAt(i);
            follower.setBrightnessToFollow(PowerManager.BRIGHTNESS_INVALID_FLOAT, /* nits= */ -1);
            follower.setBrightnessToFollow(PowerManager.BRIGHTNESS_INVALID_FLOAT, /* nits= */ -1,
                    /* ambientLux= */ 0);
        }
    }

@@ -1523,6 +1525,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    mShouldResetShortTermModel);
            mShouldResetShortTermModel = false;
        }
        mHbmController.setAutoBrightnessEnabled(mUseAutoBrightness
                ? AutomaticBrightnessController.AUTO_BRIGHTNESS_ENABLED
                : AutomaticBrightnessController.AUTO_BRIGHTNESS_DISABLED);

        if (mBrightnessTracker != null) {
            mBrightnessTracker.setBrightnessConfiguration(mBrightnessConfiguration);
@@ -1634,9 +1639,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            mAppliedThrottling = false;
        }

        float ambientLux = mAutomaticBrightnessController == null ? 0
                : mAutomaticBrightnessController.getAmbientLux();
        for (int i = 0; i < displayBrightnessFollowers.size(); i++) {
            DisplayPowerControllerInterface follower = displayBrightnessFollowers.valueAt(i);
            follower.setBrightnessToFollow(rawBrightnessState, convertToNits(rawBrightnessState));
            follower.setBrightnessToFollow(rawBrightnessState, convertToNits(rawBrightnessState),
                    ambientLux);
        }

        if (updateScreenBrightnessSetting) {
+11 −3
Original line number Diff line number Diff line
@@ -1236,6 +1236,9 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
                    mShouldResetShortTermModel);
            mShouldResetShortTermModel = false;
        }
        mHbmController.setAutoBrightnessEnabled(mUseAutoBrightness
                ? AutomaticBrightnessController.AUTO_BRIGHTNESS_ENABLED
                : AutomaticBrightnessController.AUTO_BRIGHTNESS_DISABLED);

        if (mBrightnessTracker != null) {
            mBrightnessTracker.setBrightnessConfiguration(mBrightnessConfiguration);
@@ -1347,9 +1350,12 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
            mAppliedThrottling = false;
        }

        float ambientLux = mAutomaticBrightnessController == null ? 0
                : mAutomaticBrightnessController.getAmbientLux();
        for (int i = 0; i < displayBrightnessFollowers.size(); i++) {
            DisplayPowerControllerInterface follower = displayBrightnessFollowers.valueAt(i);
            follower.setBrightnessToFollow(rawBrightnessState, convertToNits(rawBrightnessState));
            follower.setBrightnessToFollow(rawBrightnessState, convertToNits(rawBrightnessState),
                    ambientLux);
        }

        if (updateScreenBrightnessSetting) {
@@ -2136,7 +2142,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
    }

    @Override
    public void setBrightnessToFollow(float leadDisplayBrightness, float nits) {
    public void setBrightnessToFollow(float leadDisplayBrightness, float nits, float ambientLux) {
        mHbmController.onAmbientLuxChange(ambientLux);
        if (mAutomaticBrightnessController == null || nits < 0) {
            mDisplayBrightnessController.setBrightnessToFollow(leadDisplayBrightness);
        } else {
@@ -2217,7 +2224,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
        }
        for (int i = 0; i < followers.size(); i++) {
            DisplayPowerControllerInterface follower = followers.valueAt(i);
            follower.setBrightnessToFollow(PowerManager.BRIGHTNESS_INVALID_FLOAT, /* nits= */ -1);
            follower.setBrightnessToFollow(PowerManager.BRIGHTNESS_INVALID_FLOAT, /* nits= */ -1,
                    /* ambientLux= */ 0);
        }
    }

+4 −2
Original line number Diff line number Diff line
@@ -173,9 +173,11 @@ public interface DisplayPowerControllerInterface {
     * displays.
     * @param leadDisplayBrightness The brightness of the lead display in the set of concurrent
     *                              displays
     * @param nits The brightness value in nits if the device supports nits
     * @param nits The brightness value in nits if the device supports nits. Set to a negative
     *             number otherwise.
     * @param ambientLux The lux value that will be passed to {@link HighBrightnessModeController}
     */
    void setBrightnessToFollow(float leadDisplayBrightness, float nits);
    void setBrightnessToFollow(float leadDisplayBrightness, float nits, float ambientLux);

    /**
     * Add an additional display that will copy the brightness value from this display. This is used