hardware_xiaomi/hidl/biometrics/fingerprint/UdfpsHandler.cpp
Arian 9976b3f15b
hidl: biometrics: fingerprint: Add support for device specific UDFPS libs
Change-Id: I8f29d58b178aa8ff420204f790c6952fdf4ade58
2022-05-13 18:02:35 +02:00

36 lines
751 B
C++

/*
* 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;
}