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

Commit b54d40ba authored by Kenny Guy's avatar Kenny Guy
Browse files

Don't report slider events with bad lux readings.

Wait until AutomaticBrightnessController has a valid
lux reading before reporting slider events.

Bug: 126683965
Test: atest android.display.cts.BrightnessTest with config_lightSensorWarmupTime set to 0 - test passes
Test: atest android.display.cts.BrightnessTest with config_lightSensorWarmupTime set to 3000 - test passes
Test: atest android.display.cts.BrightnessTest with config_lightSensorWarmupTime set to 4000 - test times out
Change-Id: I881427c85835e751ba5ac75086a9612984878e13
parent 01794b57
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -288,6 +288,10 @@ class AutomaticBrightnessController {
        return mScreenAutoBrightness;
    }

    public boolean hasValidAmbientLux() {
        return mAmbientLuxValid;
    }

    public float getAutomaticScreenBrightnessAdjustment() {
        return mBrightnessMapper.getAutoBrightnessAdjustment();
    }
@@ -648,9 +652,9 @@ class AutomaticBrightnessController {
                mLightSensorWarmUpTimeConfig + mLightSensorEnableTime;
            if (time < timeWhenSensorWarmedUp) {
                if (mLoggingEnabled) {
                    Slog.d(TAG, "updateAmbientLux: Sensor not  ready yet: " +
                            "time=" + time + ", " +
                            "timeWhenSensorWarmedUp=" + timeWhenSensorWarmedUp);
                    Slog.d(TAG, "updateAmbientLux: Sensor not ready yet: "
                            + "time=" + time + ", "
                            + "timeWhenSensorWarmedUp=" + timeWhenSensorWarmedUp);
                }
                mHandler.sendEmptyMessageAtTime(MSG_UPDATE_AMBIENT_LUX,
                        timeWhenSensorWarmedUp);
+7 −1
Original line number Diff line number Diff line
@@ -874,7 +874,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call

        // If the brightness is already set then it's been overridden by something other than the
        // user, or is a temporary adjustment.
        final boolean userInitiatedChange = brightness < 0
        boolean userInitiatedChange = brightness < 0
                && (autoBrightnessAdjustmentChanged || userSetBrightnessChanged);

        boolean hadUserBrightnessPoint = false;
@@ -1010,6 +1010,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            }

            if (!brightnessIsTemporary) {
                if (userInitiatedChange && (mAutomaticBrightnessController == null
                        || !mAutomaticBrightnessController.hasValidAmbientLux())) {
                    // If we don't have a valid lux reading we can't report a valid
                    // slider event so notify as if the system changed the brightness.
                    userInitiatedChange = false;
                }
                notifyBrightnessChanged(brightness, userInitiatedChange, hadUserBrightnessPoint);
            }