From fafed2911d829c3e0b33225a677ba4323e30d778 Mon Sep 17 00:00:00 2001 From: Willi Ye Date: Thu, 30 Dec 2021 14:50:05 +0100 Subject: [PATCH] sm7125: Squashed import of fingerprint hal Change-Id: I8de1846bc5d2087b8f5ae307d5e710805ff03445 --- common.mk | 3 +- fingerprint/Android.mk | 42 ++ fingerprint/BiometricsFingerprint.cpp | 389 ++++++++++++++++++ fingerprint/BiometricsFingerprint.h | 107 +++++ fingerprint/service.cpp | 51 +++ ...ometrics.fingerprint@3.0-service.sm7125.rc | 7 + proprietary-files.txt | 4 - sepolicy/vendor/file_contexts | 2 +- 8 files changed, 599 insertions(+), 6 deletions(-) create mode 100644 fingerprint/Android.mk create mode 100644 fingerprint/BiometricsFingerprint.cpp create mode 100644 fingerprint/BiometricsFingerprint.h create mode 100644 fingerprint/service.cpp create mode 100644 fingerprint/vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125.rc diff --git a/common.mk b/common.mk index aea9531..b91023f 100644 --- a/common.mk +++ b/common.mk @@ -152,7 +152,8 @@ PRODUCT_PACKAGES += \ # Fingerprint PRODUCT_PACKAGES += \ - vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125 + vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125 \ + vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125 # fastbootd PRODUCT_PACKAGES += \ diff --git a/fingerprint/Android.mk b/fingerprint/Android.mk new file mode 100644 index 0000000..ca31808 --- /dev/null +++ b/fingerprint/Android.mk @@ -0,0 +1,42 @@ +# +# Copyright (C) 2021 The LineageOS Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + BiometricsFingerprint.cpp \ + service.cpp + +LOCAL_SHARED_LIBRARIES := \ + libbase \ + libhardware \ + libhidlbase \ + libhidltransport \ + liblog \ + libutils \ + android.hardware.biometrics.fingerprint@2.1 \ + vendor.samsung.hardware.biometrics.fingerprint@3.0 + +LOCAL_MODULE := vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125 +LOCAL_INIT_RC := vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125.rc +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_OWNER := samsung +LOCAL_VENDOR_MODULE := true + +include $(BUILD_EXECUTABLE) diff --git a/fingerprint/BiometricsFingerprint.cpp b/fingerprint/BiometricsFingerprint.cpp new file mode 100644 index 0000000..4008816 --- /dev/null +++ b/fingerprint/BiometricsFingerprint.cpp @@ -0,0 +1,389 @@ +/* + * Copyright (C) 2019 The LineageOS Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define LOG_TAG "vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125" + +#include + +#include + +#include +#include +#include "BiometricsFingerprint.h" + +#include +#include +#include + +namespace vendor { +namespace samsung { +namespace hardware { +namespace biometrics { +namespace fingerprint { +namespace V3_0{ +namespace implementation { + +using RequestStatus = android::hardware::biometrics::fingerprint::V2_1::RequestStatus; + +ISehBiometricsFingerprint* SehBiometricsFingerprint::sInstance = nullptr; + +SehBiometricsFingerprint::SehBiometricsFingerprint() : mClientCallback(nullptr) { + sInstance = this; // keep track of the most recent instance + if (!openHal()) { + LOG(ERROR) << "Can't open HAL module"; + } +} + +SehBiometricsFingerprint::~SehBiometricsFingerprint() { + if (ss_fingerprint_close() != 0) { + LOG(ERROR) << "Can't close HAL module"; + } +} + +Return SehBiometricsFingerprint::ErrorFilter(int32_t error) { + switch (error) { + case 0: + return RequestStatus::SYS_OK; + case -2: + return RequestStatus::SYS_ENOENT; + case -4: + return RequestStatus::SYS_EINTR; + case -5: + return RequestStatus::SYS_EIO; + case -11: + return RequestStatus::SYS_EAGAIN; + case -12: + return RequestStatus::SYS_ENOMEM; + case -13: + return RequestStatus::SYS_EACCES; + case -14: + return RequestStatus::SYS_EFAULT; + case -16: + return RequestStatus::SYS_EBUSY; + case -22: + return RequestStatus::SYS_EINVAL; + case -28: + return RequestStatus::SYS_ENOSPC; + case -110: + return RequestStatus::SYS_ETIMEDOUT; + default: + LOG(ERROR) << "An unknown error returned from fingerprint vendor library: " << error; + return RequestStatus::SYS_UNKNOWN; + } +} + +// Translate from errors returned by traditional HAL (see fingerprint.h) to +// HIDL-compliant FingerprintError. +FingerprintError SehBiometricsFingerprint::VendorErrorFilter(int32_t error, int32_t* vendorCode) { + *vendorCode = 0; + switch (error) { + case FINGERPRINT_ERROR_HW_UNAVAILABLE: + return FingerprintError::ERROR_HW_UNAVAILABLE; + case FINGERPRINT_ERROR_UNABLE_TO_PROCESS: + return FingerprintError::ERROR_UNABLE_TO_PROCESS; + case FINGERPRINT_ERROR_TIMEOUT: + return FingerprintError::ERROR_TIMEOUT; + case FINGERPRINT_ERROR_NO_SPACE: + return FingerprintError::ERROR_NO_SPACE; + case FINGERPRINT_ERROR_CANCELED: + return FingerprintError::ERROR_CANCELED; + case FINGERPRINT_ERROR_UNABLE_TO_REMOVE: + return FingerprintError::ERROR_UNABLE_TO_REMOVE; + case FINGERPRINT_ERROR_LOCKOUT: + return FingerprintError::ERROR_LOCKOUT; + default: + if (error >= FINGERPRINT_ERROR_VENDOR_BASE) { + // vendor specific code. + *vendorCode = error - FINGERPRINT_ERROR_VENDOR_BASE; + return FingerprintError::ERROR_VENDOR; + } + } + LOG(ERROR) << "Unknown error from fingerprint vendor library: " << error; + return FingerprintError::ERROR_UNABLE_TO_PROCESS; +} + +// Translate acquired messages returned by traditional HAL (see fingerprint.h) +// to HIDL-compliant FingerprintAcquiredInfo. +FingerprintAcquiredInfo SehBiometricsFingerprint::VendorAcquiredFilter(int32_t info, + int32_t* vendorCode) { + *vendorCode = 0; + switch (info) { + case FINGERPRINT_ACQUIRED_GOOD: + return FingerprintAcquiredInfo::ACQUIRED_GOOD; + case FINGERPRINT_ACQUIRED_PARTIAL: + return FingerprintAcquiredInfo::ACQUIRED_PARTIAL; + case FINGERPRINT_ACQUIRED_INSUFFICIENT: + return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT; + case FINGERPRINT_ACQUIRED_IMAGER_DIRTY: + return FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY; + case FINGERPRINT_ACQUIRED_TOO_SLOW: + return FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW; + case FINGERPRINT_ACQUIRED_TOO_FAST: + return FingerprintAcquiredInfo::ACQUIRED_TOO_FAST; + default: + if (info >= FINGERPRINT_ACQUIRED_VENDOR_BASE) { + // vendor specific code. + *vendorCode = info - FINGERPRINT_ACQUIRED_VENDOR_BASE; + return FingerprintAcquiredInfo::ACQUIRED_VENDOR; + } + } + LOG(ERROR) << "Unknown acquiredmsg from fingerprint vendor library: " << info; + return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT; +} + +Return SehBiometricsFingerprint::setNotify( + const sp& clientCallback) { + std::lock_guard lock(mClientCallbackMutex); + mClientCallback = clientCallback; + // This is here because HAL 2.1 doesn't have a way to propagate a + // unique token for its driver. Subsequent versions should send a unique + // token for each call to setNotify(). This is fine as long as there's only + // one fingerprint device on the platform. + return reinterpret_cast(this); +} + +Return SehBiometricsFingerprint::preEnroll() { + return ss_fingerprint_pre_enroll(); +} + +Return SehBiometricsFingerprint::enroll(const hidl_array& hat, + uint32_t gid, uint32_t timeoutSec) { + const hw_auth_token_t* authToken = reinterpret_cast(hat.data()); + + return ErrorFilter(ss_fingerprint_enroll(authToken, gid, timeoutSec)); +} + +Return SehBiometricsFingerprint::postEnroll() { + return ErrorFilter(ss_fingerprint_post_enroll()); +} + +Return SehBiometricsFingerprint::getAuthenticatorId() { + return ss_fingerprint_get_auth_id(); +} + +Return SehBiometricsFingerprint::cancel() { + return ErrorFilter(ss_fingerprint_cancel()); +} + +Return SehBiometricsFingerprint::enumerate() { + if (ss_fingerprint_enumerate != nullptr) { + return ErrorFilter(ss_fingerprint_enumerate()); + } + + return RequestStatus::SYS_UNKNOWN; +} + +Return SehBiometricsFingerprint::remove(uint32_t gid, uint32_t fid) { + return ErrorFilter(ss_fingerprint_remove(gid, fid)); +} + +Return SehBiometricsFingerprint::setActiveGroup(uint32_t gid, + const hidl_string&) { + std::string storePath = "/data/vendor/biometrics/fp/User_" + std::to_string(gid); + LOG(ERROR) << "setActiveGroup " << gid << " " << storePath; + return ErrorFilter(ss_fingerprint_set_active_group(gid, storePath.c_str())); +} + +Return SehBiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) { + return ErrorFilter(ss_fingerprint_authenticate(operationId, gid)); +} + +Return SehBiometricsFingerprint::sehRequest(int32_t cmd_id, + int32_t inParam, const hidl_vec& inputBuf, sehRequest_cb _hidl_cb) { + size_t inputSize = 0; + for (; inputBuf[inputSize] != '\0'; ++inputSize); + + int8_t input[inputSize + 1]; + + // HACK: SehBiometrics 3.0 doesn't have the len parameter like the older 2.1 HAL has. Set it to 10 for now + int8_t output[10]; + + for (size_t i = 0; i < inputSize; ++i) { + input[i] = inputBuf[i]; + } + input[inputSize] = '\0'; + for (size_t i = 0; i < static_cast(10); ++i) { + output[i] = '\0'; + } + + LOG(ERROR) << "request(cmd_id=" << cmd_id + << ", len=" << 10 + << ", inParam=" << inParam + << ", inputBuf=" << input + << ")"; + + int ret = ss_fingerprint_request(cmd_id, input, 0, 10 == 0 ? nullptr : output, 10, inParam); + + auto outBuf = hidl_vec(); + outBuf.setToExternal(output, 10); + + _hidl_cb(ret, outBuf); + return Void(); +} + +ISehBiometricsFingerprint* SehBiometricsFingerprint::getInstance() { + if (!sInstance) { + sInstance = new SehBiometricsFingerprint(); + } + return sInstance; +} + +bool SehBiometricsFingerprint::openHal() { + void* handle = dlopen("libbauthserver.so", RTLD_NOW); + if (handle) { + int err; + + ss_fingerprint_close = + reinterpret_cast(dlsym(handle, "ss_fingerprint_close")); + ss_fingerprint_open = + reinterpret_cast(dlsym(handle, "ss_fingerprint_open")); + + ss_set_notify_callback = reinterpret_cast( + dlsym(handle, "ss_set_notify_callback")); + ss_fingerprint_pre_enroll = reinterpret_cast( + dlsym(handle, "ss_fingerprint_pre_enroll")); + ss_fingerprint_enroll = + reinterpret_cast(dlsym(handle, "ss_fingerprint_enroll")); + ss_fingerprint_post_enroll = reinterpret_cast( + dlsym(handle, "ss_fingerprint_post_enroll")); + ss_fingerprint_get_auth_id = reinterpret_cast( + dlsym(handle, "ss_fingerprint_get_auth_id")); + ss_fingerprint_cancel = + reinterpret_cast(dlsym(handle, "ss_fingerprint_cancel")); + ss_fingerprint_enumerate = reinterpret_cast( + dlsym(handle, "ss_fingerprint_enumerate")); + ss_fingerprint_remove = + reinterpret_cast(dlsym(handle, "ss_fingerprint_remove")); + ss_fingerprint_set_active_group = reinterpret_cast( + dlsym(handle, "ss_fingerprint_set_active_group")); + ss_fingerprint_authenticate = reinterpret_cast( + dlsym(handle, "ss_fingerprint_authenticate")); + ss_fingerprint_request = reinterpret_cast( + dlsym(handle, "ss_fingerprint_request")); + + if ((err = ss_fingerprint_open(nullptr)) != 0) { + LOG(ERROR) << "Can't open fingerprint, error: " << err; + return false; + } + + if ((err = ss_set_notify_callback(SehBiometricsFingerprint::notify)) != 0) { + LOG(ERROR) << "Can't register fingerprint module callback, error: " << err; + return false; + } + + return true; + } + + return false; +} + +void SehBiometricsFingerprint::notify(const fingerprint_msg_t* msg) { + SehBiometricsFingerprint* thisPtr = + static_cast(SehBiometricsFingerprint::getInstance()); + std::lock_guard lock(thisPtr->mClientCallbackMutex); + if (thisPtr == nullptr || thisPtr->mClientCallback == nullptr) { + LOG(ERROR) << "Receiving callbacks before the client callback is registered."; + return; + } + const uint64_t devId = 1; + switch (msg->type) { + case FINGERPRINT_ERROR: { + int32_t vendorCode = 0; + FingerprintError result = VendorErrorFilter(msg->data.error, &vendorCode); + LOG(DEBUG) << "onError(" << static_cast(result) << ")"; + if (!thisPtr->mClientCallback->onError(devId, result, vendorCode).isOk()) { + LOG(ERROR) << "failed to invoke fingerprint onError callback"; + } + } break; + case FINGERPRINT_ACQUIRED: { + int32_t vendorCode = 0; + FingerprintAcquiredInfo result = + VendorAcquiredFilter(msg->data.acquired.acquired_info, &vendorCode); + LOG(DEBUG) << "onAcquired(" << static_cast(result) << ")"; + if (!thisPtr->mClientCallback->onAcquired(devId, result, vendorCode).isOk()) { + LOG(ERROR) << "failed to invoke fingerprint onAcquired callback"; + } + } break; + case FINGERPRINT_TEMPLATE_ENROLLING: + LOG(DEBUG) << "onEnrollResult(fid=" << msg->data.enroll.finger.fid + << ", gid=" << msg->data.enroll.finger.gid + << ", rem=" << msg->data.enroll.samples_remaining << ")"; + if (thisPtr->mClientCallback + ->onEnrollResult(devId, msg->data.enroll.finger.fid, + msg->data.enroll.finger.gid, msg->data.enroll.samples_remaining) + .isOk()) { + fingerprint_msg_t* newMsg = (fingerprint_msg_t*)msg; + newMsg->data.enroll.samples_remaining = 100 - msg->data.enroll.samples_remaining; + msg = newMsg; + } else { + LOG(ERROR) << "failed to invoke fingerprint onEnrollResult callback"; + } + break; + case FINGERPRINT_TEMPLATE_REMOVED: + LOG(DEBUG) << "onRemove(fid=" << msg->data.removed.finger.fid + << ", gid=" << msg->data.removed.finger.gid + << ", rem=" << msg->data.removed.remaining_templates << ")"; + if (!thisPtr->mClientCallback + ->onRemoved(devId, msg->data.removed.finger.fid, msg->data.removed.finger.gid, + msg->data.removed.remaining_templates) + .isOk()) { + LOG(ERROR) << "failed to invoke fingerprint onRemoved callback"; + } + break; + case FINGERPRINT_AUTHENTICATED: + LOG(DEBUG) << "onAuthenticated(fid=" << msg->data.authenticated.finger.fid + << ", gid=" << msg->data.authenticated.finger.gid << ")"; + if (msg->data.authenticated.finger.fid != 0) { + const uint8_t* hat = reinterpret_cast(&msg->data.authenticated.hat); + const hidl_vec token( + std::vector(hat, hat + sizeof(msg->data.authenticated.hat))); + if (!thisPtr->mClientCallback + ->onAuthenticated(devId, msg->data.authenticated.finger.fid, + msg->data.authenticated.finger.gid, token) + .isOk()) { + LOG(ERROR) << "failed to invoke fingerprint onAuthenticated callback"; + } + } else { + // Not a recognized fingerprint + if (!thisPtr->mClientCallback + ->onAuthenticated(devId, msg->data.authenticated.finger.fid, + msg->data.authenticated.finger.gid, hidl_vec()) + .isOk()) { + LOG(ERROR) << "failed to invoke fingerprint onAuthenticated callback"; + } + } + break; + case FINGERPRINT_TEMPLATE_ENUMERATING: + LOG(DEBUG) << "onEnumerate(fid=" << msg->data.enumerated.finger.fid + << ", gid=" << msg->data.enumerated.finger.gid + << ", rem=" << msg->data.enumerated.remaining_templates << ")"; + if (!thisPtr->mClientCallback + ->onEnumerate(devId, msg->data.enumerated.finger.fid, + msg->data.enumerated.finger.gid, + msg->data.enumerated.remaining_templates) + .isOk()) { + LOG(ERROR) << "failed to invoke fingerprint onEnumerate callback"; + } + break; + } +} + +} // namespace implementation +} // namespace V2_1 +} // namespace fingerprint +} // namespace biometrics +} // namespace hardware +} // namespace samsung +} // namespace vendor diff --git a/fingerprint/BiometricsFingerprint.h b/fingerprint/BiometricsFingerprint.h new file mode 100644 index 0000000..223bf78 --- /dev/null +++ b/fingerprint/BiometricsFingerprint.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2019 The LineageOS Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H +#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H + +#include +#include +#include +#include +#include + +namespace vendor { +namespace samsung { +namespace hardware { +namespace biometrics { +namespace fingerprint { +namespace V3_0 { +namespace implementation { + +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_array; +using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback; +using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus; +using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintError; +using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo; + +struct SehBiometricsFingerprint : public ISehBiometricsFingerprint { +public: + SehBiometricsFingerprint(); + ~SehBiometricsFingerprint(); + + // Method to wrap legacy HAL with BiometricsFingerprint class + static ISehBiometricsFingerprint* getInstance(); + + // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow. + Return setNotify( + const sp& clientCallback) override; + Return preEnroll() override; + Return enroll(const hidl_array& hat, uint32_t gid, + uint32_t timeoutSec) override; + Return postEnroll() override; + Return getAuthenticatorId() override; + Return cancel() override; + Return enumerate() override; + Return remove(uint32_t gid, uint32_t fid) override; + Return setActiveGroup(uint32_t gid, const hidl_string& storePath) override; + Return authenticate(uint64_t operationId, uint32_t gid) override; + + // Methods from ::vendor::samsung::hardware::biometrics::fingerprint::V3_0::ISehBiometricsFingerprint follow. + Return sehRequest(int32_t cmd_id, int32_t inParam, const hidl_vec& inputBuf, sehRequest_cb _hidl_cb) override; + + private: + bool openHal(); + static void notify( + const fingerprint_msg_t* msg); /* Static callback for legacy HAL implementation */ + static Return ErrorFilter(int32_t error); + static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode); + static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode); + static ISehBiometricsFingerprint* sInstance; + + std::mutex mClientCallbackMutex; + sp mClientCallback; + + int (*ss_fingerprint_close)(); + int (*ss_fingerprint_open)(const char* id); + + int (*ss_set_notify_callback)(fingerprint_notify_t notify); + uint64_t (*ss_fingerprint_pre_enroll)(); + int (*ss_fingerprint_enroll)(const hw_auth_token_t* hat, uint32_t gid, uint32_t timeout_sec); + int (*ss_fingerprint_post_enroll)(); + uint64_t (*ss_fingerprint_get_auth_id)(); + int (*ss_fingerprint_cancel)(); + int (*ss_fingerprint_enumerate)(); + int (*ss_fingerprint_remove)(uint32_t gid, uint32_t fid); + int (*ss_fingerprint_set_active_group)(uint32_t gid, const char* store_path); + int (*ss_fingerprint_authenticate)(uint64_t operation_id, uint32_t gid); + int (*ss_fingerprint_request)(int32_t cmd_id, const int8_t* inputBuf, uint32_t value, int8_t* outBuf, uint32_t len, uint32_t inParam); + +}; + +} // namespace implementation +} // namespace V2_1 +} // namespace fingerprint +} // namespace biometrics +} // namespace hardware +} // namespace samsung +} // namespace vendor + +#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H diff --git a/fingerprint/service.cpp b/fingerprint/service.cpp new file mode 100644 index 0000000..5cde419 --- /dev/null +++ b/fingerprint/service.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2019 The LineageOS Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125" + +#include +#include +#include + +#include "BiometricsFingerprint.h" + +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +using vendor::samsung::hardware::biometrics::fingerprint::V3_0::ISehBiometricsFingerprint; +using vendor::samsung::hardware::biometrics::fingerprint::V3_0::implementation::SehBiometricsFingerprint; + +using android::OK; +using android::sp; + +int main() { + android::sp bio = SehBiometricsFingerprint::getInstance(); + + configureRpcThreadpool(1, true); + + if (bio == nullptr || bio->registerAsService() != OK) { + LOG(ERROR) << "Could not register service for Fingerprint HAL"; + goto shutdown; + } + + LOG(INFO) << "Fingerprint HAL service is Ready."; + joinRpcThreadpool(); + +shutdown: + // In normal operation, we don't expect the thread pool to shutdown + LOG(ERROR) << "Fingerprint HAL failed to join thread pool."; + return 1; +} diff --git a/fingerprint/vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125.rc b/fingerprint/vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125.rc new file mode 100644 index 0000000..32da2f4 --- /dev/null +++ b/fingerprint/vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125.rc @@ -0,0 +1,7 @@ +service vendor.fps_hal /vendor/bin/hw/vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125 + # "class hal" causes a race condition on some devices due to files created + # in /data. As a workaround, postpone startup until later in boot once + # /data is mounted. + class late_start + user system + group system input diff --git a/proprietary-files.txt b/proprietary-files.txt index ea7591f..9759f41 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -599,10 +599,6 @@ vendor/lib64/libsecnativefeature.so vendor/etc/floating_feature.xml # Fingerprint -vendor/bin/hw/vendor.samsung.hardware.biometrics.fingerprint@3.0-service -vendor/etc/init/vendor.samsung.hardware.biometrics.fingerprint@3.0-service.rc -vendor/lib/hw/fingerprint.default.so -vendor/lib64/hw/fingerprint.default.so vendor/lib/libbauthserver.so vendor/lib64/libbauthserver.so vendor/lib/libbauthtzcommon.so diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 56c6c73..ba44a4c 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -18,7 +18,7 @@ /(vendor|system/vendor)/bin/hw/vendor\.lineage\.fastcharge@1\.0-service\.samsung u:object_r:hal_lineage_fastcharge_default_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch@1\.0-service\.samsung u:object_r:hal_lineage_touch_default_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service.samsung-qcom\.sm7125 u:object_r:hal_lineage_livedisplay_sysfs_exec:s0 -/(vendor|system/vendor)/bin/hw/vendor.samsung.hardware.biometrics.fingerprint@3.0-service u:object_r:hal_fingerprint_default_exec:s0 +/(vendor|system/vendor)/bin/hw/vendor.samsung.hardware.biometrics.fingerprint@3.0-service.sm7125 u:object_r:hal_fingerprint_default_exec:s0 /(vendor|system/vendor)/bin/hw/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.samsung.sm7125 u:object_r:hal_lineage_fod_default_exec:s0 /(vendor|system/vendor)/bin/hw/android.hardware.vibrator@1.3-service.sm7125 u:object_r:hal_vibrator_default_exec:s0 /(vendor|system/vendor)/bin/hw/android\.hardware\.nfc@1\.2-service\.samsung u:object_r:hal_nfc_default_exec:s0