diff --git a/biometrics/Android.bp b/biometrics/Android.bp index dacc3e3d..892e0bc0 100644 --- a/biometrics/Android.bp +++ b/biometrics/Android.bp @@ -15,20 +15,24 @@ cc_binary { name: "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660", - relative_install_path: "hw", defaults: ["hidl_defaults"], init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660.rc"], - srcs: ["service.cpp", "BiometricsFingerprint.cpp"], + vendor: true, + relative_install_path: "hw", + srcs: [ + "BiometricsFingerprint.cpp", + "service.cpp", + ], + shared_libs: [ - "libbase", - "libcutils", - "libhardware", + "libcutils", + "liblog", "libhidlbase", "libhidltransport", - "libhwbinder", - "liblog", + "libhardware", "libutils", "android.hardware.biometrics.fingerprint@2.1", ], proprietary: true, + } diff --git a/biometrics/BiometricsFingerprint.cpp b/biometrics/BiometricsFingerprint.cpp index 42243aba..f69a6bfa 100644 --- a/biometrics/BiometricsFingerprint.cpp +++ b/biometrics/BiometricsFingerprint.cpp @@ -15,15 +15,13 @@ * limitations under the License. */ #define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660" - -#include +#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660" #include #include #include #include "BiometricsFingerprint.h" -#include "Hardware.h" #include #include @@ -214,27 +212,12 @@ IBiometricsFingerprint* BiometricsFingerprint::getInstance() { return sInstance; } -void setFpVendorProp(const char *fp_vendor) { - property_set("persist.vendor.sys.fp.vendor", fp_vendor); -} - 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 +259,21 @@ 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(class_name); + fp_device = getDeviceForVendor("fpc"); if (fp_device == nullptr) { - ALOGE("Failed to load %s fingerprint module", class_name); + ALOGE("Failed to load fpc fingerprint module"); } else { return fp_device; } + + fp_device = getDeviceForVendor("goodix"); + if (fp_device == nullptr) { + ALOGE("Failed to load goodix fingerprint module"); + } else { + return fp_device; + } + return nullptr; } diff --git a/biometrics/Hardware.h b/biometrics/Hardware.h deleted file mode 100644 index 90a60678..00000000 --- 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 - -#include - -#include - -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 */ diff --git a/biometrics/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660.rc b/biometrics/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660.rc index 00312b39..ba9d78f4 100644 --- a/biometrics/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660.rc +++ b/biometrics/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660.rc @@ -1,15 +1,31 @@ -on boot - # Fingerprint + +on init chown system system /dev/goodix_fp chmod 0644 /dev/goodix_fp + +on boot chown system system /sys/devices/soc/soc:fpc1020/fingerdown_wait + chown system system /sys/bus/platform/devices/soc:fpc1020/irq + chown system system /sys/bus/platform/devices/soc:fpc1020/wakeup_enable + chown system system /sys/bus/platform/devices/soc:fpc1020/hw_reset + chown system system /sys/bus/platform/devices/soc:fpc1020/device_prepare + chown system system /data/misc/fpc/calibration_image.pndat chmod 0220 /sys/devices/soc/soc:fpc1020/fingerdown_wait - chown system system /sys/devices/soc/soc:fpc1020/irq - chmod 0660 /sys/devices/soc/soc:fpc1020/irq - chown system system /sys/devices/soc/soc:fpc1020/hw_reset - chmod 0660 /sys/devices/soc/soc:fpc1020/hw_reset - chown system system /sys/devices/soc/soc:fpc1020/wakeup_enable - chmod 0660 /sys/devices/soc/soc:fpc1020/wakeup_enable + chmod 0700 /sys/bus/platform/devices/soc:fpc1020/irq + chmod 0700 /sys/bus/platform/devices/soc:fpc1020/wakeup_enable + chmod 0700 /sys/bus/platform/devices/soc:fpc1020/hw_reset + chmod 0700 /sys/bus/platform/devices/soc:fpc1020/device_prepare + chmod 0600 /data/misc/fpc/calibration_image.pndat + +on post-fs-data + mkdir /data/misc/fpc 0770 system system + mkdir /data/misc/goodix 0770 system system + mkdir /persist/fpc 0770 system system + mkdir /data/vendor/goodix 0770 system system + mkdir /data/vendor/fpc 0770 system system + copy /data/vendor/fpc/user.db /data/vendor_de/0/fpdata/user.db + chown system system /data/vendor_de/0/fpdata/user.db + rm /data/vendor/fpc/user.db service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660 class late_start diff --git a/biometrics/service.cpp b/biometrics/service.cpp index bf833b32..69690b18 100644 --- a/biometrics/service.cpp +++ b/biometrics/service.cpp @@ -17,32 +17,29 @@ #define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660" #include +#include #include - +#include +#include #include "BiometricsFingerprint.h" -// libhwbinder: -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; - -// Generated HIDL files using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint; using android::hardware::biometrics::fingerprint::V2_1::implementation::BiometricsFingerprint; +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; +using android::sp; int main() { - android::sp service = BiometricsFingerprint::getInstance(); - - if (service == nullptr) { - ALOGE("Instance of BiometricsFingerprint is null"); - return 1; - } + android::sp bio = BiometricsFingerprint::getInstance(); configureRpcThreadpool(1, true /*callerWillJoin*/); - android::status_t status = service->registerAsService(); - if (status != android::OK) { - ALOGE("Cannot register BiometricsFingerprint service"); - return 1; + if (bio != nullptr) { + if (::android::OK != bio->registerAsService()) { + return 1; + } + } else { + ALOGE("Can't create instance of BiometricsFingerprint, nullptr"); } joinRpcThreadpool();