From a747c069c6b3f5a6420662020822992cc70384bc Mon Sep 17 00:00:00 2001 From: Sasha Levitskiy Date: Mon, 24 Mar 2014 16:14:42 -0700 Subject: Hardware: Fingerprint: Introducing Fingerprint HAL Change-Id: I4e55c42841c3b6a1327a16bdf6d1d4bb3847c7f3 Signed-off-by: Sasha Levitskiy --- modules/fingerprint/Android.mk | 25 +++++++++++ modules/fingerprint/fingerprint.c | 93 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 modules/fingerprint/Android.mk create mode 100644 modules/fingerprint/fingerprint.c (limited to 'modules/fingerprint') diff --git a/modules/fingerprint/Android.mk b/modules/fingerprint/Android.mk new file mode 100644 index 0000000..58c0a83 --- /dev/null +++ b/modules/fingerprint/Android.mk @@ -0,0 +1,25 @@ +# Copyright (C) 2013 The Android Open Source 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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := fingerprint.default +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := fingerprint.c +LOCAL_SHARED_LIBRARIES := liblog +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) diff --git a/modules/fingerprint/fingerprint.c b/modules/fingerprint/fingerprint.c new file mode 100644 index 0000000..3bdcdab --- /dev/null +++ b/modules/fingerprint/fingerprint.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2014 The Android Open Source 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 "FingerprintHal" + +#include +#include +#include +#include +#include + +static int fingerprint_close(hw_device_t *dev) +{ + if (dev) { + free(dev); + return 0; + } else { + return -1; + } +} + +static fingerprint_msg_t fingerprint_enroll(unsigned timeout_sec, + unsigned *data) { + (void)timeout_sec; + (void)data; + return FINGERPRINT_ERROR; +} + +static fingerprint_msg_t fingerprint_remove(unsigned fingerprint_id) { + (void)fingerprint_id; + return FINGERPRINT_ERROR; +} + +static fingerprint_msg_t fingerprint_match(unsigned fingerprint_id, + unsigned timeout_sec) { + (void)fingerprint_id; + (void)timeout_sec; + return FINGERPRINT_ERROR; +} + +static int fingerprint_open(const hw_module_t* module, const char* id, + hw_device_t** device) +{ + (void)id; + + if (device == NULL) { + ALOGE("NULL device on open"); + return -EINVAL; + } + + fingerprint_device_t *dev = malloc(sizeof(fingerprint_device_t)); + memset(dev, 0, sizeof(fingerprint_device_t)); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = (struct hw_module_t*) module; + dev->common.close = fingerprint_close; + + dev->enroll = fingerprint_enroll; + dev->remove = fingerprint_remove; + dev->match = fingerprint_match; + + *device = (hw_device_t*) dev; + return 0; +} + +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_1_0, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = FINGERPRINT_HARDWARE_MODULE_ID, + .name = "Demo Fingerprint HAL", + .author = "The Android Open Source Project", + .methods = &fingerprint_module_methods, + }, +}; -- cgit v1.1