blob: e81b18242a254cbda76b3b8a3e77e442d224961f [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>
Elliott Hughes07c08552015-01-29 21:19:10 -080019#include <malloc.h>
Sasha Levitskiya747c062014-03-24 16:14:42 -070020#include <string.h>
21#include <cutils/log.h>
22#include <hardware/hardware.h>
23#include <hardware/fingerprint.h>
24
25static int fingerprint_close(hw_device_t *dev)
26{
27 if (dev) {
28 free(dev);
29 return 0;
30 } else {
31 return -1;
32 }
33}
34
Sasha Levitskiy468b5672015-04-16 14:45:04 -070035
36static uint64_t fingerprint_pre_enroll(struct fingerprint_device __unused *dev) {
37 return FINGERPRINT_ERROR;
38}
39
Sasha Levitskiy73082842014-04-18 11:14:11 -070040static int fingerprint_enroll(struct fingerprint_device __unused *dev,
Sasha Levitskiy6eced702015-04-12 22:58:21 -070041 const hw_auth_token_t __unused *hat,
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080042 uint32_t __unused gid,
Sasha Levitskiy3b9ee8d2014-04-23 10:04:57 -070043 uint32_t __unused timeout_sec) {
Sasha Levitskiya747c062014-03-24 16:14:42 -070044 return FINGERPRINT_ERROR;
45}
46
Sasha Levitskiy468b5672015-04-16 14:45:04 -070047static uint64_t fingerprint_get_auth_id(struct fingerprint_device __unused *dev) {
48 return FINGERPRINT_ERROR;
49}
50
Jim Miller1e1f7ba2015-04-08 22:55:51 -070051static int fingerprint_cancel(struct fingerprint_device __unused *dev) {
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080052 return FINGERPRINT_ERROR;
53}
54
Sasha Levitskiy73082842014-04-18 11:14:11 -070055static int fingerprint_remove(struct fingerprint_device __unused *dev,
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080056 fingerprint_finger_id_t __unused fingerprint_id) {
57 return FINGERPRINT_ERROR;
58}
59
60static int fingerprint_set_active_group(struct fingerprint_device __unused *dev,
Sasha Levitskiya70ab952015-06-02 11:29:12 -070061 uint32_t __unused gid, const char __unused *store_path) {
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080062 return FINGERPRINT_ERROR;
63}
64
65static int fingerprint_authenticate(struct fingerprint_device __unused *dev,
Jim Miller1fb1e332015-03-24 19:25:47 -070066 uint64_t __unused operation_id, __unused uint32_t gid) {
Sasha Levitskiya747c062014-03-24 16:14:42 -070067 return FINGERPRINT_ERROR;
68}
69
Sasha Levitskiy73082842014-04-18 11:14:11 -070070static int set_notify_callback(struct fingerprint_device *dev,
71 fingerprint_notify_t notify) {
72 /* Decorate with locks */
73 dev->notify = notify;
Sasha Levitskiya747c062014-03-24 16:14:42 -070074 return FINGERPRINT_ERROR;
75}
76
Sasha Levitskiy73082842014-04-18 11:14:11 -070077static int fingerprint_open(const hw_module_t* module, const char __unused *id,
Sasha Levitskiya747c062014-03-24 16:14:42 -070078 hw_device_t** device)
79{
Sasha Levitskiya747c062014-03-24 16:14:42 -070080 if (device == NULL) {
81 ALOGE("NULL device on open");
82 return -EINVAL;
83 }
84
85 fingerprint_device_t *dev = malloc(sizeof(fingerprint_device_t));
86 memset(dev, 0, sizeof(fingerprint_device_t));
87
88 dev->common.tag = HARDWARE_DEVICE_TAG;
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080089 dev->common.version = FINGERPRINT_MODULE_API_VERSION_2_0;
Sasha Levitskiya747c062014-03-24 16:14:42 -070090 dev->common.module = (struct hw_module_t*) module;
91 dev->common.close = fingerprint_close;
92
Sasha Levitskiy468b5672015-04-16 14:45:04 -070093 dev->pre_enroll = fingerprint_pre_enroll;
Sasha Levitskiya747c062014-03-24 16:14:42 -070094 dev->enroll = fingerprint_enroll;
Sasha Levitskiy468b5672015-04-16 14:45:04 -070095 dev->get_authenticator_id = fingerprint_get_auth_id;
Jim Miller1e1f7ba2015-04-08 22:55:51 -070096 dev->cancel = fingerprint_cancel;
Sasha Levitskiya747c062014-03-24 16:14:42 -070097 dev->remove = fingerprint_remove;
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080098 dev->set_active_group = fingerprint_set_active_group;
99 dev->authenticate = fingerprint_authenticate;
Sasha Levitskiy73082842014-04-18 11:14:11 -0700100 dev->set_notify = set_notify_callback;
101 dev->notify = NULL;
Sasha Levitskiya747c062014-03-24 16:14:42 -0700102
103 *device = (hw_device_t*) dev;
104 return 0;
105}
106
107static struct hw_module_methods_t fingerprint_module_methods = {
108 .open = fingerprint_open,
109};
110
111fingerprint_module_t HAL_MODULE_INFO_SYM = {
112 .common = {
113 .tag = HARDWARE_MODULE_TAG,
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -0800114 .module_api_version = FINGERPRINT_MODULE_API_VERSION_2_0,
Sasha Levitskiya747c062014-03-24 16:14:42 -0700115 .hal_api_version = HARDWARE_HAL_API_VERSION,
116 .id = FINGERPRINT_HARDWARE_MODULE_ID,
117 .name = "Demo Fingerprint HAL",
118 .author = "The Android Open Source Project",
119 .methods = &fingerprint_module_methods,
120 },
121};