blob: 8f4bca6655fec9e6082f5c105cc3c21e812e5764 [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>
Mark Salyzynd88dfe82017-04-11 08:56:09 -070020#include <stdint.h>
Sasha Levitskiya747c062014-03-24 16:14:42 -070021#include <string.h>
Mark Salyzynd88dfe82017-04-11 08:56:09 -070022
23#include <log/log.h>
24
Sasha Levitskiya747c062014-03-24 16:14:42 -070025#include <hardware/fingerprint.h>
Mark Salyzynd88dfe82017-04-11 08:56:09 -070026#include <hardware/hardware.h>
Sasha Levitskiya747c062014-03-24 16:14:42 -070027
28static int fingerprint_close(hw_device_t *dev)
29{
30 if (dev) {
31 free(dev);
32 return 0;
33 } else {
34 return -1;
35 }
36}
37
Sasha Levitskiy468b5672015-04-16 14:45:04 -070038
39static uint64_t fingerprint_pre_enroll(struct fingerprint_device __unused *dev) {
40 return FINGERPRINT_ERROR;
41}
42
Sasha Levitskiy73082842014-04-18 11:14:11 -070043static int fingerprint_enroll(struct fingerprint_device __unused *dev,
Sasha Levitskiy6eced702015-04-12 22:58:21 -070044 const hw_auth_token_t __unused *hat,
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080045 uint32_t __unused gid,
Sasha Levitskiy3b9ee8d2014-04-23 10:04:57 -070046 uint32_t __unused timeout_sec) {
Sasha Levitskiya747c062014-03-24 16:14:42 -070047 return FINGERPRINT_ERROR;
48}
49
Sasha Levitskiy468b5672015-04-16 14:45:04 -070050static uint64_t fingerprint_get_auth_id(struct fingerprint_device __unused *dev) {
51 return FINGERPRINT_ERROR;
52}
53
Jim Miller1e1f7ba2015-04-08 22:55:51 -070054static int fingerprint_cancel(struct fingerprint_device __unused *dev) {
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080055 return FINGERPRINT_ERROR;
56}
57
Sasha Levitskiy73082842014-04-18 11:14:11 -070058static int fingerprint_remove(struct fingerprint_device __unused *dev,
Sasha Levitskiyd4331fd2015-06-08 13:14:15 -070059 uint32_t __unused gid, uint32_t __unused fid) {
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080060 return FINGERPRINT_ERROR;
61}
62
63static int fingerprint_set_active_group(struct fingerprint_device __unused *dev,
Sasha Levitskiya70ab952015-06-02 11:29:12 -070064 uint32_t __unused gid, const char __unused *store_path) {
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080065 return FINGERPRINT_ERROR;
66}
67
68static int fingerprint_authenticate(struct fingerprint_device __unused *dev,
Jim Miller1fb1e332015-03-24 19:25:47 -070069 uint64_t __unused operation_id, __unused uint32_t gid) {
Sasha Levitskiya747c062014-03-24 16:14:42 -070070 return FINGERPRINT_ERROR;
71}
72
Sasha Levitskiy73082842014-04-18 11:14:11 -070073static int set_notify_callback(struct fingerprint_device *dev,
74 fingerprint_notify_t notify) {
75 /* Decorate with locks */
76 dev->notify = notify;
Sasha Levitskiya747c062014-03-24 16:14:42 -070077 return FINGERPRINT_ERROR;
78}
79
Sasha Levitskiy73082842014-04-18 11:14:11 -070080static int fingerprint_open(const hw_module_t* module, const char __unused *id,
Sasha Levitskiya747c062014-03-24 16:14:42 -070081 hw_device_t** device)
82{
Sasha Levitskiya747c062014-03-24 16:14:42 -070083 if (device == NULL) {
84 ALOGE("NULL device on open");
85 return -EINVAL;
86 }
87
88 fingerprint_device_t *dev = malloc(sizeof(fingerprint_device_t));
89 memset(dev, 0, sizeof(fingerprint_device_t));
90
91 dev->common.tag = HARDWARE_DEVICE_TAG;
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -080092 dev->common.version = FINGERPRINT_MODULE_API_VERSION_2_0;
Sasha Levitskiya747c062014-03-24 16:14:42 -070093 dev->common.module = (struct hw_module_t*) module;
94 dev->common.close = fingerprint_close;
95
Sasha Levitskiy468b5672015-04-16 14:45:04 -070096 dev->pre_enroll = fingerprint_pre_enroll;
Sasha Levitskiya747c062014-03-24 16:14:42 -070097 dev->enroll = fingerprint_enroll;
Sasha Levitskiy468b5672015-04-16 14:45:04 -070098 dev->get_authenticator_id = fingerprint_get_auth_id;
Jim Miller1e1f7ba2015-04-08 22:55:51 -070099 dev->cancel = fingerprint_cancel;
Sasha Levitskiya747c062014-03-24 16:14:42 -0700100 dev->remove = fingerprint_remove;
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -0800101 dev->set_active_group = fingerprint_set_active_group;
102 dev->authenticate = fingerprint_authenticate;
Sasha Levitskiy73082842014-04-18 11:14:11 -0700103 dev->set_notify = set_notify_callback;
104 dev->notify = NULL;
Sasha Levitskiya747c062014-03-24 16:14:42 -0700105
106 *device = (hw_device_t*) dev;
107 return 0;
108}
109
110static struct hw_module_methods_t fingerprint_module_methods = {
111 .open = fingerprint_open,
112};
113
114fingerprint_module_t HAL_MODULE_INFO_SYM = {
115 .common = {
116 .tag = HARDWARE_MODULE_TAG,
Sasha Levitskiy3b7402e2014-12-11 06:49:36 -0800117 .module_api_version = FINGERPRINT_MODULE_API_VERSION_2_0,
Sasha Levitskiya747c062014-03-24 16:14:42 -0700118 .hal_api_version = HARDWARE_HAL_API_VERSION,
119 .id = FINGERPRINT_HARDWARE_MODULE_ID,
120 .name = "Demo Fingerprint HAL",
121 .author = "The Android Open Source Project",
122 .methods = &fingerprint_module_methods,
123 },
124};