sdm660-common: Update Fingerprint HIDL HAL
This commit is contained in:
parent
3ac541f522
commit
53e8ac411a
5 changed files with 60 additions and 114 deletions
|
@ -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,
|
||||
|
||||
}
|
||||
|
|
|
@ -15,15 +15,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660"
|
||||
|
||||
#include <cutils/properties.h>
|
||||
#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660"
|
||||
|
||||
#include <hardware/hw_auth_token.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/fingerprint.h>
|
||||
#include "BiometricsFingerprint.h"
|
||||
#include "Hardware.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
|
@ -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
|
||||
|
|
|
@ -17,32 +17,29 @@
|
|||
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_sdm660"
|
||||
|
||||
#include <android/log.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
|
||||
#include <android/hardware/biometrics/fingerprint/2.1/types.h>
|
||||
#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<IBiometricsFingerprint> service = BiometricsFingerprint::getInstance();
|
||||
|
||||
if (service == nullptr) {
|
||||
ALOGE("Instance of BiometricsFingerprint is null");
|
||||
return 1;
|
||||
}
|
||||
android::sp<IBiometricsFingerprint> 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();
|
||||
|
|
Loading…
Reference in a new issue