summaryrefslogtreecommitdiff
path: root/biometrics
diff options
context:
space:
mode:
authorGuaiYiHu <guaiyihu@foxmail.com>2019-09-19 19:22:28 +0200
committerMichael Bestas <mkbestas@lineageos.org>2020-04-30 00:48:53 +0300
commit8657d3fdc8bd2b68a0aae406827e578a5cf87301 (patch)
tree0549437db07f272d2f79089fee391f4493dae943 /biometrics
parentdce434aa656f86c1a904f2b2f25046d690a368b4 (diff)
sdm660-common: biometrics: Rework the fpc-goodix differentiation
Change-Id: Ib6be2c12d1fc7e9354001f7eb0b28e740eecde46
Diffstat (limited to 'biometrics')
-rw-r--r--biometrics/BiometricsFingerprint.cpp36
-rw-r--r--biometrics/Hardware.h58
2 files changed, 16 insertions, 78 deletions
diff --git a/biometrics/BiometricsFingerprint.cpp b/biometrics/BiometricsFingerprint.cpp
index 42243ab..311bbc6 100644
--- a/biometrics/BiometricsFingerprint.cpp
+++ b/biometrics/BiometricsFingerprint.cpp
@@ -16,15 +16,13 @@
*/
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660"
-#include <cutils/properties.h>
-
#include <hardware/hw_auth_token.h>
#include <hardware/hardware.h>
#include <hardware/fingerprint.h>
#include "BiometricsFingerprint.h"
-#include "Hardware.h"
+#include <cutils/properties.h>
#include <inttypes.h>
#include <unistd.h>
@@ -216,6 +214,7 @@ IBiometricsFingerprint* BiometricsFingerprint::getInstance() {
void setFpVendorProp(const char *fp_vendor) {
property_set("persist.vendor.sys.fp.vendor", fp_vendor);
+ property_set("ro.boot.fpsensor", fp_vendor);
}
fingerprint_device_t* getDeviceForVendor(const char *class_name)
@@ -223,18 +222,7 @@ fingerprint_device_t* getDeviceForVendor(const char *class_name)
const hw_module_t *hw_module = nullptr;
int err;
- if (!strcmp(class_name, "fpc")) {
- setFpVendorProp("fpc");
- err = load("/system/vendor/lib64/hw/fingerprint.fpc.so", &hw_module);
- } else if (!strcmp(class_name, "gdx")) {
- setFpVendorProp("goodix");
- err = load("/system/vendor/lib64/hw/fingerprint.goodix.so", &hw_module);
- } else {
- setFpVendorProp("none");
- ALOGE("No fingerprint module class specified.");
- err = 1;
- }
-
+ err = hw_get_module_by_class(FINGERPRINT_HARDWARE_MODULE_ID, class_name, &hw_module);
if (err) {
ALOGE("Failed to get fingerprint module: class %s, error %d", class_name, err);
return nullptr;
@@ -276,17 +264,25 @@ fingerprint_device_t* getDeviceForVendor(const char *class_name)
fingerprint_device_t* getFingerprintDevice()
{
fingerprint_device_t *fp_device;
- char class_name[PROPERTY_VALUE_MAX];
- property_get("ro.boot.fpsensor",
- class_name, NULL);
+ fp_device = getDeviceForVendor("fpc");
+ if (fp_device == nullptr) {
+ ALOGE("Failed to load fpc fingerprint module");
+ } else {
+ setFpVendorProp("fpc");
+ return fp_device;
+ }
- fp_device = getDeviceForVendor(class_name);
+ fp_device = getDeviceForVendor("goodix");
if (fp_device == nullptr) {
- ALOGE("Failed to load %s fingerprint module", class_name);
+ ALOGE("Failed to load goodix fingerprint module");
} else {
+ setFpVendorProp("goodix");
return fp_device;
}
+
+ setFpVendorProp("none");
+
return nullptr;
}
diff --git a/biometrics/Hardware.h b/biometrics/Hardware.h
deleted file mode 100644
index 90a6067..0000000
--- a/biometrics/Hardware.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2017, 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 _CUSTOM_HARDWARE_H
-#define _CUSTOM_HARDWARE_H
-
-#include <dlfcn.h>
-
-#include <cutils/log.h>
-
-#include <utils/threads.h>
-
-static union {
- const fingerprint_module_t *module;
- const hw_module_t *hw_module;
-} vendor;
-
-static int load(const char *path,
- const struct hw_module_t **pHmi)
-{
- int status = 0;
- void *handle = NULL;
- struct hw_module_t *hmi = NULL;
-
- ALOGE("Opening vendor module from : %s", path);
- handle = dlopen(path, RTLD_NOW);
- if (handle == NULL) {
- status = -EINVAL;
- goto done;
- }
-
- hmi = (struct hw_module_t *)dlsym(handle,
- HAL_MODULE_INFO_SYM_AS_STR);
- if (hmi == NULL) {
- status = -EINVAL;
- goto done;
- }
-
- hmi->dso = handle;
-
-done:
- *pHmi = hmi;
-
- return status;
-}
-#endif /* _CUSTOM_HARDWARE_H */