Merge "Update brightness nits to keep brightnessFloat same when RBC toggled" into tm-dev am: 2f8fc626c3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18889029 Change-Id: I0f016f8e58c854cc4d7bbf9ecf92f2c215200f27 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1057,7 +1057,17 @@ class AutomaticBrightnessController {
|
|||||||
|
|
||||||
public void recalculateSplines(boolean applyAdjustment, float[] adjustment) {
|
public void recalculateSplines(boolean applyAdjustment, float[] adjustment) {
|
||||||
mCurrentBrightnessMapper.recalculateSplines(applyAdjustment, adjustment);
|
mCurrentBrightnessMapper.recalculateSplines(applyAdjustment, adjustment);
|
||||||
updateAutoBrightness(true /*sendUpdate*/, false /*isManuallySet*/);
|
|
||||||
|
// If rbc is turned on, off or there is a change in strength, we want to reset the short
|
||||||
|
// term model. Since the nits range at which brightness now operates has changed due to
|
||||||
|
// RBC/strength change, any short term model based on the previous range should be
|
||||||
|
// invalidated.
|
||||||
|
resetShortTermModel();
|
||||||
|
|
||||||
|
// When rbc is turned on, we want to accommodate this change in the short term model.
|
||||||
|
if (applyAdjustment) {
|
||||||
|
setScreenBrightnessByUser(getAutomaticScreenBrightness());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class AutomaticBrightnessHandler extends Handler {
|
private final class AutomaticBrightnessHandler extends Handler {
|
||||||
|
|||||||
@@ -657,12 +657,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
}
|
}
|
||||||
mIsRbcActive = mCdsi.isReduceBrightColorsActivated();
|
mIsRbcActive = mCdsi.isReduceBrightColorsActivated();
|
||||||
mAutomaticBrightnessController.recalculateSplines(mIsRbcActive, adjustedNits);
|
mAutomaticBrightnessController.recalculateSplines(mIsRbcActive, adjustedNits);
|
||||||
|
|
||||||
// If rbc is turned on, off or there is a change in strength, we want to reset the short
|
|
||||||
// term model. Since the nits range at which brightness now operates has changed due to
|
|
||||||
// RBC/strength change, any short term model based on the previous range should be
|
|
||||||
// invalidated.
|
|
||||||
mAutomaticBrightnessController.resetShortTermModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.anyFloat;
|
import static org.mockito.Mockito.anyFloat;
|
||||||
import static org.mockito.Mockito.anyInt;
|
import static org.mockito.Mockito.anyInt;
|
||||||
|
import static org.mockito.Mockito.clearInvocations;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
@@ -258,29 +259,36 @@ public class AutomaticBrightnessControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testRecalculateSplines() throws Exception {
|
public void testRecalculateSplines() throws Exception {
|
||||||
// Enabling the light sensor, and setting the ambient lux to 1000
|
// Enabling the light sensor, and setting the ambient lux to 1000
|
||||||
|
int currentLux = 1000;
|
||||||
ArgumentCaptor<SensorEventListener> listenerCaptor =
|
ArgumentCaptor<SensorEventListener> listenerCaptor =
|
||||||
ArgumentCaptor.forClass(SensorEventListener.class);
|
ArgumentCaptor.forClass(SensorEventListener.class);
|
||||||
verify(mSensorManager).registerListener(listenerCaptor.capture(), eq(mLightSensor),
|
verify(mSensorManager).registerListener(listenerCaptor.capture(), eq(mLightSensor),
|
||||||
eq(INITIAL_LIGHT_SENSOR_RATE * 1000), any(Handler.class));
|
eq(INITIAL_LIGHT_SENSOR_RATE * 1000), any(Handler.class));
|
||||||
SensorEventListener listener = listenerCaptor.getValue();
|
SensorEventListener listener = listenerCaptor.getValue();
|
||||||
listener.onSensorChanged(TestUtils.createSensorEvent(mLightSensor, 1000));
|
listener.onSensorChanged(TestUtils.createSensorEvent(mLightSensor, currentLux));
|
||||||
|
|
||||||
//Setting the brightnessFloat to 0.5f
|
// User sets brightness to 0.5f
|
||||||
float currentBrightnessFloat = 0.5f;
|
when(mBrightnessMappingStrategy.getBrightness(currentLux,
|
||||||
when(mBrightnessMappingStrategy.getBrightness(1000,
|
null, ApplicationInfo.CATEGORY_UNDEFINED)).thenReturn(0.5f);
|
||||||
null, ApplicationInfo.CATEGORY_UNDEFINED)).thenReturn(currentBrightnessFloat);
|
|
||||||
mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
|
mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
|
||||||
currentBrightnessFloat /* brightness */, false /* userChangedBrightness */,
|
0.5f /* brightness */, true /* userChangedBrightness */, 0 /* adjustment */,
|
||||||
0 /* adjustment */, false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
|
false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
|
||||||
|
|
||||||
// Adjusting spline, and accordingly remapping the current 0.5f brightnessFloat to 0.3f
|
//Recalculating the spline with RBC enabled, verifying that the short term model is reset,
|
||||||
float updatedBrightnessFloat = 0.3f;
|
//and the interaction is learnt in short term model
|
||||||
when(mBrightnessMappingStrategy.getBrightness(1000,
|
float[] adjustments = new float[]{0.2f, 0.6f};
|
||||||
null, ApplicationInfo.CATEGORY_UNDEFINED)).thenReturn(updatedBrightnessFloat);
|
|
||||||
float[] adjustments = new float[]{0.2f, 0.5f};
|
|
||||||
mController.recalculateSplines(true, adjustments);
|
mController.recalculateSplines(true, adjustments);
|
||||||
|
verify(mBrightnessMappingStrategy).clearUserDataPoints();
|
||||||
verify(mBrightnessMappingStrategy).recalculateSplines(true, adjustments);
|
verify(mBrightnessMappingStrategy).recalculateSplines(true, adjustments);
|
||||||
assertEquals(mController.getAutomaticScreenBrightness(), updatedBrightnessFloat, EPSILON);
|
verify(mBrightnessMappingStrategy, times(2)).addUserDataPoint(currentLux, 0.5f);
|
||||||
|
|
||||||
|
clearInvocations(mBrightnessMappingStrategy);
|
||||||
|
|
||||||
|
// Verify short term model is not learnt when RBC is disabled
|
||||||
|
mController.recalculateSplines(false, adjustments);
|
||||||
|
verify(mBrightnessMappingStrategy).clearUserDataPoints();
|
||||||
|
verify(mBrightnessMappingStrategy).recalculateSplines(false, adjustments);
|
||||||
|
verifyNoMoreInteractions(mBrightnessMappingStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user