From a7d4dff90240873f9321b44e99319cc0a1f028a8 Mon Sep 17 00:00:00 2001 From: Paul Keith Date: Tue, 2 Oct 2018 21:43:51 +0200 Subject: [PATCH] sdk: Split TWILIGHT_ADJUSTMENT_TIME in half * The difference between civil and actual sun{rise,set} is 6 degrees of movement of the Sun in its path in the sky, astronomically speaking * Since the Sun "travels" at 15 degrees/hr in the sky, that means the difference between civil and actual sun{rise,set} is about 24 minutes, temporally speaking * In order to more closely match that temporal difference, the TWILIGHT_ADJUSTMENT_TIME should be about 30 minutes Change-Id: I30a600c71ce5dd01fcb96fb4f5108f45fa493b0c --- .../internal/display/ColorTemperatureController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lineage/lib/main/java/org/lineageos/platform/internal/display/ColorTemperatureController.java b/lineage/lib/main/java/org/lineageos/platform/internal/display/ColorTemperatureController.java index 27b86d9a..40bc681f 100644 --- a/lineage/lib/main/java/org/lineageos/platform/internal/display/ColorTemperatureController.java +++ b/lineage/lib/main/java/org/lineageos/platform/internal/display/ColorTemperatureController.java @@ -62,7 +62,7 @@ public class ColorTemperatureController extends LiveDisplayFeature { private final LineageHardwareManager mHardware; - private static final long TWILIGHT_ADJUSTMENT_TIME = DateUtils.HOUR_IN_MILLIS * 1; + private static final long TWILIGHT_ADJUSTMENT_TIME = DateUtils.HOUR_IN_MILLIS / 2; private static final Uri DISPLAY_TEMPERATURE_DAY = LineageSettings.System.getUriFor(LineageSettings.System.DISPLAY_TEMPERATURE_DAY); @@ -295,21 +295,21 @@ public class ColorTemperatureController extends LiveDisplayFeature { if (sunset < 0 || sunrise < 0 || now < (sunset - TWILIGHT_ADJUSTMENT_TIME) || now > (sunrise + TWILIGHT_ADJUSTMENT_TIME)) { - // More than 1hr after civil sunrise or before civil sunset + // More than 0.5hr after civil sunrise or before civil sunset return 1.0f; } - // Scale the transition into night mode in 1hr before civil sunset + // Scale the transition into night mode in 0.5hr before civil sunset if (now <= sunset) { return (float) (sunset - now) / TWILIGHT_ADJUSTMENT_TIME; } - // Scale the transition into day mode in 1hr after civil sunrise + // Scale the transition into day mode in 0.5hr after civil sunrise if (now >= sunrise) { return (float) (now - sunrise) / TWILIGHT_ADJUSTMENT_TIME; } - // More than 1hr past civil sunset + // More than 0.5hr past civil sunset return 0.0f; }