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

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

Merge "Reset short-term model on 'reset-brightness-configuration' command" into main

parents 6c98bdf2 973a434b
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -572,14 +572,13 @@ public class AutomaticBrightnessController {

    public boolean setBrightnessConfiguration(BrightnessConfiguration configuration,
            boolean shouldResetShortTermModel) {
        if (mBrightnessMappingStrategyMap.get(AUTO_BRIGHTNESS_MODE_DEFAULT)
                .setBrightnessConfiguration(configuration)) {
        boolean changed = mBrightnessMappingStrategyMap.get(AUTO_BRIGHTNESS_MODE_DEFAULT)
                                  .setBrightnessConfiguration(configuration);
        if (!isInIdleMode() && shouldResetShortTermModel) {
            resetShortTermModel();
            changed = true;
        }
            return true;
        }
        return false;
        return changed;
    }

    /**
+8 −9
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ public class AutomaticBrightnessControllerTest {
        mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
                0 /* brightness= */, false /* userChangedBrightness= */, 0 /* adjustment= */,
                false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT, Display.STATE_ON,
                /* useNormalBrightnessForDoze= */ false, /* shouldResetShortTermModel= */ true);
                /* useNormalBrightnessForDoze= */ false, /* shouldResetShortTermModel= */ false);
    }

    @Test
@@ -326,7 +326,7 @@ public class AutomaticBrightnessControllerTest {
        mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
                0.5f /* brightness= */, true /* userChangedBrightness= */, 0 /* adjustment= */,
                false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT, Display.STATE_ON,
                /* useNormalBrightnessForDoze= */ false, /* shouldResetShortTermModel= */ true);
                /* useNormalBrightnessForDoze= */ false, /* shouldResetShortTermModel= */ false);

        //Recalculating the spline with RBC enabled, verifying that the short term model is reset,
        //and the interaction is learnt in short term model
@@ -400,7 +400,7 @@ public class AutomaticBrightnessControllerTest {
        mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
                0.51f /* brightness= */, true /* userChangedBrightness= */, 0 /* adjustment= */,
                false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT, Display.STATE_ON,
                /* useNormalBrightnessForDoze= */ false, /* shouldResetShortTermModel= */ true);
                /* useNormalBrightnessForDoze= */ false, /* shouldResetShortTermModel= */ false);

        when(mBrightnessMappingStrategy.shouldResetShortTermModel(
                anyFloat(), anyFloat())).thenReturn(true);
@@ -573,7 +573,7 @@ public class AutomaticBrightnessControllerTest {
        mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
                0.5f /* brightness= */, true /* userChangedBrightness= */, 0 /* adjustment= */,
                false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT, Display.STATE_ON,
                /* useNormalBrightnessForDoze= */ false, /* shouldResetShortTermModel= */ true);
                /* useNormalBrightnessForDoze= */ false, /* shouldResetShortTermModel= */ false);

        // There should be a user data point added to the mapper.
        verify(mBrightnessMappingStrategy, times(1)).addUserDataPoint(/* lux= */ 1000f,
@@ -583,11 +583,12 @@ public class AutomaticBrightnessControllerTest {

        // Now let's do the same for idle mode
        mController.switchMode(AUTO_BRIGHTNESS_MODE_IDLE, /* sendUpdate= */ true);
        // Called once when switching,
        // Called once when configuring in setUp(), once when configuring in the test,
        // once when switching,
        // setAmbientLux() is called twice and once in updateAutoBrightness(),
        // nextAmbientLightBrighteningTransition() and nextAmbientLightDarkeningTransition() are
        // called twice each.
        verify(mBrightnessMappingStrategy, times(8)).getMode();
        verify(mBrightnessMappingStrategy, times(10)).getMode();
        // Called when switching.
        verify(mBrightnessMappingStrategy, times(1)).getShortTermModelTimeout();
        verify(mBrightnessMappingStrategy, times(1)).getUserBrightness();
@@ -924,9 +925,7 @@ public class AutomaticBrightnessControllerTest {
    }

    @Test
    public void testResetShortTermModelWhenConfigChanges() {
        when(mBrightnessMappingStrategy.setBrightnessConfiguration(any())).thenReturn(true);

    public void testResetShortTermModel() {
        mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
                BRIGHTNESS_MAX_FLOAT /* brightness= */, false /* userChangedBrightness= */,
                0 /* adjustment= */, false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,