blob: 3bdcdabf5bbf897a98b2ba6c009fbfa24876068b [file] [log] [blame]
Sasha Levitskiya747c062014-03-24 16:14:42 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#define LOG_TAG "FingerprintHal"
17
18#include <errno.h>
19#include <string.h>
20#include <cutils/log.h>
21#include <hardware/hardware.h>
22#include <hardware/fingerprint.h>
23
24static int fingerprint_close(hw_device_t *dev)
25{
26 if (dev) {
27 free(dev);
28 return 0;
29 } else {
30 return -1;
31 }
32}
33
34static fingerprint_msg_t fingerprint_enroll(unsigned timeout_sec,
35 unsigned *data) {
36 (void)timeout_sec;
37 (void)data;
38 return FINGERPRINT_ERROR;
39}
40
41static fingerprint_msg_t fingerprint_remove(unsigned fingerprint_id) {
42 (void)fingerprint_id;
43 return FINGERPRINT_ERROR;
44}
45
46static fingerprint_msg_t fingerprint_match(unsigned fingerprint_id,
47 unsigned timeout_sec) {
48 (void)fingerprint_id;
49 (void)timeout_sec;
50 return FINGERPRINT_ERROR;
51}
52
53static int fingerprint_open(const hw_module_t* module, const char* id,
54 hw_device_t** device)
55{
56 (void)id;
57
58 if (device == NULL) {
59 ALOGE("NULL device on open");
60 return -EINVAL;
61 }
62
63 fingerprint_device_t *dev = malloc(sizeof(fingerprint_device_t));
64 memset(dev, 0, sizeof(fingerprint_device_t));
65
66 dev->common.tag = HARDWARE_DEVICE_TAG;
67 dev->common.version = 0;
68 dev->common.module = (struct hw_module_t*) module;
69 dev->common.close = fingerprint_close;
70
71 dev->enroll = fingerprint_enroll;
72 dev->remove = fingerprint_remove;
73 dev->match = fingerprint_match;
74
75 *device = (hw_device_t*) dev;
76 return 0;
77}
78
79static struct hw_module_methods_t fingerprint_module_methods = {
80 .open = fingerprint_open,
81};
82
83fingerprint_module_t HAL_MODULE_INFO_SYM = {
84 .common = {
85 .tag = HARDWARE_MODULE_TAG,
86 .module_api_version = FINGERPRINT_MODULE_API_VERSION_1_0,
87 .hal_api_version = HARDWARE_HAL_API_VERSION,
88 .id = FINGERPRINT_HARDWARE_MODULE_ID,
89 .name = "Demo Fingerprint HAL",
90 .author = "The Android Open Source Project",
91 .methods = &fingerprint_module_methods,
92 },
93};