forked from donjohanliebert/hardware_xiaomi
hidl: biometrics: fingerprint: Add support for device specific UDFPS libs
Change-Id: I8f29d58b178aa8ff420204f790c6952fdf4ade58
This commit is contained in:
parent
3f1a8dbfe8
commit
9976b3f15b
@ -14,12 +14,14 @@ cc_binary {
|
||||
relative_install_path: "hw",
|
||||
srcs: [
|
||||
"BiometricsFingerprint.cpp",
|
||||
"UdfpsHandler.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libdl",
|
||||
"liblog",
|
||||
"libhidlbase",
|
||||
"libhardware",
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <android-base/strings.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include "BiometricsFingerprint.h"
|
||||
#include "UdfpsHandler.h"
|
||||
|
||||
#include <android-base/properties.h>
|
||||
#include <inttypes.h>
|
||||
@ -48,7 +49,11 @@ using ::android::base::StartsWith;
|
||||
|
||||
BiometricsFingerprint* BiometricsFingerprint::sInstance = nullptr;
|
||||
|
||||
BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr), mDevice(nullptr) {
|
||||
BiometricsFingerprint::BiometricsFingerprint()
|
||||
: mClientCallback(nullptr),
|
||||
mDevice(nullptr),
|
||||
mUdfpsHandlerFactory(nullptr),
|
||||
mUdfpsHandler(nullptr) {
|
||||
sInstance = this; // keep track of the most recent instance
|
||||
for (auto& [class_name, is_udfps] : kModules) {
|
||||
mDevice = openHal(class_name);
|
||||
@ -69,11 +74,26 @@ BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr), mDevi
|
||||
|
||||
if (mIsUdfps) {
|
||||
SetProperty("ro.hardware.fp.udfps", "true");
|
||||
|
||||
mUdfpsHandlerFactory = getUdfpsHandlerFactory();
|
||||
if (!mUdfpsHandlerFactory) {
|
||||
ALOGE("Can't get UdfpsHandlerFactory");
|
||||
} else {
|
||||
mUdfpsHandler = mUdfpsHandlerFactory->create();
|
||||
if (!mUdfpsHandler) {
|
||||
ALOGE("Can't create UdfpsHandler");
|
||||
} else {
|
||||
mUdfpsHandler->init(mDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BiometricsFingerprint::~BiometricsFingerprint() {
|
||||
ALOGV("~BiometricsFingerprint()");
|
||||
if (mUdfpsHandler) {
|
||||
mUdfpsHandlerFactory->destroy(mUdfpsHandler);
|
||||
}
|
||||
if (mDevice == nullptr) {
|
||||
ALOGE("No valid device");
|
||||
return;
|
||||
@ -245,12 +265,19 @@ Return<bool> BiometricsFingerprint::isUdfps(uint32_t /*sensorId*/) {
|
||||
return mIsUdfps;
|
||||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::onFingerDown(uint32_t /*x*/, uint32_t /*y*/, float /*minor*/,
|
||||
float /*major*/) {
|
||||
Return<void> BiometricsFingerprint::onFingerDown(uint32_t x, uint32_t y, float minor, float major) {
|
||||
if (mUdfpsHandler) {
|
||||
mUdfpsHandler->onFingerDown(x, y, minor, major);
|
||||
}
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::onFingerUp() {
|
||||
if (mUdfpsHandler) {
|
||||
mUdfpsHandler->onFingerUp();
|
||||
}
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <log/log.h>
|
||||
#include "UdfpsHandler.h"
|
||||
#include "fingerprint.h"
|
||||
|
||||
namespace android {
|
||||
@ -75,6 +76,8 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||
sp<IBiometricsFingerprintClientCallback> mClientCallback;
|
||||
fingerprint_device_t* mDevice;
|
||||
bool mIsUdfps;
|
||||
UdfpsHandlerFactory* mUdfpsHandlerFactory;
|
||||
UdfpsHandler* mUdfpsHandler;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
35
hidl/biometrics/fingerprint/UdfpsHandler.cpp
Normal file
35
hidl/biometrics/fingerprint/UdfpsHandler.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "UdfpsHandler.h"
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define UDFPS_HANDLER_LIB_NAME "libudfpshandler.so"
|
||||
#define UDFPS_HANDLER_FACTORY "UDFPS_HANDLER_FACTORY"
|
||||
|
||||
UdfpsHandlerFactory* getUdfpsHandlerFactory() {
|
||||
void* libudfpshander;
|
||||
UdfpsHandlerFactory* factory_handler;
|
||||
|
||||
libudfpshander = dlopen(UDFPS_HANDLER_LIB_NAME, RTLD_LAZY);
|
||||
if (!libudfpshander) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
factory_handler = (UdfpsHandlerFactory*)dlsym(libudfpshander, UDFPS_HANDLER_FACTORY);
|
||||
if (!factory_handler) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
return factory_handler;
|
||||
|
||||
error:
|
||||
if (libudfpshander) {
|
||||
dlclose(libudfpshander);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
26
hidl/biometrics/fingerprint/include/UdfpsHandler.h
Normal file
26
hidl/biometrics/fingerprint/include/UdfpsHandler.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fingerprint.h"
|
||||
|
||||
class UdfpsHandler {
|
||||
public:
|
||||
virtual ~UdfpsHandler() = default;
|
||||
|
||||
virtual void init(fingerprint_device_t *device) = 0;
|
||||
virtual void onFingerDown(uint32_t x, uint32_t y, float minor, float major) = 0;
|
||||
virtual void onFingerUp() = 0;
|
||||
};
|
||||
|
||||
struct UdfpsHandlerFactory {
|
||||
UdfpsHandler* (*create)();
|
||||
void (*destroy)(UdfpsHandler* handler);
|
||||
};
|
||||
|
||||
UdfpsHandlerFactory *getUdfpsHandlerFactory();
|
Loading…
Reference in New Issue
Block a user