diff options
author | Steve Kondik <steve@cyngn.com> | 2016-04-21 20:40:37 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-04-21 20:45:32 -0700 |
commit | 7a4fed964039231e3f8ede0e7835c3294b93d129 (patch) | |
tree | aa67c8180cfddcb0e87cfcfc5d82077db7c08179 /cm/lib | |
parent | b00c945e35d1c4968b4e91b090498f0619378a6f (diff) | |
download | vendor_cmsdk-7a4fed964039231e3f8ede0e7835c3294b93d129.zip vendor_cmsdk-7a4fed964039231e3f8ede0e7835c3294b93d129.tar.gz vendor_cmsdk-7a4fed964039231e3f8ede0e7835c3294b93d129.tar.bz2 |
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
Diffstat (limited to 'cm/lib')
-rw-r--r-- | cm/lib/main/java/org/cyanogenmod/platform/internal/display/ColorTemperatureController.java | 30 |
1 files changed, 14 insertions, 16 deletions
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); + } } |