aboutsummaryrefslogtreecommitdiffstats
path: root/cm/lib/main/java/org/cyanogenmod/platform/internal/display/AmbientLuxObserver.java
diff options
context:
space:
mode:
Diffstat (limited to 'cm/lib/main/java/org/cyanogenmod/platform/internal/display/AmbientLuxObserver.java')
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/display/AmbientLuxObserver.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/AmbientLuxObserver.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/AmbientLuxObserver.java
index bf1e85e..f0d67aa 100644
--- a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/AmbientLuxObserver.java
+++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/AmbientLuxObserver.java
@@ -38,6 +38,7 @@ public class AmbientLuxObserver {
private final SensorManager mSensorManager;
private final float mThresholdLux;
+ private final float mHysteresisLux;
private final int mThresholdDuration;
private boolean mLightSensorEnabled = false;
@@ -61,9 +62,10 @@ public class AmbientLuxObserver {
}
public AmbientLuxObserver(Context context, Looper looper,
- float thresholdLux, int thresholdDuration) {
+ float thresholdLux, float hysteresisLux, int thresholdDuration) {
mLuxHandler = new AmbientLuxHandler(looper);
mThresholdLux = thresholdLux;
+ mHysteresisLux = hysteresisLux;
mThresholdDuration = thresholdDuration;
mRingBuffer = new TimedMovingAverageRingBuffer(thresholdDuration);
@@ -103,7 +105,9 @@ public class AmbientLuxObserver {
" mAmbientLux=" + mAmbientLux);
}
- direction = mAmbientLux >= mThresholdLux ? HIGH : LOW;
+ final float threshold = mState == HIGH
+ ? mThresholdLux - mHysteresisLux : mThresholdLux;
+ direction = mAmbientLux >= threshold ? HIGH : LOW;
if (mState != direction) {
mState = direction;
if (mCallback != null) {