diff --git a/fingerprint/BiometricsFingerprint.cpp b/fingerprint/BiometricsFingerprint.cpp index 16e0342..d96a6cf 100644 --- a/fingerprint/BiometricsFingerprint.cpp +++ b/fingerprint/BiometricsFingerprint.cpp @@ -34,7 +34,7 @@ #define SEH_PARAM_RELEASED 1 #define SEH_AOSP_FQNAME "android.hardware.biometrics.fingerprint@2.3::IBiometricsFingerprint" #define TSP_CMD_PATH "/sys/class/sec/tsp/cmd" -#define BRIGHTNESS_PATH "/sys/class/backlight/panel0-backlight/brightness" +#define HBM_PATH "/sys/class/lcd/panel/mask_brightness" namespace vendor { namespace samsung { @@ -114,19 +114,14 @@ static hidl_vec stringToVec(const std::string& str) { } Return SehBiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, float) { - mPreviousBrightness = get(BRIGHTNESS_PATH, ""); - set(BRIGHTNESS_PATH, "331"); + std::thread([this]() { + std::this_thread::sleep_for(std::chrono::milliseconds(35)); + set(HBM_PATH, "331"); + }).detach(); sehRequest(SEH_FINGER_STATE, SEH_PARAM_PRESSED, stringToVec(SEH_AOSP_FQNAME), SehBiometricsFingerprint::requestResult); - std::thread([this]() { - std::this_thread::sleep_for(std::chrono::milliseconds(400)); - if (!mPreviousBrightness.empty()) { - set(BRIGHTNESS_PATH, mPreviousBrightness); - mPreviousBrightness = ""; - } - }).detach(); return Void(); } @@ -134,6 +129,8 @@ Return SehBiometricsFingerprint::onFingerUp() { sehRequest(SEH_FINGER_STATE, SEH_PARAM_RELEASED, stringToVec(SEH_AOSP_FQNAME), SehBiometricsFingerprint::requestResult); + set(HBM_PATH, "0"); + return Void(); } @@ -402,6 +399,9 @@ void SehBiometricsFingerprint::notify(const fingerprint_msg_t* msg) { } } break; case FINGERPRINT_TEMPLATE_ENROLLING: + if(msg->data.enroll.samples_remaining == 0) { + set(HBM_PATH, "0"); + } LOG(DEBUG) << "onEnrollResult(fid=" << msg->data.enroll.finger.fid << ", gid=" << msg->data.enroll.finger.gid << ", rem=" << msg->data.enroll.samples_remaining << ")"; @@ -434,6 +434,7 @@ void SehBiometricsFingerprint::notify(const fingerprint_msg_t* msg) { const uint8_t* hat = reinterpret_cast(&msg->data.authenticated.hat); const hidl_vec token( std::vector(hat, hat + sizeof(msg->data.authenticated.hat))); + set(HBM_PATH, "0"); if (!thisPtr->mClientCallback ->onAuthenticated(devId, msg->data.authenticated.finger.fid, msg->data.authenticated.finger.gid, token) diff --git a/fingerprint/BiometricsFingerprint.h b/fingerprint/BiometricsFingerprint.h index c76788b..e2d8868 100644 --- a/fingerprint/BiometricsFingerprint.h +++ b/fingerprint/BiometricsFingerprint.h @@ -99,8 +99,6 @@ public: int (*ss_fingerprint_request)(int32_t cmd_id, const int8_t* inputBuf, uint32_t value, int8_t* outBuf, uint32_t len, uint32_t inParam); static void requestResult(int retval, const hidl_vec& outBuf); - std::string mPreviousBrightness; - }; } // namespace implementation diff --git a/sepolicy/vendor/hal_fingerprint_default.te b/sepolicy/vendor/hal_fingerprint_default.te index 35969bf..6eb8ef8 100644 --- a/sepolicy/vendor/hal_fingerprint_default.te +++ b/sepolicy/vendor/hal_fingerprint_default.te @@ -12,12 +12,9 @@ allow hal_fingerprint_default biometrics_efs_file:file r_file_perms; allow hal_fingerprint_default biometrics_efs_file:dir search; allow hal_fingerprint_default efs_file:dir search; -# /sys/class/backlight/panel0-backlight/ +# /sys/class/lcd/panel/mask_brightness allow hal_fingerprint_default sysfs_lcd_writable:dir search; -allow hal_fingerprint_default sysfs_lcd_writable:file r_file_perms; - -allow hal_fingerprint_default vendor_sysfs_graphics:dir r_dir_perms; -allow hal_fingerprint_default vendor_sysfs_graphics:file rw_file_perms; +allow hal_fingerprint_default sysfs_lcd_writable:file rw_file_perms; # /sys/class/fingerprint/ allow hal_fingerprint_default sysfs_fingerprint:dir r_dir_perms;