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
This commit is contained in:
Paul Keith
2018-10-02 21:43:51 +02:00
parent bd9f127ef8
commit a7d4dff902

View File

@@ -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;
}