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

Commit daad29b0 authored by Piotr Wilczyński's avatar Piotr Wilczyński Committed by Android (Google) Code Review
Browse files

Merge "Wear doze: last used lux instead of last observed lux" into main

parents 52acbe99 2aafaaf1
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ public class AutomaticBrightnessController {
    private long mLightSensorEnableTime;

    // The currently accepted nominal ambient light level.
    private float mAmbientLux;
    private float mAmbientLux = INVALID_LUX;

    // The last calculated ambient light level (long time window).
    private float mSlowAmbientLux;
@@ -434,23 +434,23 @@ public class AutomaticBrightnessController {
     * entering doze - we disable the light sensor, invalidate the lux, but we still need to set
     * the initial brightness in doze mode.
     */
    public float getAutomaticScreenBrightnessBasedOnLastObservedLux(
    public float getAutomaticScreenBrightnessBasedOnLastUsedLux(
            BrightnessEvent brightnessEvent) {
        if (mLastObservedLux == INVALID_LUX) {
        float lastUsedLux = mAmbientLux;
        if (lastUsedLux == INVALID_LUX) {
            return PowerManager.BRIGHTNESS_INVALID_FLOAT;
        }

        float brightness = mCurrentBrightnessMapper.getBrightness(mLastObservedLux,
        float brightness = mCurrentBrightnessMapper.getBrightness(lastUsedLux,
                mForegroundAppPackageName, mForegroundAppCategory);
        if (shouldApplyDozeScaleFactor()) {
            brightness *= mDozeScaleFactor;
        }

        if (brightnessEvent != null) {
            brightnessEvent.setLux(mLastObservedLux);
            brightnessEvent.setLux(lastUsedLux);
            brightnessEvent.setRecommendedBrightness(brightness);
            brightnessEvent.setFlags(brightnessEvent.getFlags()
                    | (mLastObservedLux == INVALID_LUX ? BrightnessEvent.FLAG_INVALID_LUX : 0)
                    | (shouldApplyDozeScaleFactor() ? BrightnessEvent.FLAG_DOZE_SCALE : 0));
            brightnessEvent.setAutoBrightnessMode(getMode());
        }
+1 −1
Original line number Diff line number Diff line
@@ -1448,7 +1448,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    && mAutomaticBrightnessStrategy.shouldUseAutoBrightness()) {
                // Use the auto-brightness curve and the last observed lux
                rawBrightnessState = mAutomaticBrightnessController
                        .getAutomaticScreenBrightnessBasedOnLastObservedLux(
                        .getAutomaticScreenBrightnessBasedOnLastUsedLux(
                                mTempBrightnessEvent);
            } else {
                rawBrightnessState = getDozeBrightnessForOffload();
+2 −2
Original line number Diff line number Diff line
@@ -360,11 +360,11 @@ public class AutomaticBrightnessStrategy extends AutomaticBrightnessStrategy2
     * @param brightnessEvent Event object to populate with details about why the specific
     *                        brightness was chosen.
     */
    public float getAutomaticScreenBrightnessBasedOnLastObservedLux(
    public float getAutomaticScreenBrightnessBasedOnLastUsedLux(
            BrightnessEvent brightnessEvent) {
        float brightness = (mAutomaticBrightnessController != null)
                ? mAutomaticBrightnessController
                .getAutomaticScreenBrightnessBasedOnLastObservedLux(brightnessEvent)
                .getAutomaticScreenBrightnessBasedOnLastUsedLux(brightnessEvent)
                : PowerManager.BRIGHTNESS_INVALID_FLOAT;
        adjustAutomaticBrightnessStateIfValid(brightness);
        return brightness;
+2 −2
Original line number Diff line number Diff line
@@ -279,11 +279,11 @@ public class AutomaticBrightnessStrategy2 {
     * @param brightnessEvent Event object to populate with details about why the specific
     *                        brightness was chosen.
     */
    public float getAutomaticScreenBrightnessBasedOnLastObservedLux(
    public float getAutomaticScreenBrightnessBasedOnLastUsedLux(
            BrightnessEvent brightnessEvent) {
        float brightness = (mAutomaticBrightnessController != null)
                ? mAutomaticBrightnessController
                .getAutomaticScreenBrightnessBasedOnLastObservedLux(brightnessEvent)
                .getAutomaticScreenBrightnessBasedOnLastUsedLux(brightnessEvent)
                : PowerManager.BRIGHTNESS_INVALID_FLOAT;
        adjustAutomaticBrightnessStateIfValid(brightness);
        return brightness;
+5 −5
Original line number Diff line number Diff line
@@ -1030,7 +1030,7 @@ public class AutomaticBrightnessControllerTest {
    }

    @Test
    public void testBrightnessBasedOnLastObservedLux() throws Exception {
    public void testBrightnessBasedOnLastUsedLux() throws Exception {
        ArgumentCaptor<SensorEventListener> listenerCaptor =
                ArgumentCaptor.forClass(SensorEventListener.class);
        verify(mSensorManager).registerListener(listenerCaptor.capture(), eq(mLightSensor),
@@ -1054,7 +1054,7 @@ public class AutomaticBrightnessControllerTest {
                /* userChanged= */ false, DisplayPowerRequest.POLICY_BRIGHT, Display.STATE_ON,
                /* shouldResetShortTermModel= */ true);
        assertEquals(normalizedBrightness,
                mController.getAutomaticScreenBrightnessBasedOnLastObservedLux(
                mController.getAutomaticScreenBrightnessBasedOnLastUsedLux(
                        /* brightnessEvent= */ null), EPSILON);
    }

@@ -1090,7 +1090,7 @@ public class AutomaticBrightnessControllerTest {
                mController.getAutomaticScreenBrightness(
                        /* brightnessEvent= */ null), EPSILON);
        assertEquals(normalizedBrightness * DOZE_SCALE_FACTOR,
                mController.getAutomaticScreenBrightnessBasedOnLastObservedLux(
                mController.getAutomaticScreenBrightnessBasedOnLastUsedLux(
                        /* brightnessEvent= */ null), EPSILON);
    }

@@ -1128,7 +1128,7 @@ public class AutomaticBrightnessControllerTest {
        assertEquals(normalizedBrightness,
                mController.getAutomaticScreenBrightness(/* brightnessEvent= */ null), EPSILON);
        assertEquals(normalizedBrightness,
                mController.getAutomaticScreenBrightnessBasedOnLastObservedLux(
                mController.getAutomaticScreenBrightnessBasedOnLastUsedLux(
                        /* brightnessEvent= */ null), EPSILON);
    }

@@ -1163,7 +1163,7 @@ public class AutomaticBrightnessControllerTest {
        assertEquals(normalizedBrightness,
                mController.getAutomaticScreenBrightness(/* brightnessEvent= */ null), EPSILON);
        assertEquals(normalizedBrightness,
                mController.getAutomaticScreenBrightnessBasedOnLastObservedLux(
                mController.getAutomaticScreenBrightnessBasedOnLastUsedLux(
                        /* brightnessEvent= */ null), EPSILON);
    }
}
Loading