Merge "Stop RBC affecting brightness so drastically" into sc-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6be9887cb9
@@ -125,6 +125,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
private static final int MSG_IGNORE_PROXIMITY = 8;
|
private static final int MSG_IGNORE_PROXIMITY = 8;
|
||||||
private static final int MSG_STOP = 9;
|
private static final int MSG_STOP = 9;
|
||||||
private static final int MSG_UPDATE_BRIGHTNESS = 10;
|
private static final int MSG_UPDATE_BRIGHTNESS = 10;
|
||||||
|
private static final int MSG_UPDATE_RBC = 11;
|
||||||
|
|
||||||
private static final int PROXIMITY_UNKNOWN = -1;
|
private static final int PROXIMITY_UNKNOWN = -1;
|
||||||
private static final int PROXIMITY_NEGATIVE = 0;
|
private static final int PROXIMITY_NEGATIVE = 0;
|
||||||
@@ -422,13 +423,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
// PowerManager.BRIGHTNESS_INVALID_FLOAT when there's no temporary adjustment set.
|
// PowerManager.BRIGHTNESS_INVALID_FLOAT when there's no temporary adjustment set.
|
||||||
private float mTemporaryAutoBrightnessAdjustment;
|
private float mTemporaryAutoBrightnessAdjustment;
|
||||||
|
|
||||||
// Whether a reduce bright colors (rbc) change has been initiated by the user. We want to
|
// Whether reduce bright colors (rbc) has been turned on, or a change in strength has been
|
||||||
// retain the current backlight level when rbc is toggled, since rbc additionally makes the
|
// requested. We want to retain the current backlight level when rbc is toggled, since rbc
|
||||||
// screen appear dimmer using screen colors rather than backlight levels, and therefore we
|
// additionally makes the screen appear dimmer using screen colors rather than backlight levels,
|
||||||
// don't actually want to compensate for this by then in/decreasing the backlight when
|
// and therefore we don't actually want to compensate for this by then in/decreasing the
|
||||||
// toggling this feature.
|
// backlight when toggling this feature.
|
||||||
// This should be false during system start up.
|
// This should be false during system start up.
|
||||||
private boolean mPendingUserRbcChange;
|
private boolean mPendingRbcOnOrChanged = false;
|
||||||
|
|
||||||
// Animators.
|
// Animators.
|
||||||
private ObjectAnimator mColorFadeOnAnimator;
|
private ObjectAnimator mColorFadeOnAnimator;
|
||||||
@@ -564,23 +565,35 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
@Override
|
@Override
|
||||||
public void onReduceBrightColorsActivationChanged(boolean activated,
|
public void onReduceBrightColorsActivationChanged(boolean activated,
|
||||||
boolean userInitiated) {
|
boolean userInitiated) {
|
||||||
applyReduceBrightColorsSplineAdjustment(userInitiated);
|
applyReduceBrightColorsSplineAdjustment(
|
||||||
|
/* rbcStrengthChanged= */ false, activated);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReduceBrightColorsStrengthChanged(int strength) {
|
public void onReduceBrightColorsStrengthChanged(int strength) {
|
||||||
applyReduceBrightColorsSplineAdjustment(/*userInitiated*/ false);
|
applyReduceBrightColorsSplineAdjustment(
|
||||||
|
/* rbcStrengthChanged= */ true, /* justActivated= */ false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (active) {
|
if (active) {
|
||||||
applyReduceBrightColorsSplineAdjustment(/*userInitiated*/ false);
|
applyReduceBrightColorsSplineAdjustment(
|
||||||
|
/* rbcStrengthChanged= */ false, /* justActivated= */ false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mCdsi = null;
|
mCdsi = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyReduceBrightColorsSplineAdjustment(boolean userInitiated) {
|
private void applyReduceBrightColorsSplineAdjustment(
|
||||||
|
boolean rbcStrengthChanged, boolean justActivated) {
|
||||||
|
final int strengthChanged = rbcStrengthChanged ? 1 : 0;
|
||||||
|
final int activated = justActivated ? 1 : 0;
|
||||||
|
mHandler.obtainMessage(MSG_UPDATE_RBC, strengthChanged, activated).sendToTarget();
|
||||||
|
sendUpdatePowerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleRbcChanged(boolean strengthChanged, boolean justActivated) {
|
||||||
if (mBrightnessMapper == null) {
|
if (mBrightnessMapper == null) {
|
||||||
Log.w(TAG, "No brightness mapping available to recalculate splines");
|
Log.w(TAG, "No brightness mapping available to recalculate splines");
|
||||||
return;
|
return;
|
||||||
@@ -591,8 +604,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
adjustedNits[i] = mCdsi.getReduceBrightColorsAdjustedBrightnessNits(mNitsRange[i]);
|
adjustedNits[i] = mCdsi.getReduceBrightColorsAdjustedBrightnessNits(mNitsRange[i]);
|
||||||
}
|
}
|
||||||
mBrightnessMapper.recalculateSplines(mCdsi.isReduceBrightColorsActivated(), adjustedNits);
|
mBrightnessMapper.recalculateSplines(mCdsi.isReduceBrightColorsActivated(), adjustedNits);
|
||||||
mPendingUserRbcChange = userInitiated;
|
|
||||||
sendUpdatePowerState();
|
mPendingRbcOnOrChanged = strengthChanged || justActivated;
|
||||||
|
|
||||||
|
// Reset model if strength changed OR rbc is turned off
|
||||||
|
if (strengthChanged || !justActivated && mAutomaticBrightnessController != null) {
|
||||||
|
mAutomaticBrightnessController.resetShortTermModel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -926,7 +944,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
|
|
||||||
private void reloadReduceBrightColours() {
|
private void reloadReduceBrightColours() {
|
||||||
if (mCdsi != null && mCdsi.isReduceBrightColorsActivated()) {
|
if (mCdsi != null && mCdsi.isReduceBrightColorsActivated()) {
|
||||||
applyReduceBrightColorsSplineAdjustment(/*userInitiated*/ false);
|
applyReduceBrightColorsSplineAdjustment(
|
||||||
|
/* rbcStrengthChanged= */ false, /* justActivated= */ false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2072,21 +2091,24 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We want to return true if the user has set the screen brightness.
|
||||||
|
// If they have just turned RBC on (and therefore added that interaction to the curve),
|
||||||
|
// or changed the brightness another way, then we should return true.
|
||||||
private boolean updateUserSetScreenBrightness() {
|
private boolean updateUserSetScreenBrightness() {
|
||||||
final boolean brightnessSplineChanged = mPendingUserRbcChange;
|
final boolean treatAsIfUserChanged = mPendingRbcOnOrChanged;
|
||||||
if (mPendingUserRbcChange && !Float.isNaN(mCurrentScreenBrightnessSetting)) {
|
if (treatAsIfUserChanged && !Float.isNaN(mCurrentScreenBrightnessSetting)) {
|
||||||
mLastUserSetScreenBrightness = mCurrentScreenBrightnessSetting;
|
mLastUserSetScreenBrightness = mCurrentScreenBrightnessSetting;
|
||||||
}
|
}
|
||||||
mPendingUserRbcChange = false;
|
mPendingRbcOnOrChanged = false;
|
||||||
|
|
||||||
if ((Float.isNaN(mPendingScreenBrightnessSetting)
|
if ((Float.isNaN(mPendingScreenBrightnessSetting)
|
||||||
|| mPendingScreenBrightnessSetting < 0.0f)) {
|
|| mPendingScreenBrightnessSetting < 0.0f)) {
|
||||||
return brightnessSplineChanged;
|
return treatAsIfUserChanged;
|
||||||
}
|
}
|
||||||
if (mCurrentScreenBrightnessSetting == mPendingScreenBrightnessSetting) {
|
if (mCurrentScreenBrightnessSetting == mPendingScreenBrightnessSetting) {
|
||||||
mPendingScreenBrightnessSetting = PowerManager.BRIGHTNESS_INVALID_FLOAT;
|
mPendingScreenBrightnessSetting = PowerManager.BRIGHTNESS_INVALID_FLOAT;
|
||||||
mTemporaryScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT;
|
mTemporaryScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT;
|
||||||
return brightnessSplineChanged;
|
return treatAsIfUserChanged;
|
||||||
}
|
}
|
||||||
setCurrentScreenBrightness(mPendingScreenBrightnessSetting);
|
setCurrentScreenBrightness(mPendingScreenBrightnessSetting);
|
||||||
mLastUserSetScreenBrightness = mPendingScreenBrightnessSetting;
|
mLastUserSetScreenBrightness = mPendingScreenBrightnessSetting;
|
||||||
@@ -2428,6 +2450,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
}
|
}
|
||||||
handleSettingsChange(false /*userSwitch*/);
|
handleSettingsChange(false /*userSwitch*/);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MSG_UPDATE_RBC:
|
||||||
|
final int strengthChanged = msg.arg1;
|
||||||
|
final int justActivated = msg.arg2;
|
||||||
|
handleRbcChanged(strengthChanged == 1, justActivated == 1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user