Merge "Don't pass non slider adj. as user interactions" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e319ba691a
@@ -446,14 +446,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// PowerManager.BRIGHTNESS_INVALID_FLOAT when there's no temporary adjustment set.
|
||||
private float mTemporaryAutoBrightnessAdjustment;
|
||||
|
||||
// Whether reduce bright colors (rbc) has been turned on, or a change in strength has been
|
||||
// requested. We want to retain the current backlight level when rbc is toggled, since rbc
|
||||
// additionally makes the screen appear dimmer using screen colors rather than backlight levels,
|
||||
// and therefore we don't actually want to compensate for this by then in/decreasing the
|
||||
// backlight when toggling this feature.
|
||||
// This should be false during system start up.
|
||||
private boolean mPendingRbcOnOrChanged = false;
|
||||
|
||||
// Animators.
|
||||
private ObjectAnimator mColorFadeOnAnimator;
|
||||
private ObjectAnimator mColorFadeOffAnimator;
|
||||
@@ -572,20 +564,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
@Override
|
||||
public void onReduceBrightColorsActivationChanged(boolean activated,
|
||||
boolean userInitiated) {
|
||||
applyReduceBrightColorsSplineAdjustment(
|
||||
/* rbcStrengthChanged= */ false, activated);
|
||||
applyReduceBrightColorsSplineAdjustment();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReduceBrightColorsStrengthChanged(int strength) {
|
||||
applyReduceBrightColorsSplineAdjustment(
|
||||
/* rbcStrengthChanged= */ true, /* justActivated= */ false);
|
||||
applyReduceBrightColorsSplineAdjustment();
|
||||
}
|
||||
});
|
||||
if (active) {
|
||||
applyReduceBrightColorsSplineAdjustment(
|
||||
/* rbcStrengthChanged= */ false, /* justActivated= */ false);
|
||||
applyReduceBrightColorsSplineAdjustment();
|
||||
}
|
||||
} else {
|
||||
mCdsi = null;
|
||||
@@ -615,15 +604,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
private void applyReduceBrightColorsSplineAdjustment() {
|
||||
mHandler.obtainMessage(MSG_UPDATE_RBC).sendToTarget();
|
||||
sendUpdatePowerState();
|
||||
}
|
||||
|
||||
private void handleRbcChanged(boolean strengthChanged, boolean justActivated) {
|
||||
private void handleRbcChanged() {
|
||||
if (mAutomaticBrightnessController == null) {
|
||||
return;
|
||||
}
|
||||
@@ -642,12 +628,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mAutomaticBrightnessController.recalculateSplines(mCdsi.isReduceBrightColorsActivated(),
|
||||
adjustedNits);
|
||||
|
||||
mPendingRbcOnOrChanged = strengthChanged || justActivated;
|
||||
|
||||
// Reset model if strength changed OR rbc is turned off
|
||||
if ((strengthChanged || !justActivated) && mAutomaticBrightnessController != null) {
|
||||
mAutomaticBrightnessController.resetShortTermModel();
|
||||
}
|
||||
// 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
|
||||
// invalidated.
|
||||
mAutomaticBrightnessController.resetShortTermModel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1019,8 +1005,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
|
||||
private void reloadReduceBrightColours() {
|
||||
if (mCdsi != null && mCdsi.isReduceBrightColorsActivated()) {
|
||||
applyReduceBrightColorsSplineAdjustment(
|
||||
/* rbcStrengthChanged= */ false, /* justActivated= */ false);
|
||||
applyReduceBrightColorsSplineAdjustment();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2285,23 +2270,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
}
|
||||
|
||||
// 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.
|
||||
// RBC on, off, and intensity changes will return false.
|
||||
// Slider interactions whilst in RBC will return true, just as when in non-rbc.
|
||||
private boolean updateUserSetScreenBrightness() {
|
||||
final boolean treatAsIfUserChanged = mPendingRbcOnOrChanged;
|
||||
if (treatAsIfUserChanged && !Float.isNaN(mCurrentScreenBrightnessSetting)) {
|
||||
mLastUserSetScreenBrightness = mCurrentScreenBrightnessSetting;
|
||||
}
|
||||
mPendingRbcOnOrChanged = false;
|
||||
|
||||
if ((Float.isNaN(mPendingScreenBrightnessSetting)
|
||||
|| mPendingScreenBrightnessSetting < 0.0f)) {
|
||||
return treatAsIfUserChanged;
|
||||
return false;
|
||||
}
|
||||
if (mCurrentScreenBrightnessSetting == mPendingScreenBrightnessSetting) {
|
||||
mPendingScreenBrightnessSetting = PowerManager.BRIGHTNESS_INVALID_FLOAT;
|
||||
mTemporaryScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT;
|
||||
return treatAsIfUserChanged;
|
||||
return false;
|
||||
}
|
||||
setCurrentScreenBrightness(mPendingScreenBrightnessSetting);
|
||||
mLastUserSetScreenBrightness = mPendingScreenBrightnessSetting;
|
||||
@@ -2691,9 +2670,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
break;
|
||||
|
||||
case MSG_UPDATE_RBC:
|
||||
final int strengthChanged = msg.arg1;
|
||||
final int justActivated = msg.arg2;
|
||||
handleRbcChanged(strengthChanged == 1, justActivated == 1);
|
||||
handleRbcChanged();
|
||||
break;
|
||||
|
||||
case MSG_BRIGHTNESS_RAMP_DONE:
|
||||
|
||||
Reference in New Issue
Block a user