summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/display/DisplayDeviceConfig.java26
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java18
-rw-r--r--services/core/java/com/android/server/display/RampAnimator.java35
-rw-r--r--services/core/xsd/display-device-config/display-device-config.xsd10
-rw-r--r--services/core/xsd/display-device-config/schema/current.txt4
5 files changed, 90 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/display/DisplayDeviceConfig.java b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
index aa30c0897d60..a25ac210f9c8 100644
--- a/services/core/java/com/android/server/display/DisplayDeviceConfig.java
+++ b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
@@ -152,6 +152,9 @@ import javax.xml.datatype.DatatypeConfigurationException;
* <screenBrightnessRampSlowDecrease>0.03</screenBrightnessRampSlowDecrease>
* <screenBrightnessRampSlowIncrease>0.04</screenBrightnessRampSlowIncrease>
*
+ * <screenBrightnessRampIncreaseMaxMillis>2000</screenBrightnessRampIncreaseMaxMillis>
+ * <screenBrightnessRampDecreaseMaxMillis>3000</screenBrightnessRampDecreaseMaxMillis>
+ *
* <lightSensor>
* <type>android.sensor.light</type>
* <name>1234 Ambient Light Sensor</name>
@@ -259,6 +262,8 @@ public class DisplayDeviceConfig {
private float mBrightnessRampFastIncrease = Float.NaN;
private float mBrightnessRampSlowDecrease = Float.NaN;
private float mBrightnessRampSlowIncrease = Float.NaN;
+ private long mBrightnessRampDecreaseMaxMillis = 0;
+ private long mBrightnessRampIncreaseMaxMillis = 0;
private int mAmbientHorizonLong = AMBIENT_LIGHT_LONG_HORIZON_MILLIS;
private int mAmbientHorizonShort = AMBIENT_LIGHT_SHORT_HORIZON_MILLIS;
private float mScreenBrighteningMinThreshold = 0.0f; // Retain behaviour as though there is
@@ -534,6 +539,14 @@ public class DisplayDeviceConfig {
return mBrightnessRampSlowIncrease;
}
+ public long getBrightnessRampDecreaseMaxMillis() {
+ return mBrightnessRampDecreaseMaxMillis;
+ }
+
+ public long getBrightnessRampIncreaseMaxMillis() {
+ return mBrightnessRampIncreaseMaxMillis;
+ }
+
public int getAmbientHorizonLong() {
return mAmbientHorizonLong;
}
@@ -628,6 +641,8 @@ public class DisplayDeviceConfig {
+ ", mBrightnessRampFastIncrease=" + mBrightnessRampFastIncrease
+ ", mBrightnessRampSlowDecrease=" + mBrightnessRampSlowDecrease
+ ", mBrightnessRampSlowIncrease=" + mBrightnessRampSlowIncrease
+ + ", mBrightnessRampDecreaseMaxMillis=" + mBrightnessRampDecreaseMaxMillis
+ + ", mBrightnessRampIncreaseMaxMillis=" + mBrightnessRampIncreaseMaxMillis
+ ", mAmbientHorizonLong=" + mAmbientHorizonLong
+ ", mAmbientHorizonShort=" + mAmbientHorizonShort
+ ", mScreenDarkeningMinThreshold=" + mScreenDarkeningMinThreshold
@@ -725,6 +740,8 @@ public class DisplayDeviceConfig {
mBrightnessRampFastIncrease = PowerManager.BRIGHTNESS_MAX;
mBrightnessRampSlowDecrease = PowerManager.BRIGHTNESS_MAX;
mBrightnessRampSlowIncrease = PowerManager.BRIGHTNESS_MAX;
+ mBrightnessRampDecreaseMaxMillis = 0;
+ mBrightnessRampIncreaseMaxMillis = 0;
setSimpleMappingStrategyValues();
loadAmbientLightSensorFromConfigXml();
setProxSensorUnspecified();
@@ -1115,6 +1132,15 @@ public class DisplayDeviceConfig {
}
loadBrightnessRampsFromConfigXml();
}
+
+ final BigInteger increaseMax = config.getScreenBrightnessRampIncreaseMaxMillis();
+ if (increaseMax != null) {
+ mBrightnessRampIncreaseMaxMillis = increaseMax.intValue();
+ }
+ final BigInteger decreaseMax = config.getScreenBrightnessRampDecreaseMaxMillis();
+ if (decreaseMax != null) {
+ mBrightnessRampDecreaseMaxMillis = decreaseMax.intValue();
+ }
}
private void loadBrightnessRampsFromConfigXml() {
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 80ff8349a153..d13a9a3ec27e 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -255,6 +255,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// to reach the final state.
private final boolean mBrightnessBucketsInDozeConfig;
+ // Maximum time a ramp animation can take.
+ private long mBrightnessRampIncreaseMaxTimeMillis;
+ private long mBrightnessRampDecreaseMaxTimeMillis;
+
// The pending power request.
// Initially null until the first call to requestPowerState.
@GuardedBy("mLock")
@@ -507,7 +511,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
final Resources resources = context.getResources();
-
// DOZE AND DIM SETTINGS
mScreenBrightnessDozeConfig = clampAbsoluteBrightness(
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DOZE));
@@ -641,7 +644,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mIsRbcActive = mCdsi.isReduceBrightColorsActivated();
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
@@ -837,6 +839,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
loadNitsRange(mContext.getResources());
setUpAutoBrightness(mContext.getResources(), mHandler);
reloadReduceBrightColours();
+ if (mScreenBrightnessRampAnimator != null) {
+ mScreenBrightnessRampAnimator.setAnimationTimeLimits(
+ mBrightnessRampIncreaseMaxTimeMillis,
+ mBrightnessRampDecreaseMaxTimeMillis);
+ }
mHbmController.resetHbmData(info.width, info.height, token, info.uniqueId,
mDisplayDeviceConfig.getHighBrightnessModeData(),
new HighBrightnessModeController.HdrBrightnessDeviceConfig() {
@@ -883,6 +890,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mScreenBrightnessRampAnimator = new DualRampAnimator<>(mPowerState,
DisplayPowerState.SCREEN_BRIGHTNESS_FLOAT,
DisplayPowerState.SCREEN_SDR_BRIGHTNESS_FLOAT);
+ mScreenBrightnessRampAnimator.setAnimationTimeLimits(
+ mBrightnessRampIncreaseMaxTimeMillis,
+ mBrightnessRampDecreaseMaxTimeMillis);
mScreenBrightnessRampAnimator.setListener(mRampAnimatorListener);
noteScreenState(mPowerState.getScreenState());
@@ -1007,6 +1017,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mBrightnessRampRateFastIncrease = mDisplayDeviceConfig.getBrightnessRampFastIncrease();
mBrightnessRampRateSlowDecrease = mDisplayDeviceConfig.getBrightnessRampSlowDecrease();
mBrightnessRampRateSlowIncrease = mDisplayDeviceConfig.getBrightnessRampSlowIncrease();
+ mBrightnessRampDecreaseMaxTimeMillis =
+ mDisplayDeviceConfig.getBrightnessRampDecreaseMaxMillis();
+ mBrightnessRampIncreaseMaxTimeMillis =
+ mDisplayDeviceConfig.getBrightnessRampIncreaseMaxMillis();
}
private void loadNitsRange(Resources resources) {
diff --git a/services/core/java/com/android/server/display/RampAnimator.java b/services/core/java/com/android/server/display/RampAnimator.java
index 2567e4306293..690ec3fb5aaf 100644
--- a/services/core/java/com/android/server/display/RampAnimator.java
+++ b/services/core/java/com/android/server/display/RampAnimator.java
@@ -34,6 +34,8 @@ class RampAnimator<T> {
private float mCurrentValue;
private float mTargetValue;
private float mRate;
+ private float mAnimationIncreaseMaxTimeSecs;
+ private float mAnimationDecreaseMaxTimeSecs;
private boolean mAnimating;
private float mAnimatedValue; // higher precision copy of mCurrentValue
@@ -43,13 +45,24 @@ class RampAnimator<T> {
private Listener mListener;
- public RampAnimator(T object, FloatProperty<T> property) {
+ RampAnimator(T object, FloatProperty<T> property) {
mObject = object;
mProperty = property;
mChoreographer = Choreographer.getInstance();
}
/**
+ * Sets the maximum time that a brightness animation can take.
+ */
+ public void setAnimationTimeLimits(long animationRampIncreaseMaxTimeMillis,
+ long animationRampDecreaseMaxTimeMillis) {
+ mAnimationIncreaseMaxTimeSecs = (animationRampIncreaseMaxTimeMillis > 0)
+ ? (animationRampIncreaseMaxTimeMillis / 1000.0f) : 0.0f;
+ mAnimationDecreaseMaxTimeSecs = (animationRampDecreaseMaxTimeMillis > 0)
+ ? (animationRampDecreaseMaxTimeMillis / 1000.0f) : 0.0f;
+ }
+
+ /**
* Starts animating towards the specified value.
*
* If this is the first time the property is being set or if the rate is 0,
@@ -83,6 +96,15 @@ class RampAnimator<T> {
return false;
}
+ // Adjust the rate so that we do not exceed our maximum animation time.
+ if (target > mCurrentValue && mAnimationIncreaseMaxTimeSecs > 0.0f
+ && ((target - mCurrentValue) / rate) > mAnimationIncreaseMaxTimeSecs) {
+ rate = (target - mCurrentValue) / mAnimationIncreaseMaxTimeSecs;
+ } else if (target < mCurrentValue && mAnimationDecreaseMaxTimeSecs > 0.0f
+ && ((mCurrentValue - target) / rate) > mAnimationDecreaseMaxTimeSecs) {
+ rate = (mCurrentValue - target) / mAnimationDecreaseMaxTimeSecs;
+ }
+
// Adjust the rate based on the closest target.
// If a faster rate is specified, then use the new rate so that we converge
// more rapidly based on the new request.
@@ -209,6 +231,17 @@ class RampAnimator<T> {
}
/**
+ * Sets the maximum time that a brightness animation can take.
+ */
+ public void setAnimationTimeLimits(long animationRampIncreaseMaxTimeMillis,
+ long animationRampDecreaseMaxTimeMillis) {
+ mFirst.setAnimationTimeLimits(animationRampIncreaseMaxTimeMillis,
+ animationRampDecreaseMaxTimeMillis);
+ mSecond.setAnimationTimeLimits(animationRampIncreaseMaxTimeMillis,
+ animationRampDecreaseMaxTimeMillis);
+ }
+
+ /**
* Starts animating towards the specified values.
*
* If this is the first time the property is being set or if the rate is 0,
diff --git a/services/core/xsd/display-device-config/display-device-config.xsd b/services/core/xsd/display-device-config/display-device-config.xsd
index 0e9a04f1fdde..09044e72f60b 100644
--- a/services/core/xsd/display-device-config/display-device-config.xsd
+++ b/services/core/xsd/display-device-config/display-device-config.xsd
@@ -57,6 +57,16 @@
<xs:element type="nonNegativeDecimal" name="screenBrightnessRampSlowIncrease">
<xs:annotation name="final"/>
</xs:element>
+ <!-- Maximum time in milliseconds that a brightness increase animation
+ can take. -->
+ <xs:element type="xs:nonNegativeInteger" name="screenBrightnessRampIncreaseMaxMillis">
+ <xs:annotation name="final"/>
+ </xs:element>
+ <!-- Maximum time in milliseconds that a brightness decrease animation
+ can take. -->
+ <xs:element type="xs:nonNegativeInteger" name="screenBrightnessRampDecreaseMaxMillis">
+ <xs:annotation name="final"/>
+ </xs:element>
<xs:element type="sensorDetails" name="lightSensor">
<xs:annotation name="final"/>
</xs:element>
diff --git a/services/core/xsd/display-device-config/schema/current.txt b/services/core/xsd/display-device-config/schema/current.txt
index 075edd77af1d..e8b13ca6356e 100644
--- a/services/core/xsd/display-device-config/schema/current.txt
+++ b/services/core/xsd/display-device-config/schema/current.txt
@@ -48,8 +48,10 @@ package com.android.server.display.config {
method public com.android.server.display.config.DisplayQuirks getQuirks();
method @NonNull public final java.math.BigDecimal getScreenBrightnessDefault();
method @NonNull public final com.android.server.display.config.NitsMap getScreenBrightnessMap();
+ method public final java.math.BigInteger getScreenBrightnessRampDecreaseMaxMillis();
method public final java.math.BigDecimal getScreenBrightnessRampFastDecrease();
method public final java.math.BigDecimal getScreenBrightnessRampFastIncrease();
+ method public final java.math.BigInteger getScreenBrightnessRampIncreaseMaxMillis();
method public final java.math.BigDecimal getScreenBrightnessRampSlowDecrease();
method public final java.math.BigDecimal getScreenBrightnessRampSlowIncrease();
method @NonNull public final com.android.server.display.config.ThermalThrottling getThermalThrottling();
@@ -64,8 +66,10 @@ package com.android.server.display.config {
method public void setQuirks(com.android.server.display.config.DisplayQuirks);
method public final void setScreenBrightnessDefault(@NonNull java.math.BigDecimal);
method public final void setScreenBrightnessMap(@NonNull com.android.server.display.config.NitsMap);
+ method public final void setScreenBrightnessRampDecreaseMaxMillis(java.math.BigInteger);
method public final void setScreenBrightnessRampFastDecrease(java.math.BigDecimal);
method public final void setScreenBrightnessRampFastIncrease(java.math.BigDecimal);
+ method public final void setScreenBrightnessRampIncreaseMaxMillis(java.math.BigInteger);
method public final void setScreenBrightnessRampSlowDecrease(java.math.BigDecimal);
method public final void setScreenBrightnessRampSlowIncrease(java.math.BigDecimal);
method public final void setThermalThrottling(@NonNull com.android.server.display.config.ThermalThrottling);