mondrian: Switch fingerprint HAL to AIDL

This commit is contained in:
flakeforever
2025-07-13 11:24:31 -07:00
parent e25059c809
commit 3bfc9d337a
9 changed files with 50 additions and 46 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -372,6 +372,9 @@
<item>500</item>
</integer-array>
<!-- Whether to enable fingerprint unlock when screen turns off on udfps devices -->
<bool name="config_screen_off_udfps_enabled">true</bool>
<!-- Type of the udfps long press sensor. Empty if long press is not supported. -->
<string name="config_dozeUdfpsLongPressSensorType" translatable="false">org.lineageos.sensor.udfps</string>

View File

@@ -61,9 +61,6 @@
<!-- Whether the device supports Smart Pixels -->
<bool name="config_supportSmartPixels">true</bool>
<!-- Whether devices suports in-display fingerprint when screen is off -->
<bool name="config_supportScreenOffUdfps">true</bool>
<!-- Whether to show peak refresh rate in display settings -->
<bool name="config_show_peak_refresh_rate_switch">true</bool>

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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",
],

View File

@@ -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 <aidl/android/hardware/biometrics/fingerprint/BnFingerprint.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/unique_fd.h>
#include <poll.h>
@@ -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 <typename T>
@@ -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);
}
}
};