From 7a4fed964039231e3f8ede0e7835c3294b93d129 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Thu, 21 Apr 2016 20:40:37 -0700 Subject: 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 --- .../display/ColorTemperatureController.java | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'cm/lib/main/java') diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/ColorTemperatureController.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/ColorTemperatureController.java index 2874e74..d20c002 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/ColorTemperatureController.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/ColorTemperatureController.java @@ -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); + } } -- cgit v1.1