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

Commit d7ab9495 authored by Fiona Campbell's avatar Fiona Campbell
Browse files

Fix brightness curve when user sets slider to min.

The brightness spline was setting the entire curve to 0.0f. This was due
to the min and max points of point x+1 being constrained to a factor of
the brightness x. If this happens to be 0.0f, the brightness curve will
never increase.

Bug: 153799222

Test: AutomaticBrightnessControllerTest

Change-Id: Id29389e7fc17b402d2f1bd581a805a6067eac4bb
parent 3443ba8d
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -51,6 +51,11 @@ public abstract class BrightnessMappingStrategy {
    private static final float MAX_GRAD = 1.0f;
    private static final float SHORT_TERM_MODEL_THRESHOLD_RATIO = 0.6f;

    // Constant that ensures that each step of the curve can increase by up to at least
    // MIN_PERMISSABLE_INCREASE. Otherwise when the brightness is set to 0, the curve will never
    // increase and will always be 0.
    private static final float MIN_PERMISSABLE_INCREASE =  0.004f;

    protected boolean mLoggingEnabled;

    private static final Plog PLOG = Plog.createSystemPlog(TAG);
@@ -400,7 +405,9 @@ public abstract class BrightnessMappingStrategy {
        for (int i = idx+1; i < lux.length; i++) {
            float currLux = lux[i];
            float currBrightness = brightness[i];
            float maxBrightness = prevBrightness * permissibleRatio(currLux, prevLux);
            float maxBrightness = MathUtils.max(
                    prevBrightness * permissibleRatio(currLux, prevLux),
                    prevBrightness + MIN_PERMISSABLE_INCREASE);
            float newBrightness = MathUtils.constrain(
                    currBrightness, prevBrightness, maxBrightness);
            if (newBrightness == currBrightness) {