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 <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 35 36static uint64_t fingerprint_pre_enroll(struct fingerprint_device __unused *dev) { 37 return FINGERPRINT_ERROR; 38} 39 40static int fingerprint_enroll(struct fingerprint_device __unused *dev, 41 const hw_auth_token_t __unused *hat, 42 uint32_t __unused gid, 43 uint32_t __unused timeout_sec) { 44 return FINGERPRINT_ERROR; 45} 46 47static uint64_t fingerprint_get_auth_id(struct fingerprint_device __unused *dev) { 48 return FINGERPRINT_ERROR; 49} 50 51static int fingerprint_cancel(struct fingerprint_device __unused *dev) { 52 return FINGERPRINT_ERROR; 53} 54 55static int fingerprint_remove(struct fingerprint_device __unused *dev, 56 uint32_t __unused gid, uint32_t __unused fid) { 57 return FINGERPRINT_ERROR; 58} 59 60static int fingerprint_set_active_group(struct fingerprint_device __unused *dev, 61 uint32_t __unused gid, const char __unused *store_path) { 62 return FINGERPRINT_ERROR; 63} 64 65static int fingerprint_authenticate(struct fingerprint_device __unused *dev, 66 uint64_t __unused operation_id, __unused uint32_t gid) { 67 return FINGERPRINT_ERROR; 68} 69 70static int set_notify_callback(struct fingerprint_device *dev, 71 fingerprint_notify_t notify) { 72 /* Decorate with locks */ 73 dev->notify = notify; 74 return FINGERPRINT_ERROR; 75} 76 77static int fingerprint_open(const hw_module_t* module, const char __unused *id, 78 hw_device_t** device) 79{ 80 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; 89 dev->common.version = FINGERPRINT_MODULE_API_VERSION_2_0; 90 dev->common.module = (struct hw_module_t*) module; 91 dev->common.close = fingerprint_close; 92 93 dev->pre_enroll = fingerprint_pre_enroll; 94 dev->enroll = fingerprint_enroll; 95 dev->get_authenticator_id = fingerprint_get_auth_id; 96 dev->cancel = fingerprint_cancel; 97 dev->remove = fingerprint_remove; 98 dev->set_active_group = fingerprint_set_active_group; 99 dev->authenticate = fingerprint_authenticate; 100 dev->set_notify = set_notify_callback; 101 dev->notify = NULL; 102 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, 114 .module_api_version = FINGERPRINT_MODULE_API_VERSION_2_0, 115 .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}; 122