diff --git a/configs/properties/vendor.prop b/configs/properties/vendor.prop index 878fab0..5b800be 100644 --- a/configs/properties/vendor.prop +++ b/configs/properties/vendor.prop @@ -297,11 +297,8 @@ persist.vendor.dpm.vndr.idletimer.mode=default drm.service.enabled=true # Fingerprint -persist.vendor.sys.fp.expolevel=0x88 -persist.vendor.sys.fp.fod.location.X_Y=433,2056 -persist.vendor.sys.fp.fod.size.width_height=214,214 -ro.hardware.fp.fod.location=low -ro.hardware.fp.fod=true +persist.vendor.fingerprint.type=udfps_optical +persist.vendor.fingerprint.sensor_location=720|2882|124 # FM vendor.hw.fm.init=0 diff --git a/device.mk b/device.mk index f39087a..f891c05 100644 --- a/device.mk +++ b/device.mk @@ -154,8 +154,8 @@ PRODUCT_PACKAGES += \ # Fingerprint PRODUCT_PACKAGES += \ - android.hardware.biometrics.fingerprint@2.3-service.xiaomi \ - libudfpshandler + android.hardware.biometrics.fingerprint-service.xiaomi \ + libudfpshandler:64 PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml diff --git a/overlay/FrameworksResMondrian/res/values/config.xml b/overlay/FrameworksResMondrian/res/values/config.xml index ca7d810..39d2c44 100644 --- a/overlay/FrameworksResMondrian/res/values/config.xml +++ b/overlay/FrameworksResMondrian/res/values/config.xml @@ -372,6 +372,9 @@ 500 + + true + org.lineageos.sensor.udfps diff --git a/overlay/FrameworksResXiaomi/res/values/config.xml b/overlay/FrameworksResXiaomi/res/values/config.xml index 965ef26..14e9912 100644 --- a/overlay/FrameworksResXiaomi/res/values/config.xml +++ b/overlay/FrameworksResXiaomi/res/values/config.xml @@ -61,9 +61,6 @@ true - - true - true diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 20c3a3e..2c1d784 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -30,8 +30,7 @@ /dev/goodix_fp u:object_r:vendor_fingerprint_device:s0 /mnt/vendor/persist/fpc(/.*)? u:object_r:vendor_fingerprint_data_file:s0 /mnt/vendor/persist/goodix(/.*)? u:object_r:vendor_fingerprint_data_file:s0 -/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.3-service\.xiaomi u:object_r:hal_fingerprint_default_exec:s0 -/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.3-service\.sm8475 u:object_r:hal_fingerprint_default_exec:s0 +/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint-service\.xiaomi u:object_r:hal_fingerprint_default_exec:s0 # FPS info /sys/class/drm/card0/sde-crtc-0/measured_fps u:object_r:vendor_sysfs_graphics:s0 diff --git a/sepolicy/vendor/hal_fingerprint_default.te b/sepolicy/vendor/hal_fingerprint_default.te index 10b6a6f..e6234f9 100644 --- a/sepolicy/vendor/hal_fingerprint_default.te +++ b/sepolicy/vendor/hal_fingerprint_default.te @@ -29,6 +29,7 @@ allow hal_fingerprint_default mnt_vendor_file:dir search; allow hal_fingerprint_default vendor_displayfeature_device:chr_file { ioctl open read write }; get_prop(hal_fingerprint_default, vendor_adsprpc_prop) +get_prop(hal_fingerprint_default, vendor_camera_prop) get_prop(hal_fingerprint_default, vendor_panel_info_prop) set_prop(hal_fingerprint_default, vendor_fp_prop) set_prop(hal_fingerprint_default, vendor_fp_info_prop) diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index 55830a9..1c9293c 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -1,4 +1,5 @@ # Fingerprint +persist.vendor.fingerprint. u:object_r:vendor_fp_prop:s0 persist.vendor.fpc. u:object_r:vendor_fp_prop:s0 persist.vendor.sys.fp. u:object_r:vendor_fp_prop:s0 persist.vendor.sys.fp.info u:object_r:vendor_fp_info_prop:s0 diff --git a/udfps/Android.bp b/udfps/Android.bp index 41adbf2..f20e0f2 100644 --- a/udfps/Android.bp +++ b/udfps/Android.bp @@ -1,5 +1,5 @@ // -// Copyright (C) 2022 The LineageOS Project +// Copyright (C) 2022-2025 The LineageOS Project // // SPDX-License-Identifier: Apache-2.0 // @@ -11,6 +11,9 @@ cc_library { shared_libs: [ "libbase", ], + static_libs: [ + "android.hardware.biometrics.fingerprint-V4-ndk", + ], header_libs: [ "//hardware/xiaomi:xiaomifingerprint_headers", ], diff --git a/udfps/UdfpsHandler.cpp b/udfps/UdfpsHandler.cpp index 28a7943..63e7d0a 100644 --- a/udfps/UdfpsHandler.cpp +++ b/udfps/UdfpsHandler.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2022 The LineageOS Project - * 2023 flakeforever + * Copyright (C) 2022-2025 The LineageOS Project + * 2023-2025 flakeforever * * SPDX-License-Identifier: Apache-2.0 */ #define LOG_TAG "UdfpsHandler.xiaomi_sm8475" +#include #include +#include #include #include @@ -64,6 +66,8 @@ struct disp_local_hbm_req { #define FOD_PRESS_STATUS_PATH "/sys/class/touch/touch_dev/fod_press_status" +using ::aidl::android::hardware::biometrics::fingerprint::AcquiredInfo; + namespace { template @@ -233,12 +237,6 @@ class XiaomiSm8475UdfpsHander : public UdfpsHandler { }).detach(); } - void extCmd(int32_t cmd, int32_t param) { - mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_X, fodX); - mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_Y, fodY); - mDevice->extCmd(mDevice, cmd, param); - } - void onFingerDown(uint32_t /*x*/, uint32_t /*y*/, float /*minor*/, float /*major*/) { // fodX = x; // fodY = y; @@ -258,11 +256,14 @@ class XiaomiSm8475UdfpsHander : public UdfpsHandler { } } - void onEnrollResult(uint32_t fingerId, uint32_t groupId, uint32_t remaining) { - LOG(INFO) << __func__ << " fingerId: " << fingerId << " remaining: " << remaining; - if (remaining == 0 && fingerPressed) { - setFingerUp(); - } + void onAuthenticationSucceeded() { + LOG(INFO) << __func__; + onFingerUp(); + } + + void onAuthenticationFailed() { + LOG(INFO) << __func__; + onFingerUp(); } void cancel() { @@ -270,18 +271,6 @@ class XiaomiSm8475UdfpsHander : public UdfpsHandler { setFingerUp(); } - void preEnroll() { - LOG(DEBUG) << __func__; - } - - void enroll() { - LOG(DEBUG) << __func__; - } - - void postEnroll() { - LOG(DEBUG) << __func__; - } - private: fingerprint_device_t* mDevice; android::base::unique_fd touchDevice; @@ -292,6 +281,16 @@ class XiaomiSm8475UdfpsHander : public UdfpsHandler { uint32_t fodX; uint32_t fodY; + void extCmd(int32_t cmd, int32_t param) { + mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_X, fodX); + mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_Y, fodY); + mDevice->extCmd(mDevice, cmd, param); + + if (param == 0) { + setFingerUp(); + } + } + void registerDisplayEvent(int fd, int id, int type) { disp_event_req req; req.base.flag = 0; @@ -314,17 +313,21 @@ class XiaomiSm8475UdfpsHander : public UdfpsHandler { } void setFingerUp() { - fingerPressed = false; - setDisplayLocalHBM(0, 0); - int buf[MAX_BUF_SIZE] = {TOUCH_ID, THP_FOD_DOWNUP_CTL, 0}; - ioctl(touchDevice.get(), TOUCH_IOC_SET_CUR_VALUE, &buf); + if (fingerPressed) { + fingerPressed = false; + setDisplayLocalHBM(0, 0); + int buf[MAX_BUF_SIZE] = {TOUCH_ID, THP_FOD_DOWNUP_CTL, 0}; + ioctl(touchDevice.get(), TOUCH_IOC_SET_CUR_VALUE, &buf); + } } void setFingerDown() { - fingerPressed = true; - setDisplayLocalHBM(0, 2); - int buf[MAX_BUF_SIZE] = {TOUCH_ID, THP_FOD_DOWNUP_CTL, 1}; - ioctl(touchDevice.get(), TOUCH_IOC_SET_CUR_VALUE, &buf); + if (!fingerPressed) { + fingerPressed = true; + setDisplayLocalHBM(0, 2); + int buf[MAX_BUF_SIZE] = {TOUCH_ID, THP_FOD_DOWNUP_CTL, 1}; + ioctl(touchDevice.get(), TOUCH_IOC_SET_CUR_VALUE, &buf); + } } };