From 562f63234fa90e4ea2c79c06f77eaaa6c3b427fd Mon Sep 17 00:00:00 2001 From: Rituj Beniwal Date: Wed, 26 May 2021 17:31:31 +0530 Subject: [PATCH] sm8150-common: Apply ALS correction to the RAW sensor value * Probably a derp here https://github.com/LineageOS/android_device_oneplus_sm8150-common/commit/07c6e1a71fa7ef5ef58561c86097ef5e7ea10934 Signed-off-by: Rituj Beniwal --- sensors/AlsCorrection.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sensors/AlsCorrection.cpp b/sensors/AlsCorrection.cpp index 59094e43..2946a069 100644 --- a/sensors/AlsCorrection.cpp +++ b/sensors/AlsCorrection.cpp @@ -73,11 +73,13 @@ void AlsCorrection::correct(float& light) { correction = correction * (((float) screen_brightness) / ((float) max_brightness)); correction += als_bias; } - ALOGV("Final correction: %f", correction); // Sensor is not accurate for low values - if (light < correction) { + if (light - correction >= 0) { + light -= correction; + } else { light = correction; } + ALOGV("Corrected reading: %f", light); } } // namespace implementation