livedisplay: Always check for transition
* If the device is started in the middle of a transition period, the transition would not occur. Always check for this condition instead of only firing it when TwilightService updates. Change-Id: Ibe6cfa69506ffc6a9bf6390ee7e13863f275ec2a
This commit is contained in:
parent
b00c945e35
commit
7a4fed9640
@ -48,8 +48,6 @@ public class ColorTemperatureController extends LiveDisplayFeature {
|
||||
private int mDayTemperature;
|
||||
private int mNightTemperature;
|
||||
|
||||
private boolean mTransitioning = false;
|
||||
|
||||
private static final long TWILIGHT_ADJUSTMENT_TIME = DateUtils.HOUR_IN_MILLIS * 1;
|
||||
|
||||
private static final Uri DISPLAY_TEMPERATURE_DAY =
|
||||
@ -99,7 +97,7 @@ public class ColorTemperatureController extends LiveDisplayFeature {
|
||||
@Override
|
||||
protected void onScreenStateChanged() {
|
||||
// pause/continue transition
|
||||
if (mTransitioning) {
|
||||
if (isTransitioning()) {
|
||||
if (isScreenOn()) {
|
||||
mHandler.post(mTransitionRunnable);
|
||||
} else {
|
||||
@ -133,27 +131,22 @@ public class ColorTemperatureController extends LiveDisplayFeature {
|
||||
pw.println();
|
||||
pw.println(" ColorTemperatureController State:");
|
||||
pw.println(" mColorTemperature=" + mColorTemperature);
|
||||
pw.println(" mTransitioning=" + mTransitioning);
|
||||
pw.println(" isTransitioning=" + isTransitioning());
|
||||
}
|
||||
|
||||
private final Runnable mTransitionRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (ColorTemperatureController.this) {
|
||||
updateColorTemperature();
|
||||
|
||||
mTransitioning = getMode() == MODE_AUTO &&
|
||||
mColorTemperature != mDayTemperature &&
|
||||
mColorTemperature != mNightTemperature;
|
||||
|
||||
if (mTransitioning) {
|
||||
// fire again in a minute
|
||||
mHandler.postDelayed(mTransitionRunnable, DateUtils.MINUTE_IN_MILLIS);
|
||||
}
|
||||
}
|
||||
updateColorTemperature();
|
||||
}
|
||||
};
|
||||
|
||||
private boolean isTransitioning() {
|
||||
return getMode() == MODE_AUTO &&
|
||||
mColorTemperature != mDayTemperature &&
|
||||
mColorTemperature != mNightTemperature;
|
||||
}
|
||||
|
||||
private synchronized void updateColorTemperature() {
|
||||
if (!mUseTemperatureAdjustment || !isScreenOn()) {
|
||||
return;
|
||||
@ -175,6 +168,11 @@ public class ColorTemperatureController extends LiveDisplayFeature {
|
||||
}
|
||||
|
||||
setDisplayTemperature(temperature);
|
||||
|
||||
if (isTransitioning()) {
|
||||
// fire again in a minute
|
||||
mHandler.postDelayed(mTransitionRunnable, DateUtils.MINUTE_IN_MILLIS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user