• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 <malloc.h>
20 #include <stdint.h>
21 #include <string.h>
22 
23 #include <log/log.h>
24 
25 #include <hardware/fingerprint.h>
26 #include <hardware/hardware.h>
27 
fingerprint_close(hw_device_t * dev)28 static 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 
38 
fingerprint_pre_enroll(struct fingerprint_device __unused * dev)39 static uint64_t fingerprint_pre_enroll(struct fingerprint_device __unused *dev) {
40     return FINGERPRINT_ERROR;
41 }
42 
fingerprint_enroll(struct fingerprint_device __unused * dev,const hw_auth_token_t __unused * hat,uint32_t __unused gid,uint32_t __unused timeout_sec)43 static int fingerprint_enroll(struct fingerprint_device __unused *dev,
44                                 const hw_auth_token_t __unused *hat,
45                                 uint32_t __unused gid,
46                                 uint32_t __unused timeout_sec) {
47     return FINGERPRINT_ERROR;
48 }
49 
fingerprint_get_auth_id(struct fingerprint_device __unused * dev)50 static uint64_t fingerprint_get_auth_id(struct fingerprint_device __unused *dev) {
51     return FINGERPRINT_ERROR;
52 }
53 
fingerprint_cancel(struct fingerprint_device __unused * dev)54 static int fingerprint_cancel(struct fingerprint_device __unused *dev) {
55     return FINGERPRINT_ERROR;
56 }
57 
fingerprint_remove(struct fingerprint_device __unused * dev,uint32_t __unused gid,uint32_t __unused fid)58 static int fingerprint_remove(struct fingerprint_device __unused *dev,
59                                 uint32_t __unused gid, uint32_t __unused fid) {
60     return FINGERPRINT_ERROR;
61 }
62 
fingerprint_set_active_group(struct fingerprint_device __unused * dev,uint32_t __unused gid,const char __unused * store_path)63 static int fingerprint_set_active_group(struct fingerprint_device __unused *dev,
64                                         uint32_t __unused gid, const char __unused *store_path) {
65     return FINGERPRINT_ERROR;
66 }
67 
fingerprint_authenticate(struct fingerprint_device __unused * dev,uint64_t __unused operation_id,__unused uint32_t gid)68 static int fingerprint_authenticate(struct fingerprint_device __unused *dev,
69                                     uint64_t __unused operation_id, __unused uint32_t gid) {
70     return FINGERPRINT_ERROR;
71 }
72 
set_notify_callback(struct fingerprint_device * dev,fingerprint_notify_t notify)73 static int set_notify_callback(struct fingerprint_device *dev,
74                                 fingerprint_notify_t notify) {
75     /* Decorate with locks */
76     dev->notify = notify;
77     return FINGERPRINT_ERROR;
78 }
79 
fingerprint_open(const hw_module_t * module,const char __unused * id,hw_device_t ** device)80 static int fingerprint_open(const hw_module_t* module, const char __unused *id,
81                             hw_device_t** device)
82 {
83     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;
92     dev->common.version = FINGERPRINT_MODULE_API_VERSION_2_0;
93     dev->common.module = (struct hw_module_t*) module;
94     dev->common.close = fingerprint_close;
95 
96     dev->pre_enroll = fingerprint_pre_enroll;
97     dev->enroll = fingerprint_enroll;
98     dev->get_authenticator_id = fingerprint_get_auth_id;
99     dev->cancel = fingerprint_cancel;
100     dev->remove = fingerprint_remove;
101     dev->set_active_group = fingerprint_set_active_group;
102     dev->authenticate = fingerprint_authenticate;
103     dev->set_notify = set_notify_callback;
104     dev->notify = NULL;
105 
106     *device = (hw_device_t*) dev;
107     return 0;
108 }
109 
110 static struct hw_module_methods_t fingerprint_module_methods = {
111     .open = fingerprint_open,
112 };
113 
114 fingerprint_module_t HAL_MODULE_INFO_SYM = {
115     .common = {
116         .tag                = HARDWARE_MODULE_TAG,
117         .module_api_version = FINGERPRINT_MODULE_API_VERSION_2_0,
118         .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 };
125