From: J0SH1X Date: Tue, 30 Jan 2024 16:48:14 +0000 (+0100) Subject: aidl: fingerprint: Add support for libsfp_sensor X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=49d5eb139fe57c923cb76ffc265935f568c89171;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung.git aidl: fingerprint: Add support for libsfp_sensor Co-Authored-By: Tim Zimmermann Change-Id: I7fbbb1467f87b688057eac24d2434274e1105e05 --- 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;