Merge "Apply a maximum time to Screen brightness RampAnimator." into tm-dev am: 7cda9b01e3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17707268 Change-Id: Ie18b5e91bfb3470727085a5b984633219ed88804 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -152,6 +152,9 @@ import javax.xml.datatype.DatatypeConfigurationException;
|
|||||||
* <screenBrightnessRampSlowDecrease>0.03</screenBrightnessRampSlowDecrease>
|
* <screenBrightnessRampSlowDecrease>0.03</screenBrightnessRampSlowDecrease>
|
||||||
* <screenBrightnessRampSlowIncrease>0.04</screenBrightnessRampSlowIncrease>
|
* <screenBrightnessRampSlowIncrease>0.04</screenBrightnessRampSlowIncrease>
|
||||||
*
|
*
|
||||||
|
* <screenBrightnessRampIncreaseMaxMillis>2000</screenBrightnessRampIncreaseMaxMillis>
|
||||||
|
* <screenBrightnessRampDecreaseMaxMillis>3000</screenBrightnessRampDecreaseMaxMillis>
|
||||||
|
*
|
||||||
* <lightSensor>
|
* <lightSensor>
|
||||||
* <type>android.sensor.light</type>
|
* <type>android.sensor.light</type>
|
||||||
* <name>1234 Ambient Light Sensor</name>
|
* <name>1234 Ambient Light Sensor</name>
|
||||||
@@ -259,6 +262,8 @@ public class DisplayDeviceConfig {
|
|||||||
private float mBrightnessRampFastIncrease = Float.NaN;
|
private float mBrightnessRampFastIncrease = Float.NaN;
|
||||||
private float mBrightnessRampSlowDecrease = Float.NaN;
|
private float mBrightnessRampSlowDecrease = Float.NaN;
|
||||||
private float mBrightnessRampSlowIncrease = 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 mAmbientHorizonLong = AMBIENT_LIGHT_LONG_HORIZON_MILLIS;
|
||||||
private int mAmbientHorizonShort = AMBIENT_LIGHT_SHORT_HORIZON_MILLIS;
|
private int mAmbientHorizonShort = AMBIENT_LIGHT_SHORT_HORIZON_MILLIS;
|
||||||
private float mScreenBrighteningMinThreshold = 0.0f; // Retain behaviour as though there is
|
private float mScreenBrighteningMinThreshold = 0.0f; // Retain behaviour as though there is
|
||||||
@@ -534,6 +539,14 @@ public class DisplayDeviceConfig {
|
|||||||
return mBrightnessRampSlowIncrease;
|
return mBrightnessRampSlowIncrease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getBrightnessRampDecreaseMaxMillis() {
|
||||||
|
return mBrightnessRampDecreaseMaxMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBrightnessRampIncreaseMaxMillis() {
|
||||||
|
return mBrightnessRampIncreaseMaxMillis;
|
||||||
|
}
|
||||||
|
|
||||||
public int getAmbientHorizonLong() {
|
public int getAmbientHorizonLong() {
|
||||||
return mAmbientHorizonLong;
|
return mAmbientHorizonLong;
|
||||||
}
|
}
|
||||||
@@ -628,6 +641,8 @@ public class DisplayDeviceConfig {
|
|||||||
+ ", mBrightnessRampFastIncrease=" + mBrightnessRampFastIncrease
|
+ ", mBrightnessRampFastIncrease=" + mBrightnessRampFastIncrease
|
||||||
+ ", mBrightnessRampSlowDecrease=" + mBrightnessRampSlowDecrease
|
+ ", mBrightnessRampSlowDecrease=" + mBrightnessRampSlowDecrease
|
||||||
+ ", mBrightnessRampSlowIncrease=" + mBrightnessRampSlowIncrease
|
+ ", mBrightnessRampSlowIncrease=" + mBrightnessRampSlowIncrease
|
||||||
|
+ ", mBrightnessRampDecreaseMaxMillis=" + mBrightnessRampDecreaseMaxMillis
|
||||||
|
+ ", mBrightnessRampIncreaseMaxMillis=" + mBrightnessRampIncreaseMaxMillis
|
||||||
+ ", mAmbientHorizonLong=" + mAmbientHorizonLong
|
+ ", mAmbientHorizonLong=" + mAmbientHorizonLong
|
||||||
+ ", mAmbientHorizonShort=" + mAmbientHorizonShort
|
+ ", mAmbientHorizonShort=" + mAmbientHorizonShort
|
||||||
+ ", mScreenDarkeningMinThreshold=" + mScreenDarkeningMinThreshold
|
+ ", mScreenDarkeningMinThreshold=" + mScreenDarkeningMinThreshold
|
||||||
@@ -725,6 +740,8 @@ public class DisplayDeviceConfig {
|
|||||||
mBrightnessRampFastIncrease = PowerManager.BRIGHTNESS_MAX;
|
mBrightnessRampFastIncrease = PowerManager.BRIGHTNESS_MAX;
|
||||||
mBrightnessRampSlowDecrease = PowerManager.BRIGHTNESS_MAX;
|
mBrightnessRampSlowDecrease = PowerManager.BRIGHTNESS_MAX;
|
||||||
mBrightnessRampSlowIncrease = PowerManager.BRIGHTNESS_MAX;
|
mBrightnessRampSlowIncrease = PowerManager.BRIGHTNESS_MAX;
|
||||||
|
mBrightnessRampDecreaseMaxMillis = 0;
|
||||||
|
mBrightnessRampIncreaseMaxMillis = 0;
|
||||||
setSimpleMappingStrategyValues();
|
setSimpleMappingStrategyValues();
|
||||||
loadAmbientLightSensorFromConfigXml();
|
loadAmbientLightSensorFromConfigXml();
|
||||||
setProxSensorUnspecified();
|
setProxSensorUnspecified();
|
||||||
@@ -1115,6 +1132,15 @@ public class DisplayDeviceConfig {
|
|||||||
}
|
}
|
||||||
loadBrightnessRampsFromConfigXml();
|
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() {
|
private void loadBrightnessRampsFromConfigXml() {
|
||||||
|
|||||||
@@ -255,6 +255,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
// to reach the final state.
|
// to reach the final state.
|
||||||
private final boolean mBrightnessBucketsInDozeConfig;
|
private final boolean mBrightnessBucketsInDozeConfig;
|
||||||
|
|
||||||
|
// Maximum time a ramp animation can take.
|
||||||
|
private long mBrightnessRampIncreaseMaxTimeMillis;
|
||||||
|
private long mBrightnessRampDecreaseMaxTimeMillis;
|
||||||
|
|
||||||
// The pending power request.
|
// The pending power request.
|
||||||
// Initially null until the first call to requestPowerState.
|
// Initially null until the first call to requestPowerState.
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
@@ -507,7 +511,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
|
|
||||||
final Resources resources = context.getResources();
|
final Resources resources = context.getResources();
|
||||||
|
|
||||||
|
|
||||||
// DOZE AND DIM SETTINGS
|
// DOZE AND DIM SETTINGS
|
||||||
mScreenBrightnessDozeConfig = clampAbsoluteBrightness(
|
mScreenBrightnessDozeConfig = clampAbsoluteBrightness(
|
||||||
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DOZE));
|
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DOZE));
|
||||||
@@ -641,7 +644,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
|
// 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
|
// 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
|
// 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());
|
loadNitsRange(mContext.getResources());
|
||||||
setUpAutoBrightness(mContext.getResources(), mHandler);
|
setUpAutoBrightness(mContext.getResources(), mHandler);
|
||||||
reloadReduceBrightColours();
|
reloadReduceBrightColours();
|
||||||
|
if (mScreenBrightnessRampAnimator != null) {
|
||||||
|
mScreenBrightnessRampAnimator.setAnimationTimeLimits(
|
||||||
|
mBrightnessRampIncreaseMaxTimeMillis,
|
||||||
|
mBrightnessRampDecreaseMaxTimeMillis);
|
||||||
|
}
|
||||||
mHbmController.resetHbmData(info.width, info.height, token, info.uniqueId,
|
mHbmController.resetHbmData(info.width, info.height, token, info.uniqueId,
|
||||||
mDisplayDeviceConfig.getHighBrightnessModeData(),
|
mDisplayDeviceConfig.getHighBrightnessModeData(),
|
||||||
new HighBrightnessModeController.HdrBrightnessDeviceConfig() {
|
new HighBrightnessModeController.HdrBrightnessDeviceConfig() {
|
||||||
@@ -883,6 +890,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
mScreenBrightnessRampAnimator = new DualRampAnimator<>(mPowerState,
|
mScreenBrightnessRampAnimator = new DualRampAnimator<>(mPowerState,
|
||||||
DisplayPowerState.SCREEN_BRIGHTNESS_FLOAT,
|
DisplayPowerState.SCREEN_BRIGHTNESS_FLOAT,
|
||||||
DisplayPowerState.SCREEN_SDR_BRIGHTNESS_FLOAT);
|
DisplayPowerState.SCREEN_SDR_BRIGHTNESS_FLOAT);
|
||||||
|
mScreenBrightnessRampAnimator.setAnimationTimeLimits(
|
||||||
|
mBrightnessRampIncreaseMaxTimeMillis,
|
||||||
|
mBrightnessRampDecreaseMaxTimeMillis);
|
||||||
mScreenBrightnessRampAnimator.setListener(mRampAnimatorListener);
|
mScreenBrightnessRampAnimator.setListener(mRampAnimatorListener);
|
||||||
|
|
||||||
noteScreenState(mPowerState.getScreenState());
|
noteScreenState(mPowerState.getScreenState());
|
||||||
@@ -1007,6 +1017,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
mBrightnessRampRateFastIncrease = mDisplayDeviceConfig.getBrightnessRampFastIncrease();
|
mBrightnessRampRateFastIncrease = mDisplayDeviceConfig.getBrightnessRampFastIncrease();
|
||||||
mBrightnessRampRateSlowDecrease = mDisplayDeviceConfig.getBrightnessRampSlowDecrease();
|
mBrightnessRampRateSlowDecrease = mDisplayDeviceConfig.getBrightnessRampSlowDecrease();
|
||||||
mBrightnessRampRateSlowIncrease = mDisplayDeviceConfig.getBrightnessRampSlowIncrease();
|
mBrightnessRampRateSlowIncrease = mDisplayDeviceConfig.getBrightnessRampSlowIncrease();
|
||||||
|
mBrightnessRampDecreaseMaxTimeMillis =
|
||||||
|
mDisplayDeviceConfig.getBrightnessRampDecreaseMaxMillis();
|
||||||
|
mBrightnessRampIncreaseMaxTimeMillis =
|
||||||
|
mDisplayDeviceConfig.getBrightnessRampIncreaseMaxMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadNitsRange(Resources resources) {
|
private void loadNitsRange(Resources resources) {
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ class RampAnimator<T> {
|
|||||||
private float mCurrentValue;
|
private float mCurrentValue;
|
||||||
private float mTargetValue;
|
private float mTargetValue;
|
||||||
private float mRate;
|
private float mRate;
|
||||||
|
private float mAnimationIncreaseMaxTimeSecs;
|
||||||
|
private float mAnimationDecreaseMaxTimeSecs;
|
||||||
|
|
||||||
private boolean mAnimating;
|
private boolean mAnimating;
|
||||||
private float mAnimatedValue; // higher precision copy of mCurrentValue
|
private float mAnimatedValue; // higher precision copy of mCurrentValue
|
||||||
@@ -43,12 +45,23 @@ class RampAnimator<T> {
|
|||||||
|
|
||||||
private Listener mListener;
|
private Listener mListener;
|
||||||
|
|
||||||
public RampAnimator(T object, FloatProperty<T> property) {
|
RampAnimator(T object, FloatProperty<T> property) {
|
||||||
mObject = object;
|
mObject = object;
|
||||||
mProperty = property;
|
mProperty = property;
|
||||||
mChoreographer = Choreographer.getInstance();
|
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.
|
* Starts animating towards the specified value.
|
||||||
*
|
*
|
||||||
@@ -83,6 +96,15 @@ class RampAnimator<T> {
|
|||||||
return false;
|
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.
|
// Adjust the rate based on the closest target.
|
||||||
// If a faster rate is specified, then use the new rate so that we converge
|
// If a faster rate is specified, then use the new rate so that we converge
|
||||||
// more rapidly based on the new request.
|
// more rapidly based on the new request.
|
||||||
@@ -208,6 +230,17 @@ class RampAnimator<T> {
|
|||||||
mSecond.setListener(mInternalListener);
|
mSecond.setListener(mInternalListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Starts animating towards the specified values.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -57,6 +57,16 @@
|
|||||||
<xs:element type="nonNegativeDecimal" name="screenBrightnessRampSlowIncrease">
|
<xs:element type="nonNegativeDecimal" name="screenBrightnessRampSlowIncrease">
|
||||||
<xs:annotation name="final"/>
|
<xs:annotation name="final"/>
|
||||||
</xs:element>
|
</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:element type="sensorDetails" name="lightSensor">
|
||||||
<xs:annotation name="final"/>
|
<xs:annotation name="final"/>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -48,8 +48,10 @@ package com.android.server.display.config {
|
|||||||
method public com.android.server.display.config.DisplayQuirks getQuirks();
|
method public com.android.server.display.config.DisplayQuirks getQuirks();
|
||||||
method @NonNull public final java.math.BigDecimal getScreenBrightnessDefault();
|
method @NonNull public final java.math.BigDecimal getScreenBrightnessDefault();
|
||||||
method @NonNull public final com.android.server.display.config.NitsMap getScreenBrightnessMap();
|
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 getScreenBrightnessRampFastDecrease();
|
||||||
method public final java.math.BigDecimal getScreenBrightnessRampFastIncrease();
|
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 getScreenBrightnessRampSlowDecrease();
|
||||||
method public final java.math.BigDecimal getScreenBrightnessRampSlowIncrease();
|
method public final java.math.BigDecimal getScreenBrightnessRampSlowIncrease();
|
||||||
method @NonNull public final com.android.server.display.config.ThermalThrottling getThermalThrottling();
|
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 void setQuirks(com.android.server.display.config.DisplayQuirks);
|
||||||
method public final void setScreenBrightnessDefault(@NonNull java.math.BigDecimal);
|
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 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 setScreenBrightnessRampFastDecrease(java.math.BigDecimal);
|
||||||
method public final void setScreenBrightnessRampFastIncrease(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 setScreenBrightnessRampSlowDecrease(java.math.BigDecimal);
|
||||||
method public final void setScreenBrightnessRampSlowIncrease(java.math.BigDecimal);
|
method public final void setScreenBrightnessRampSlowIncrease(java.math.BigDecimal);
|
||||||
method public final void setThermalThrottling(@NonNull com.android.server.display.config.ThermalThrottling);
|
method public final void setThermalThrottling(@NonNull com.android.server.display.config.ThermalThrottling);
|
||||||
|
|||||||
Reference in New Issue
Block a user