summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Chan <jc@linux.com>2017-02-05 21:18:09 +0800
committerPaul Keith <javelinanddart@aidenswann.com>2017-02-09 17:29:54 +0000
commitb23aaf793db4eabe9110affb9695ae99a1f68d2f (patch)
tree9cf945566a9a828ca721b98239c9ba901ad2eb4c
parent650848675d4a888cbf377290c69e5a941bfcb25d (diff)
downloadandroid_hardware_samsung-b23aaf793db4eabe9110affb9695ae99a1f68d2f.tar.gz
android_hardware_samsung-b23aaf793db4eabe9110affb9695ae99a1f68d2f.tar.bz2
android_hardware_samsung-b23aaf793db4eabe9110affb9695ae99a1f68d2f.zip
add Samsung BAUTH Fingerprint HAL
Change-Id: I3c0d3e2a0f9b77f0202cbdb0a75a00b760afcd8c
-rw-r--r--Android.mk1
-rw-r--r--fingerprint/Android.mk5
-rw-r--r--fingerprint/bauth/Android.mk15
-rw-r--r--fingerprint/bauth/fingerprint.c193
4 files changed, 214 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
index e08de6d..fa697a2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -40,6 +40,7 @@ include $(SAM_ROOT)/AdvancedDisplay/Android.mk
include $(SAM_ROOT)/audio/Android.mk
include $(SAM_ROOT)/consumerir/Android.mk
include $(SAM_ROOT)/dtbhtool/Android.mk
+include $(SAM_ROOT)/fingerprint/Android.mk
include $(SAM_ROOT)/liblights/Android.mk
include $(SAM_ROOT)/modemloader/Android.mk
include $(SAM_ROOT)/power/Android.mk
diff --git a/fingerprint/Android.mk b/fingerprint/Android.mk
new file mode 100644
index 0000000..51fd331
--- /dev/null
+++ b/fingerprint/Android.mk
@@ -0,0 +1,5 @@
+FP_ROOT := $(call my-dir)
+
+ifneq ($(TARGET_SEC_FP_HAL_VARIANT),)
+include $(FP_ROOT)/$(TARGET_SEC_FP_HAL_VARIANT)/Android.mk
+endif
diff --git a/fingerprint/bauth/Android.mk b/fingerprint/bauth/Android.mk
new file mode 100644
index 0000000..e4041da
--- /dev/null
+++ b/fingerprint/bauth/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ fingerprint.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libhardware liblog
+
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_MODULE := fingerprint.$(TARGET_BOARD_PLATFORM)
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/fingerprint/bauth/fingerprint.c b/fingerprint/bauth/fingerprint.c
new file mode 100644
index 0000000..55a56b8
--- /dev/null
+++ b/fingerprint/bauth/fingerprint.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2017 Jesse Chan, 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.
+ */
+
+#define LOG_TAG "SS Fingerprint HAL"
+
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <cutils/log.h>
+
+#include <hardware/hardware.h>
+#include <hardware/fingerprint.h>
+#include <utils/threads.h>
+
+typedef struct {
+ void *libhandle;
+ int (*ss_fingerprint_close)(void);
+ uint64_t (*ss_fingerprint_pre_enroll)(void);
+ int (*ss_fingerprint_enroll)(const hw_auth_token_t *hat, uint32_t gid, uint32_t timeout_sec);
+ int (*ss_fingerprint_post_enroll)(void);
+ uint64_t (*ss_fingerprint_get_auth_id)(void);
+ int (*ss_fingerprint_remove)(uint32_t gid, uint32_t fid);
+ int (*ss_fingerprint_set_active_group)(uint32_t gid, const char *store_path);
+ int (*ss_fingerprint_authenticate)(uint64_t operation_id, uint32_t gid);
+ int (*ss_set_notify_callback)(fingerprint_notify_t notify);
+ int (*ss_fingerprint_cancel)(void);
+ int (*ss_fingerprint_open)(const char *id);
+} bauth_server_handle_t;
+
+bauth_server_handle_t* bauth_handle;
+
+static int load_bauth_server(void)
+{
+ bauth_handle = (bauth_server_handle_t *)malloc(sizeof(bauth_server_handle_t));
+ if (bauth_handle == NULL)
+ goto no_memory;
+
+ void *libhandle = bauth_handle->libhandle;
+
+ libhandle = dlopen("libbauthserver.so", RTLD_NOW);
+ bauth_handle->ss_fingerprint_close = dlsym(libhandle, "ss_fingerprint_close");
+ bauth_handle->ss_fingerprint_pre_enroll = dlsym(libhandle, "ss_fingerprint_pre_enroll");
+ bauth_handle->ss_fingerprint_enroll = dlsym(libhandle, "ss_fingerprint_enroll");
+ bauth_handle->ss_fingerprint_post_enroll = dlsym(libhandle, "ss_fingerprint_post_enroll");
+ bauth_handle->ss_fingerprint_get_auth_id = dlsym(libhandle, "ss_fingerprint_get_auth_id");
+ bauth_handle->ss_fingerprint_remove = dlsym(libhandle, "ss_fingerprint_remove");
+ bauth_handle->ss_fingerprint_set_active_group = dlsym(libhandle, "ss_fingerprint_set_active_group");
+ bauth_handle->ss_fingerprint_authenticate = dlsym(libhandle, "ss_fingerprint_authenticate");
+ bauth_handle->ss_set_notify_callback = dlsym(libhandle, "ss_set_notify_callback");
+ bauth_handle->ss_fingerprint_cancel = dlsym(libhandle, "ss_fingerprint_cancel");
+ bauth_handle->ss_fingerprint_open = dlsym(libhandle, "ss_fingerprint_open");
+
+ return 0;
+
+no_memory:
+ ALOGE("%s: not enough memory to load the libhandle", __func__);
+ return -ENOMEM;
+}
+
+static int fingerprint_close(hw_device_t *dev)
+{
+ bauth_handle->ss_fingerprint_close();
+
+ if (dev)
+ free(dev);
+
+ return 0;
+}
+
+static uint64_t fingerprint_pre_enroll(struct fingerprint_device __unused *dev)
+{
+ return bauth_handle->ss_fingerprint_pre_enroll();
+}
+
+static int fingerprint_enroll(struct fingerprint_device __unused *dev, const hw_auth_token_t *hat,
+ uint32_t gid, uint32_t timeout_sec)
+{
+ return bauth_handle->ss_fingerprint_enroll(hat, gid, timeout_sec);
+}
+
+static int fingerprint_post_enroll(struct fingerprint_device __unused *dev)
+{
+ return bauth_handle->ss_fingerprint_post_enroll();
+}
+
+static uint64_t fingerprint_get_auth_id(struct fingerprint_device __unused *dev)
+{
+ return bauth_handle->ss_fingerprint_get_auth_id();
+}
+
+static int fingerprint_cancel(struct fingerprint_device __unused *dev)
+{
+ return bauth_handle->ss_fingerprint_cancel();
+}
+
+static int fingerprint_remove(struct fingerprint_device __unused *dev, uint32_t gid, uint32_t fid)
+{
+ return bauth_handle->ss_fingerprint_remove(gid, fid);
+}
+
+static int fingerprint_set_active_group(struct fingerprint_device __unused *dev, uint32_t gid,
+ const char *store_path)
+{
+ return bauth_handle->ss_fingerprint_set_active_group(gid, store_path);
+}
+
+static int fingerprint_authenticate(struct fingerprint_device __unused *dev, uint64_t operation_id,
+ uint32_t gid)
+{
+ return bauth_handle->ss_fingerprint_authenticate(operation_id, gid);
+}
+
+static int set_notify_callback(struct fingerprint_device *dev, fingerprint_notify_t notify)
+{
+ /* Decorate with locks */
+ dev->notify = notify;
+ return bauth_handle->ss_set_notify_callback(notify);
+}
+
+static int fingerprint_open(const hw_module_t* module, const char *id, hw_device_t** device)
+{
+ int ret;
+ fingerprint_device_t *dev = NULL;
+
+ if (device == NULL) {
+ ALOGE("NULL device on open");
+ ret = -ENODEV;
+ goto fail;
+ }
+
+ ret = load_bauth_server();
+ if (ret < 0)
+ goto fail;
+
+ dev = (fingerprint_device_t*)calloc(1, sizeof(fingerprint_device_t));
+ if (dev == NULL) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+
+ dev->common.tag = HARDWARE_DEVICE_TAG;
+ dev->common.version = FINGERPRINT_MODULE_API_VERSION_2_0;
+ dev->common.module = (struct hw_module_t*) module;
+ dev->common.close = fingerprint_close;
+
+ dev->pre_enroll = fingerprint_pre_enroll;
+ dev->enroll = fingerprint_enroll;
+ dev->post_enroll = fingerprint_post_enroll;
+ dev->get_authenticator_id = fingerprint_get_auth_id;
+ dev->cancel = fingerprint_cancel;
+ dev->remove = fingerprint_remove;
+ dev->set_active_group = fingerprint_set_active_group;
+ dev->authenticate = fingerprint_authenticate;
+ dev->set_notify = set_notify_callback;
+ dev->notify = NULL;
+
+ *device = (hw_device_t*) dev;
+ return (*bauth_handle->ss_fingerprint_open)(id);
+
+fail:
+ ALOGE("%s: failed to open FP device (ret=%d)", __func__, ret);
+ return ret;
+}
+
+static struct hw_module_methods_t fingerprint_module_methods = {
+ .open = fingerprint_open,
+};
+
+fingerprint_module_t HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = FINGERPRINT_MODULE_API_VERSION_2_0,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = FINGERPRINT_HARDWARE_MODULE_ID,
+ .name = "Samsung TZ Fingerprint HAL",
+ .author = "The LineageOS Project",
+ .methods = &fingerprint_module_methods,
+ },
+};