Merge "Make Brightness Ramp Speeds Configurable"
This commit is contained in:
committed by
Android (Google) Code Review
commit
fb2f95b830
@@ -24,6 +24,7 @@ import android.util.Slog;
|
||||
import android.view.DisplayAddress;
|
||||
|
||||
import com.android.internal.BrightnessSynchronizer;
|
||||
import com.android.internal.R;
|
||||
import com.android.server.display.config.DisplayConfiguration;
|
||||
import com.android.server.display.config.DisplayQuirks;
|
||||
import com.android.server.display.config.HbmTiming;
|
||||
@@ -64,6 +65,7 @@ public class DisplayDeviceConfig {
|
||||
private static final String STABLE_ID_SUFFIX_FORMAT = "id_%d";
|
||||
private static final String NO_SUFFIX_FORMAT = "%d";
|
||||
private static final long STABLE_FLAG = 1L << 62;
|
||||
|
||||
// Float.NaN (used as invalid for brightness) cannot be stored in config.xml
|
||||
// so -2 is used instead
|
||||
private static final float INVALID_BRIGHTNESS_IN_CONFIG = -2f;
|
||||
@@ -75,6 +77,10 @@ public class DisplayDeviceConfig {
|
||||
private float mBrightnessMinimum = Float.NaN;
|
||||
private float mBrightnessMaximum = Float.NaN;
|
||||
private float mBrightnessDefault = Float.NaN;
|
||||
private float mBrightnessRampFastDecrease = Float.NaN;
|
||||
private float mBrightnessRampFastIncrease = Float.NaN;
|
||||
private float mBrightnessRampSlowDecrease = Float.NaN;
|
||||
private float mBrightnessRampSlowIncrease = Float.NaN;
|
||||
private List<String> mQuirks;
|
||||
private boolean mIsHighBrightnessModeEnabled = false;
|
||||
private HighBrightnessModeData mHbmData;
|
||||
@@ -177,6 +183,22 @@ public class DisplayDeviceConfig {
|
||||
return mBrightnessDefault;
|
||||
}
|
||||
|
||||
public float getBrightnessRampFastDecrease() {
|
||||
return mBrightnessRampFastDecrease;
|
||||
}
|
||||
|
||||
public float getBrightnessRampFastIncrease() {
|
||||
return mBrightnessRampFastIncrease;
|
||||
}
|
||||
|
||||
public float getBrightnessRampSlowDecrease() {
|
||||
return mBrightnessRampSlowDecrease;
|
||||
}
|
||||
|
||||
public float getBrightnessRampSlowIncrease() {
|
||||
return mBrightnessRampSlowIncrease;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param quirkValue The quirk to test.
|
||||
* @return {@code true} if the specified quirk is present in this configuration,
|
||||
@@ -210,6 +232,10 @@ public class DisplayDeviceConfig {
|
||||
+ ", mQuirks=" + mQuirks
|
||||
+ ", isHbmEnabled=" + mIsHighBrightnessModeEnabled
|
||||
+ ", mHbmData=" + mHbmData
|
||||
+ ", mBrightnessRampFastDecrease=" + mBrightnessRampFastDecrease
|
||||
+ ", mBrightnessRampFastIncrease=" + mBrightnessRampFastIncrease
|
||||
+ ", mBrightnessRampSlowDecrease=" + mBrightnessRampSlowDecrease
|
||||
+ ", mBrightnessRampSlowIncrease=" + mBrightnessRampSlowIncrease
|
||||
+ "}";
|
||||
return str;
|
||||
}
|
||||
@@ -265,6 +291,7 @@ public class DisplayDeviceConfig {
|
||||
loadBrightnessConstraintsFromConfigXml();
|
||||
loadHighBrightnessModeData(config);
|
||||
loadQuirks(config);
|
||||
loadBrightnessRamps(config);
|
||||
} else {
|
||||
Slog.w(TAG, "DisplayDeviceConfig file is null");
|
||||
}
|
||||
@@ -278,6 +305,7 @@ public class DisplayDeviceConfig {
|
||||
// If no ddc exists, use config.xml
|
||||
loadBrightnessDefaultFromConfigXml();
|
||||
loadBrightnessConstraintsFromConfigXml();
|
||||
loadBrightnessRampsFromConfigXml();
|
||||
}
|
||||
|
||||
private void initFromPmValues() {
|
||||
@@ -397,6 +425,41 @@ public class DisplayDeviceConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBrightnessRamps(DisplayConfiguration config) {
|
||||
// Priority 1: Value in the display device config (float)
|
||||
// Priority 2: Value in the config.xml (int)
|
||||
final BigDecimal fastDownDecimal = config.getScreenBrightnessRampFastDecrease();
|
||||
final BigDecimal fastUpDecimal = config.getScreenBrightnessRampFastIncrease();
|
||||
final BigDecimal slowDownDecimal = config.getScreenBrightnessRampSlowDecrease();
|
||||
final BigDecimal slowUpDecimal = config.getScreenBrightnessRampSlowIncrease();
|
||||
|
||||
if (fastDownDecimal != null && fastUpDecimal != null && slowDownDecimal != null
|
||||
&& slowUpDecimal != null) {
|
||||
mBrightnessRampFastDecrease = fastDownDecimal.floatValue();
|
||||
mBrightnessRampFastIncrease = fastUpDecimal.floatValue();
|
||||
mBrightnessRampSlowDecrease = slowDownDecimal.floatValue();
|
||||
mBrightnessRampSlowIncrease = slowUpDecimal.floatValue();
|
||||
} else {
|
||||
if (fastDownDecimal != null || fastUpDecimal != null || slowDownDecimal != null
|
||||
|| slowUpDecimal != null) {
|
||||
Slog.w(TAG, "Per display brightness ramp values ignored because not all "
|
||||
+ "values are present in display device config");
|
||||
}
|
||||
loadBrightnessRampsFromConfigXml();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBrightnessRampsFromConfigXml() {
|
||||
mBrightnessRampFastIncrease = BrightnessSynchronizer.brightnessIntToFloat(
|
||||
mContext.getResources().getInteger(R.integer.config_brightness_ramp_rate_fast));
|
||||
mBrightnessRampSlowIncrease = BrightnessSynchronizer.brightnessIntToFloat(
|
||||
mContext.getResources().getInteger(R.integer.config_brightness_ramp_rate_slow));
|
||||
// config.xml uses the same values for both increasing and decreasing brightness
|
||||
// transitions so we assign them to the same values here.
|
||||
mBrightnessRampFastDecrease = mBrightnessRampFastIncrease;
|
||||
mBrightnessRampSlowDecrease = mBrightnessRampSlowIncrease;
|
||||
}
|
||||
|
||||
/**
|
||||
* Container for high brightness mode configuration data.
|
||||
*/
|
||||
|
||||
@@ -331,8 +331,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
private BrightnessReason mBrightnessReasonTemp = new BrightnessReason();
|
||||
|
||||
// Brightness animation ramp rates in brightness units per second
|
||||
private final float mBrightnessRampRateSlow;
|
||||
private final float mBrightnessRampRateFast;
|
||||
private float mBrightnessRampRateFastDecrease;
|
||||
private float mBrightnessRampRateFastIncrease;
|
||||
private float mBrightnessRampRateSlowDecrease;
|
||||
private float mBrightnessRampRateSlowIncrease;
|
||||
|
||||
|
||||
// Whether or not to skip the initial brightness ramps into STATE_ON.
|
||||
@@ -459,10 +461,21 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mAllowAutoBrightnessWhileDozingConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_allowAutoBrightnessWhileDozing);
|
||||
|
||||
mBrightnessRampRateFast = BrightnessSynchronizer.brightnessIntToFloat(resources.getInteger(
|
||||
com.android.internal.R.integer.config_brightness_ramp_rate_fast));
|
||||
mBrightnessRampRateSlow = BrightnessSynchronizer.brightnessIntToFloat(resources.getInteger(
|
||||
com.android.internal.R.integer.config_brightness_ramp_rate_slow));
|
||||
|
||||
DisplayDeviceConfig displayDeviceConfig = logicalDisplay
|
||||
.getPrimaryDisplayDeviceLocked().getDisplayDeviceConfig();
|
||||
// TODO: (b/178183143) Ensure that the ddc is not null
|
||||
if (displayDeviceConfig != null) {
|
||||
mBrightnessRampRateFastDecrease = displayDeviceConfig.getBrightnessRampFastDecrease();
|
||||
mBrightnessRampRateFastIncrease = displayDeviceConfig.getBrightnessRampFastIncrease();
|
||||
mBrightnessRampRateSlowDecrease = displayDeviceConfig.getBrightnessRampSlowDecrease();
|
||||
mBrightnessRampRateSlowIncrease = displayDeviceConfig.getBrightnessRampSlowIncrease();
|
||||
} else {
|
||||
mBrightnessRampRateFastDecrease = 1.0f;
|
||||
mBrightnessRampRateFastIncrease = 1.0f;
|
||||
mBrightnessRampRateSlowDecrease = 1.0f;
|
||||
mBrightnessRampRateSlowIncrease = 1.0f;
|
||||
}
|
||||
mSkipScreenOnBrightnessRamp = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_skipScreenOnBrightnessRamp);
|
||||
|
||||
@@ -783,7 +796,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
boolean mustInitialize = false;
|
||||
int brightnessAdjustmentFlags = 0;
|
||||
mBrightnessReasonTemp.set(null);
|
||||
|
||||
synchronized (mLock) {
|
||||
mPendingUpdatePowerStateLocked = false;
|
||||
if (mPendingRequestLocked == null) {
|
||||
@@ -1122,13 +1134,25 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// user even when the display is all black.
|
||||
float animateValue = brightnessState == PowerManager.BRIGHTNESS_OFF_FLOAT
|
||||
? PowerManager.BRIGHTNESS_MIN : brightnessState;
|
||||
if (isValidBrightnessValue(animateValue)) {
|
||||
final float currentBrightness = mPowerState.getScreenBrightness();
|
||||
if (isValidBrightnessValue(animateValue)
|
||||
&& !BrightnessSynchronizer.floatEquals(animateValue, currentBrightness)) {
|
||||
if (initialRampSkip || hasBrightnessBuckets
|
||||
|| wasOrWillBeInVr || !isDisplayContentVisible || brightnessIsTemporary) {
|
||||
animateScreenBrightness(animateValue, SCREEN_ANIMATION_RATE_MINIMUM);
|
||||
} else {
|
||||
animateScreenBrightness(animateValue,
|
||||
slowChange ? mBrightnessRampRateSlow : mBrightnessRampRateFast);
|
||||
boolean isIncreasing = animateValue > currentBrightness;
|
||||
final float rampSpeed;
|
||||
if (isIncreasing && slowChange) {
|
||||
rampSpeed = mBrightnessRampRateSlowIncrease;
|
||||
} else if (isIncreasing && !slowChange) {
|
||||
rampSpeed = mBrightnessRampRateFastIncrease;
|
||||
} else if (!isIncreasing && slowChange) {
|
||||
rampSpeed = mBrightnessRampRateSlowDecrease;
|
||||
} else {
|
||||
rampSpeed = mBrightnessRampRateFastDecrease;
|
||||
}
|
||||
animateScreenBrightness(animateValue, rampSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,18 @@
|
||||
</xs:element>
|
||||
<xs:element type="highBrightnessMode" name="highBrightnessMode" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element type="displayQuirks" name="quirks" minOccurs="0" maxOccurs="1" />
|
||||
<xs:element type="nonNegativeDecimal" name="screenBrightnessRampFastDecrease">
|
||||
<xs:annotation name="final"/>
|
||||
</xs:element>
|
||||
<xs:element type="nonNegativeDecimal" name="screenBrightnessRampFastIncrease">
|
||||
<xs:annotation name="final"/>
|
||||
</xs:element>
|
||||
<xs:element type="nonNegativeDecimal" name="screenBrightnessRampSlowDecrease">
|
||||
<xs:annotation name="final"/>
|
||||
</xs:element>
|
||||
<xs:element type="nonNegativeDecimal" name="screenBrightnessRampSlowIncrease">
|
||||
<xs:annotation name="final"/>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -7,10 +7,18 @@ 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.BigDecimal getScreenBrightnessRampFastDecrease();
|
||||
method public final java.math.BigDecimal getScreenBrightnessRampFastIncrease();
|
||||
method public final java.math.BigDecimal getScreenBrightnessRampSlowDecrease();
|
||||
method public final java.math.BigDecimal getScreenBrightnessRampSlowIncrease();
|
||||
method public void setHighBrightnessMode(com.android.server.display.config.HighBrightnessMode);
|
||||
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 setScreenBrightnessRampFastDecrease(java.math.BigDecimal);
|
||||
method public final void setScreenBrightnessRampFastIncrease(java.math.BigDecimal);
|
||||
method public final void setScreenBrightnessRampSlowDecrease(java.math.BigDecimal);
|
||||
method public final void setScreenBrightnessRampSlowIncrease(java.math.BigDecimal);
|
||||
}
|
||||
|
||||
public class DisplayQuirks {
|
||||
|
||||
Reference in New Issue
Block a user