summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2022-12-19 18:04:06 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-12-19 18:04:06 +0000
commit13652c7a6e5be48dacd12b5b8b7f10c5c883dcea (patch)
treef0a74f4842eb86822c961ce33a3c6703a11a2061
parent16afc53f101628050d31e6377c85876ff99924a9 (diff)
parent068229d18513882d1dc7fbd1c0c4630c4bae10c3 (diff)
Merge "Retain the short-term model when device state changes" into tm-qpr-dev
-rw-r--r--services/core/java/com/android/server/display/AutomaticBrightnessController.java30
-rw-r--r--services/core/java/com/android/server/display/BrightnessMappingStrategy.java38
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerService.java7
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java23
-rw-r--r--services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java86
5 files changed, 140 insertions, 44 deletions
diff --git a/services/core/java/com/android/server/display/AutomaticBrightnessController.java b/services/core/java/com/android/server/display/AutomaticBrightnessController.java
index c0e7ab8a28a5..8b579ac6539d 100644
--- a/services/core/java/com/android/server/display/AutomaticBrightnessController.java
+++ b/services/core/java/com/android/server/display/AutomaticBrightnessController.java
@@ -249,7 +249,7 @@ class AutomaticBrightnessController {
HysteresisLevels screenBrightnessThresholdsIdle, Context context,
HighBrightnessModeController hbmController, BrightnessThrottler brightnessThrottler,
BrightnessMappingStrategy idleModeBrightnessMapper, int ambientLightHorizonShort,
- int ambientLightHorizonLong) {
+ int ambientLightHorizonLong, float userLux, float userBrightness) {
this(new Injector(), callbacks, looper, sensorManager, lightSensor,
interactiveModeBrightnessMapper,
lightSensorWarmUpTime, brightnessMin, brightnessMax, dozeScaleFactor,
@@ -258,7 +258,7 @@ class AutomaticBrightnessController {
ambientBrightnessThresholds, screenBrightnessThresholds,
ambientBrightnessThresholdsIdle, screenBrightnessThresholdsIdle, context,
hbmController, brightnessThrottler, idleModeBrightnessMapper,
- ambientLightHorizonShort, ambientLightHorizonLong
+ ambientLightHorizonShort, ambientLightHorizonLong, userLux, userBrightness
);
}
@@ -275,7 +275,7 @@ class AutomaticBrightnessController {
HysteresisLevels screenBrightnessThresholdsIdle, Context context,
HighBrightnessModeController hbmController, BrightnessThrottler brightnessThrottler,
BrightnessMappingStrategy idleModeBrightnessMapper, int ambientLightHorizonShort,
- int ambientLightHorizonLong) {
+ int ambientLightHorizonLong, float userLux, float userBrightness) {
mInjector = injector;
mClock = injector.createClock();
mContext = context;
@@ -322,6 +322,12 @@ class AutomaticBrightnessController {
mIdleModeBrightnessMapper = idleModeBrightnessMapper;
// Initialize to active (normal) screen brightness mode
switchToInteractiveScreenBrightnessMode();
+
+ if (userLux != BrightnessMappingStrategy.NO_USER_LUX
+ && userBrightness != BrightnessMappingStrategy.NO_USER_BRIGHTNESS) {
+ // Use the given short-term model
+ setScreenBrightnessByUser(userLux, userBrightness);
+ }
}
/**
@@ -383,7 +389,8 @@ class AutomaticBrightnessController {
public void configure(int state, @Nullable BrightnessConfiguration configuration,
float brightness, boolean userChangedBrightness, float adjustment,
- boolean userChangedAutoBrightnessAdjustment, int displayPolicy) {
+ boolean userChangedAutoBrightnessAdjustment, int displayPolicy,
+ boolean shouldResetShortTermModel) {
mState = state;
mHbmController.setAutoBrightnessEnabled(mState);
// While dozing, the application processor may be suspended which will prevent us from
@@ -392,7 +399,7 @@ class AutomaticBrightnessController {
// and hold onto the last computed screen auto brightness. We save the dozing flag for
// debugging purposes.
boolean dozing = (displayPolicy == DisplayPowerRequest.POLICY_DOZE);
- boolean changed = setBrightnessConfiguration(configuration);
+ boolean changed = setBrightnessConfiguration(configuration, shouldResetShortTermModel);
changed |= setDisplayPolicy(displayPolicy);
if (userChangedAutoBrightnessAdjustment) {
changed |= setAutoBrightnessAdjustment(adjustment);
@@ -492,9 +499,13 @@ class AutomaticBrightnessController {
// and we can't use this data to add a new control point to the short-term model.
return false;
}
- mCurrentBrightnessMapper.addUserDataPoint(mAmbientLux, brightness);
+ return setScreenBrightnessByUser(mAmbientLux, brightness);
+ }
+
+ private boolean setScreenBrightnessByUser(float lux, float brightness) {
+ mCurrentBrightnessMapper.addUserDataPoint(lux, brightness);
mShortTermModelValid = true;
- mShortTermModelAnchor = mAmbientLux;
+ mShortTermModelAnchor = lux;
if (mLoggingEnabled) {
Slog.d(TAG, "ShortTermModel: anchor=" + mShortTermModelAnchor);
}
@@ -514,9 +525,10 @@ class AutomaticBrightnessController {
mShortTermModelValid = false;
}
- public boolean setBrightnessConfiguration(BrightnessConfiguration configuration) {
+ public boolean setBrightnessConfiguration(BrightnessConfiguration configuration,
+ boolean shouldResetShortTermModel) {
if (mInteractiveModeBrightnessMapper.setBrightnessConfiguration(configuration)) {
- if (!isInIdleMode()) {
+ if (!isInIdleMode() && shouldResetShortTermModel) {
resetShortTermModel();
}
return true;
diff --git a/services/core/java/com/android/server/display/BrightnessMappingStrategy.java b/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
index 25d0752844fd..3fc50c4edf6d 100644
--- a/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
+++ b/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
@@ -51,6 +51,9 @@ import java.util.Objects;
public abstract class BrightnessMappingStrategy {
private static final String TAG = "BrightnessMappingStrategy";
+ public static final float NO_USER_LUX = -1;
+ public static final float NO_USER_BRIGHTNESS = -1;
+
private static final float LUX_GRAD_SMOOTHING = 0.25f;
private static final float MAX_GRAD = 1.0f;
private static final float SHORT_TERM_MODEL_THRESHOLD_RATIO = 0.6f;
@@ -68,6 +71,7 @@ public abstract class BrightnessMappingStrategy {
* Creates a BrightnessMappingStrategy for active (normal) mode.
* @param resources
* @param displayDeviceConfig
+ * @param displayWhiteBalanceController
* @return the BrightnessMappingStrategy
*/
@Nullable
@@ -82,6 +86,7 @@ public abstract class BrightnessMappingStrategy {
* Creates a BrightnessMappingStrategy for idle screen brightness mode.
* @param resources
* @param displayDeviceConfig
+ * @param displayWhiteBalanceController
* @return the BrightnessMappingStrategy
*/
@Nullable
@@ -100,6 +105,7 @@ public abstract class BrightnessMappingStrategy {
* @param displayDeviceConfig
* @param isForIdleMode determines whether the configurations loaded are for idle screen
* brightness mode or active screen brightness mode.
+ * @param displayWhiteBalanceController
* @return the BrightnessMappingStrategy
*/
@Nullable
@@ -370,6 +376,10 @@ public abstract class BrightnessMappingStrategy {
*/
public abstract boolean isForIdleMode();
+ abstract float getUserLux();
+
+ abstract float getUserBrightness();
+
/**
* Check if the short term model should be reset given the anchor lux the last
* brightness change was made at and the current ambient lux.
@@ -604,8 +614,8 @@ public abstract class BrightnessMappingStrategy {
mMaxGamma = maxGamma;
mAutoBrightnessAdjustment = 0;
- mUserLux = -1;
- mUserBrightness = -1;
+ mUserLux = NO_USER_LUX;
+ mUserBrightness = NO_USER_BRIGHTNESS;
if (mLoggingEnabled) {
PLOG.start("simple mapping strategy");
}
@@ -732,6 +742,16 @@ public abstract class BrightnessMappingStrategy {
return false;
}
+ @Override
+ float getUserLux() {
+ return mUserLux;
+ }
+
+ @Override
+ float getUserBrightness() {
+ return mUserBrightness;
+ }
+
private void computeSpline() {
Pair<float[], float[]> curve = getAdjustedCurve(mLux, mBrightness, mUserLux,
mUserBrightness, mAutoBrightnessAdjustment, mMaxGamma);
@@ -799,8 +819,8 @@ public abstract class BrightnessMappingStrategy {
mIsForIdleMode = isForIdleMode;
mMaxGamma = maxGamma;
mAutoBrightnessAdjustment = 0;
- mUserLux = -1;
- mUserBrightness = -1;
+ mUserLux = NO_USER_LUX;
+ mUserBrightness = NO_USER_BRIGHTNESS;
mDisplayWhiteBalanceController = displayWhiteBalanceController;
mNits = nits;
@@ -972,6 +992,16 @@ public abstract class BrightnessMappingStrategy {
return mIsForIdleMode;
}
+ @Override
+ float getUserLux() {
+ return mUserLux;
+ }
+
+ @Override
+ float getUserBrightness() {
+ return mUserBrightness;
+ }
+
/**
* Prints out the default curve and how it differs from the long-term curve
* and the current curve (in case the current curve includes short-term adjustments).
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index 3da7d830a23f..8f35924128bb 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -593,7 +593,7 @@ public final class DisplayManagerService extends SystemService {
getBrightnessConfigForDisplayWithPdsFallbackLocked(
logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId(),
userSerial);
- dpc.setBrightnessConfiguration(config);
+ dpc.setBrightnessConfiguration(config, /* shouldResetShortTermModel= */ true);
}
dpc.onSwitchUser(newUserId);
});
@@ -1890,7 +1890,7 @@ public final class DisplayManagerService extends SystemService {
}
DisplayPowerController dpc = getDpcFromUniqueIdLocked(uniqueId);
if (dpc != null) {
- dpc.setBrightnessConfiguration(c);
+ dpc.setBrightnessConfiguration(c, /* shouldResetShortTermModel= */ true);
}
}
}
@@ -1939,7 +1939,8 @@ public final class DisplayManagerService extends SystemService {
final DisplayPowerController dpc = mDisplayPowerControllers.get(
logicalDisplay.getDisplayIdLocked());
if (dpc != null) {
- dpc.setBrightnessConfiguration(config);
+ dpc.setBrightnessConfiguration(config,
+ /* shouldResetShortTermModel= */ false);
}
}
});
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 2fc6fd2254a7..c740b9856e16 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -231,6 +231,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// True if should use light sensor to automatically determine doze screen brightness.
private final boolean mAllowAutoBrightnessWhileDozingConfig;
+ // True if the brightness config has changed and the short-term model needs to be reset
+ private boolean mShouldResetShortTermModel;
+
// Whether or not the color fade on screen on / off is enabled.
private final boolean mColorFadeEnabled;
@@ -957,6 +960,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
return;
}
+ float userLux = BrightnessMappingStrategy.NO_USER_LUX;
+ float userBrightness = BrightnessMappingStrategy.NO_USER_BRIGHTNESS;
+ if (mInteractiveModeBrightnessMapper != null) {
+ userLux = mInteractiveModeBrightnessMapper.getUserLux();
+ userBrightness = mInteractiveModeBrightnessMapper.getUserBrightness();
+ }
+
final boolean isIdleScreenBrightnessEnabled = resources.getBoolean(
R.bool.config_enableIdleScreenBrightnessMode);
mInteractiveModeBrightnessMapper = BrightnessMappingStrategy.create(resources,
@@ -1084,7 +1094,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
ambientBrightnessThresholdsIdle, screenBrightnessThresholdsIdle, mContext,
mHbmController, mBrightnessThrottler, mIdleModeBrightnessMapper,
mDisplayDeviceConfig.getAmbientHorizonShort(),
- mDisplayDeviceConfig.getAmbientHorizonLong());
+ mDisplayDeviceConfig.getAmbientHorizonLong(), userLux, userBrightness);
mBrightnessEventRingBuffer =
new RingBuffer<>(BrightnessEvent.class, RINGBUFFER_MAX);
@@ -1413,7 +1423,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mBrightnessConfiguration,
mLastUserSetScreenBrightness,
userSetBrightnessChanged, autoBrightnessAdjustment,
- autoBrightnessAdjustmentChanged, mPowerRequest.policy);
+ autoBrightnessAdjustmentChanged, mPowerRequest.policy,
+ mShouldResetShortTermModel);
+ mShouldResetShortTermModel = false;
}
if (mBrightnessTracker != null) {
@@ -1807,8 +1819,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mHandler.sendEmptyMessage(MSG_IGNORE_PROXIMITY);
}
- public void setBrightnessConfiguration(BrightnessConfiguration c) {
- Message msg = mHandler.obtainMessage(MSG_CONFIGURE_BRIGHTNESS, c);
+ public void setBrightnessConfiguration(BrightnessConfiguration c,
+ boolean shouldResetShortTermModel) {
+ Message msg = mHandler.obtainMessage(MSG_CONFIGURE_BRIGHTNESS,
+ shouldResetShortTermModel ? 1 : 0, /* unused */ 0, c);
msg.sendToTarget();
}
@@ -3046,6 +3060,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
break;
case MSG_CONFIGURE_BRIGHTNESS:
mBrightnessConfiguration = (BrightnessConfiguration) msg.obj;
+ mShouldResetShortTermModel = msg.arg1 == 1;
updatePowerState();
break;
diff --git a/services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java b/services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java
index bb08ef756a14..3834834032cc 100644
--- a/services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyFloat;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.clearInvocations;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -97,7 +98,8 @@ public class AutomaticBrightnessControllerTest {
mLightSensor = TestUtils.createSensor(Sensor.TYPE_LIGHT, "Light Sensor");
mContext = InstrumentationRegistry.getContext();
- mController = setupController(mLightSensor);
+ mController = setupController(mLightSensor, BrightnessMappingStrategy.NO_USER_LUX,
+ BrightnessMappingStrategy.NO_USER_BRIGHTNESS);
}
@After
@@ -109,7 +111,8 @@ public class AutomaticBrightnessControllerTest {
}
}
- private AutomaticBrightnessController setupController(Sensor lightSensor) {
+ private AutomaticBrightnessController setupController(Sensor lightSensor, float userLux,
+ float userBrightness) {
mClock = new OffsettableClock.Stopped();
mTestLooper = new TestLooper(mClock::now);
@@ -134,7 +137,7 @@ public class AutomaticBrightnessControllerTest {
mAmbientBrightnessThresholds, mScreenBrightnessThresholds,
mAmbientBrightnessThresholdsIdle, mScreenBrightnessThresholdsIdle,
mContext, mHbmController, mBrightnessThrottler, mIdleBrightnessMappingStrategy,
- AMBIENT_LIGHT_HORIZON_SHORT, AMBIENT_LIGHT_HORIZON_LONG
+ AMBIENT_LIGHT_HORIZON_SHORT, AMBIENT_LIGHT_HORIZON_LONG, userLux, userBrightness
);
when(mHbmController.getCurrentBrightnessMax()).thenReturn(BRIGHTNESS_MAX_FLOAT);
@@ -145,9 +148,10 @@ public class AutomaticBrightnessControllerTest {
// Configure the brightness controller and grab an instance of the sensor listener,
// through which we can deliver fake (for test) sensor values.
- controller.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
- 0 /* brightness */, false /* userChangedBrightness */, 0 /* adjustment */,
- false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
+ controller.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ 0 /* brightness= */, false /* userChangedBrightness= */, 0 /* adjustment= */,
+ false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ true);
return controller;
}
@@ -252,9 +256,10 @@ public class AutomaticBrightnessControllerTest {
listener.onSensorChanged(TestUtils.createSensorEvent(mLightSensor, 1000));
// User sets brightness to 100
- mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
- 0.5f /* brightness */, true /* userChangedBrightness */, 0 /* adjustment */,
- false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
+ mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ 0.5f /* brightness= */, true /* userChangedBrightness= */, 0 /* adjustment= */,
+ false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ true);
// There should be a user data point added to the mapper.
verify(mBrightnessMappingStrategy).addUserDataPoint(1000f, 0.5f);
@@ -274,9 +279,10 @@ public class AutomaticBrightnessControllerTest {
// User sets brightness to 0.5f
when(mBrightnessMappingStrategy.getBrightness(currentLux,
null, ApplicationInfo.CATEGORY_UNDEFINED)).thenReturn(0.5f);
- mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
- 0.5f /* brightness */, true /* userChangedBrightness */, 0 /* adjustment */,
- false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
+ mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ 0.5f /* brightness= */, true /* userChangedBrightness= */, 0 /* adjustment= */,
+ false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ true);
//Recalculating the spline with RBC enabled, verifying that the short term model is reset,
//and the interaction is learnt in short term model
@@ -307,9 +313,10 @@ public class AutomaticBrightnessControllerTest {
listener.onSensorChanged(TestUtils.createSensorEvent(mLightSensor, 1000));
// User sets brightness to 100
- mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
- 0.5f /* brightness */, true /* userChangedBrightness */, 0 /* adjustment */,
- false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
+ mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ 0.5f /* brightness= */, true /* userChangedBrightness= */, 0 /* adjustment= */,
+ false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ true);
// There should be a user data point added to the mapper.
verify(mBrightnessMappingStrategy, times(1)).addUserDataPoint(1000f, 0.5f);
@@ -325,9 +332,10 @@ public class AutomaticBrightnessControllerTest {
verifyNoMoreInteractions(mBrightnessMappingStrategy);
// User sets idle brightness to 0.5
- mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
- 0.5f /* brightness */, true /* userChangedBrightness */, 0 /* adjustment */,
- false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
+ mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ 0.5f /* brightness= */, true /* userChangedBrightness= */, 0 /* adjustment= */,
+ false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ true);
// Ensure we use the correct mapping strategy
verify(mIdleBrightnessMappingStrategy, times(1)).addUserDataPoint(1000f, 0.5f);
@@ -483,17 +491,19 @@ public class AutomaticBrightnessControllerTest {
final float throttledBrightness = 0.123f;
when(mBrightnessThrottler.getBrightnessCap()).thenReturn(throttledBrightness);
when(mBrightnessThrottler.isThrottled()).thenReturn(true);
- mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
- BRIGHTNESS_MAX_FLOAT /* brightness */, false /* userChangedBrightness */,
- 0 /* adjustment */, false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
+ mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ BRIGHTNESS_MAX_FLOAT /* brightness= */, false /* userChangedBrightness= */,
+ 0 /* adjustment= */, false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ true);
assertEquals(throttledBrightness, mController.getAutomaticScreenBrightness(), 0.0f);
// Remove throttling and notify ABC again
when(mBrightnessThrottler.getBrightnessCap()).thenReturn(BRIGHTNESS_MAX_FLOAT);
when(mBrightnessThrottler.isThrottled()).thenReturn(false);
- mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration */,
- BRIGHTNESS_MAX_FLOAT /* brightness */, false /* userChangedBrightness */,
- 0 /* adjustment */, false /* userChanged */, DisplayPowerRequest.POLICY_BRIGHT);
+ mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ BRIGHTNESS_MAX_FLOAT /* brightness= */, false /* userChangedBrightness= */,
+ 0 /* adjustment= */, false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ true);
assertEquals(BRIGHTNESS_MAX_FLOAT, mController.getAutomaticScreenBrightness(), 0.0f);
}
@@ -584,4 +594,32 @@ public class AutomaticBrightnessControllerTest {
assertEquals(lux, sensorValues[0], EPSILON);
assertEquals(mClock.now() - AMBIENT_LIGHT_HORIZON_LONG, sensorTimestamps[0]);
}
+
+ @Test
+ public void testResetShortTermModelWhenConfigChanges() {
+ when(mBrightnessMappingStrategy.isForIdleMode()).thenReturn(false);
+ when(mBrightnessMappingStrategy.setBrightnessConfiguration(any())).thenReturn(true);
+
+ mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ BRIGHTNESS_MAX_FLOAT /* brightness= */, false /* userChangedBrightness= */,
+ 0 /* adjustment= */, false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ false);
+ verify(mBrightnessMappingStrategy, never()).clearUserDataPoints();
+
+ mController.configure(AUTO_BRIGHTNESS_ENABLED, null /* configuration= */,
+ BRIGHTNESS_MAX_FLOAT /* brightness= */, false /* userChangedBrightness= */,
+ 0 /* adjustment= */, false /* userChanged= */, DisplayPowerRequest.POLICY_BRIGHT,
+ /* shouldResetShortTermModel= */ true);
+ verify(mBrightnessMappingStrategy).clearUserDataPoints();
+ }
+
+ @Test
+ public void testUseProvidedShortTermModel() {
+ verify(mBrightnessMappingStrategy, never()).addUserDataPoint(anyFloat(), anyFloat());
+
+ float userLux = 1000;
+ float userBrightness = 0.3f;
+ setupController(mLightSensor, userLux, userBrightness);
+ verify(mBrightnessMappingStrategy).addUserDataPoint(userLux, userBrightness);
+ }
}