From 19005b2e9a56a4293f7c7c30e12344b8ab5b519f Mon Sep 17 00:00:00 2001 From: Simon1511 Date: Mon, 17 Jul 2023 16:05:13 +0200 Subject: [PATCH] sm7125-common: fingerprint: prevent unnwanted onFingerUp() calls * onFingerUp() would also be called during unlocking with Pin/Password/etc, always resetting the brightness to the previous value Change-Id: I5319a8a50a4ad3308e787322c6c2a417b9169b23 --- fingerprint/BiometricsFingerprint.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fingerprint/BiometricsFingerprint.cpp b/fingerprint/BiometricsFingerprint.cpp index 7316ad1..732f697 100644 --- a/fingerprint/BiometricsFingerprint.cpp +++ b/fingerprint/BiometricsFingerprint.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef HAS_FINGERPRINT_GESTURES #include @@ -35,6 +36,7 @@ #define TSP_CMD_PATH "/sys/class/sec/tsp/cmd" #define HBM_PATH "/sys/class/lcd/panel/mask_brightness" +#define MASK_BRIGHTNESS_PATH "/sys/class/lcd/panel/actual_mask_brightness" namespace android { namespace hardware { @@ -53,6 +55,14 @@ static void set(const std::string& path, const T& value) { file << value; } +template +static T get(const std::string& path, const T& def) { + std::ifstream file(path); + T result; + file >> result; + return file.fail() ? def : result; +} + std::string getBootloader() { return android::base::GetProperty("ro.boot.bootloader", ""); } @@ -139,9 +149,11 @@ Return BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, floa } Return BiometricsFingerprint::onFingerUp() { - request(SEM_REQUEST_TOUCH_EVENT, FINGERPRINT_REQUEST_RESUME); + if (strcmp(get(MASK_BRIGHTNESS_PATH, "0").c_str(), "0") != 0) { + request(SEM_REQUEST_TOUCH_EVENT, FINGERPRINT_REQUEST_RESUME); - set(HBM_PATH, "0"); + set(HBM_PATH, "0"); + } return Void(); }