From 49d5eb139fe57c923cb76ffc265935f568c89171 Mon Sep 17 00:00:00 2001 From: J0SH1X Date: Tue, 30 Jan 2024 17:48:14 +0100 Subject: [PATCH] aidl: fingerprint: Add support for libsfp_sensor Co-Authored-By: Tim Zimmermann Change-Id: I7fbbb1467f87b688057eac24d2434274e1105e05 --- aidl/fingerprint/LegacyHAL.cpp | 4 ++++ aidl/fingerprint/Session.cpp | 34 +++++++++++++++++++++++++++++----- aidl/fingerprint/Session.h | 2 ++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/aidl/fingerprint/LegacyHAL.cpp b/aidl/fingerprint/LegacyHAL.cpp index 54f5a35..143efc6 100644 --- a/aidl/fingerprint/LegacyHAL.cpp +++ b/aidl/fingerprint/LegacyHAL.cpp @@ -18,6 +18,10 @@ namespace fingerprint { bool LegacyHAL::openHal(fingerprint_notify_t notify) { void* handle = dlopen("libbauthserver.so", RTLD_NOW); + + if (!handle) + handle = dlopen("libsfp_sensor.so", RTLD_NOW); + if (handle) { int err; diff --git a/aidl/fingerprint/Session.cpp b/aidl/fingerprint/Session.cpp index aa4bdae..722190d 100644 --- a/aidl/fingerprint/Session.cpp +++ b/aidl/fingerprint/Session.cpp @@ -13,6 +13,7 @@ #include +#include #include #include @@ -42,8 +43,8 @@ Session::Session(LegacyHAL hal, int userId, std::shared_ptr cb mDeathRecipient = AIBinder_DeathRecipient_new(onClientDeath); char filename[64]; - snprintf(filename, sizeof(filename), "/data/vendor_de/%d/fpdata/"); - mHal.ss_fingerprint_set_active_group(userId, &filename[0]); + snprintf(filename, sizeof(filename), FINGERPRINT_DATA_DIR, userId); + mHal.ss_fingerprint_set_active_group(userId, filename); } ndk::ScopedAStatus Session::generateChallenge() { @@ -119,9 +120,32 @@ ndk::ScopedAStatus Session::detectInteraction(std::shared_ptr enrollments; + char filename[64]; + snprintf(filename, sizeof(filename), FINGERPRINT_DATA_DIR, mUserId); + + DIR* directory = opendir(filename); + if (directory) { + struct dirent* entry; + while ((entry = readdir(directory))) { + int uid, fid; + if (sscanf(entry->d_name, "User_%d_%dtmpl.dat", &uid, &fid)) { + if (uid == mUserId) + enrollments.push_back(fid); + } + } + closedir(directory); + } else { + LOG(WARNING) << "Failed to open " << filename; + } + + mCb->onEnrollmentsEnumerated(enrollments); + } return ndk::ScopedAStatus::ok(); } diff --git a/aidl/fingerprint/Session.h b/aidl/fingerprint/Session.h index dc3bd3d..cc91831 100644 --- a/aidl/fingerprint/Session.h +++ b/aidl/fingerprint/Session.h @@ -14,6 +14,8 @@ #include "LegacyHAL.h" #include "LockoutTracker.h" +#define FINGERPRINT_DATA_DIR "/data/vendor/biometrics/fp/User_%d/" + using ::aidl::android::hardware::biometrics::common::ICancellationSignal; using ::aidl::android::hardware::biometrics::common::OperationContext; using ::aidl::android::hardware::biometrics::fingerprint::PointerContext; -- 2.20.1