blob: ac7e35bc09a52a87013b95f758c72f912951fbc6 [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 Levitskiy73082842014-04-18 11:14:11 -070035static int fingerprint_enroll(struct fingerprint_device __unused *dev,
Sasha Levitskiy6eced702015-04-12 22:58:21 -070036 const hw_auth_token_t __unused *hat,
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080037 uint32_t __unused gid,
Sasha Levitskiy3b9ee8d2014-04-23 10:04:57 -070038 uint32_t __unused timeout_sec) {
Sasha Levitskiya747c062014-03-24 16:14:42 -070039 return FINGERPRINT_ERROR;
40}
41
Jim Miller1e1f7ba2015-04-08 22:55:51 -070042static int fingerprint_cancel(struct fingerprint_device __unused *dev) {
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080043 return FINGERPRINT_ERROR;
44}
45
Sasha Levitskiy73082842014-04-18 11:14:11 -070046static int fingerprint_remove(struct fingerprint_device __unused *dev,
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080047 fingerprint_finger_id_t __unused fingerprint_id) {
48 return FINGERPRINT_ERROR;
49}
50
51static int fingerprint_set_active_group(struct fingerprint_device __unused *dev,
52 uint32_t __unused gid) {
53 return FINGERPRINT_ERROR;
54}
55
56static int fingerprint_authenticate(struct fingerprint_device __unused *dev,
Jim Miller1fb1e332015-03-24 19:25:47 -070057 uint64_t __unused operation_id, __unused uint32_t gid) {
Sasha Levitskiya747c062014-03-24 16:14:42 -070058 return FINGERPRINT_ERROR;
59}
60
Sasha Levitskiy73082842014-04-18 11:14:11 -070061static int set_notify_callback(struct fingerprint_device *dev,
62 fingerprint_notify_t notify) {
63 /* Decorate with locks */
64 dev->notify = notify;
Sasha Levitskiya747c062014-03-24 16:14:42 -070065 return FINGERPRINT_ERROR;
66}
67
Sasha Levitskiy73082842014-04-18 11:14:11 -070068static int fingerprint_open(const hw_module_t* module, const char __unused *id,
Sasha Levitskiya747c062014-03-24 16:14:42 -070069 hw_device_t** device)
70{
Sasha Levitskiya747c062014-03-24 16:14:42 -070071 if (device == NULL) {
72 ALOGE("NULL device on open");
73 return -EINVAL;
74 }
75
76 fingerprint_device_t *dev = malloc(sizeof(fingerprint_device_t));
77 memset(dev, 0, sizeof(fingerprint_device_t));
78
79 dev->common.tag = HARDWARE_DEVICE_TAG;
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080080 dev->common.version = FINGERPRINT_MODULE_API_VERSION_2_0;
Sasha Levitskiya747c062014-03-24 16:14:42 -070081 dev->common.module = (struct hw_module_t*) module;
82 dev->common.close = fingerprint_close;
83
84 dev->enroll = fingerprint_enroll;
Jim Miller1e1f7ba2015-04-08 22:55:51 -070085 dev->cancel = fingerprint_cancel;
Sasha Levitskiya747c062014-03-24 16:14:42 -070086 dev->remove = fingerprint_remove;
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080087 dev->set_active_group = fingerprint_set_active_group;
88 dev->authenticate = fingerprint_authenticate;
Sasha Levitskiy73082842014-04-18 11:14:11 -070089 dev->set_notify = set_notify_callback;
90 dev->notify = NULL;
Sasha Levitskiya747c062014-03-24 16:14:42 -070091
92 *device = (hw_device_t*) dev;
93 return 0;
94}
95
96static struct hw_module_methods_t fingerprint_module_methods = {
97 .open = fingerprint_open,
98};
99
100fingerprint_module_t HAL_MODULE_INFO_SYM = {
101 .common = {
102 .tag = HARDWARE_MODULE_TAG,
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -0800103 .module_api_version = FINGERPRINT_MODULE_API_VERSION_2_0,
Sasha Levitskiya747c062014-03-24 16:14:42 -0700104 .hal_api_version = HARDWARE_HAL_API_VERSION,
105 .id = FINGERPRINT_HARDWARE_MODULE_ID,
106 .name = "Demo Fingerprint HAL",
107 .author = "The Android Open Source Project",
108 .methods = &fingerprint_module_methods,
109 },
110};