File: biometry.h

package info (click to toggle)
biometryd 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,524 kB
  • sloc: cpp: 10,213; ansic: 191; python: 42; makefile: 33
file content (154 lines) | stat: -rw-r--r-- 5,237 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 * Copyright © 2020 UBports foundation Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Erfan Abdi <erfangplus@gmail.com>
 */

#ifndef BIOMETRY_HARDWARE_BIOMETRY_H_
#define BIOMETRY_HARDWARE_BIOMETRY_H_

#include <biometry/visibility.h>

#include <stdint.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef int UHardwareBiometryFingerprintAcquiredInfo;
enum
{
    ACQUIRED_GOOD = 0,
    /** sensor needs more data, i.e. longer swipe. */
    ACQUIRED_PARTIAL = 1,
    /**
     * image doesn't contain enough detail for recognition*/
    ACQUIRED_INSUFFICIENT = 2,
    /** sensor needs to be cleaned */
    ACQUIRED_IMAGER_DIRTY = 3,
    /** mostly swipe-type sensors; not enough data collected */
    ACQUIRED_TOO_SLOW = 4,
    /** vendor-specific acquisition messages start here */
    ACQUIRED_TOO_FAST = 5,
    /** vendor-specific acquisition messages */
    ACQUIRED_VENDOR = 6
};

typedef int UHardwareBiometryFingerprintError;
enum
{
    /** Used for testing, no error returned */
    ERROR_NO_ERROR = 0,
    /** The hardware has an error that can't be resolved. */
    ERROR_HW_UNAVAILABLE = 1,
    /** Bad data; operation can't continue */
    ERROR_UNABLE_TO_PROCESS = 2,
    /** The operation has timed out waiting for user input. */
    ERROR_TIMEOUT = 3,
    /** No space available to store a template */
    ERROR_NO_SPACE = 4,
    /** The current operation has been canceled */
    ERROR_CANCELED = 5,
    /** Unable to remove a template */
    ERROR_UNABLE_TO_REMOVE = 6,
    /** The hardware is in lockout due to too many attempts */
    ERROR_LOCKOUT = 7,
    /** Vendor-specific error message */
    ERROR_VENDOR = 8
};

typedef int UHardwareBiometryRequestStatus;
enum
{
    SYS_UNKNOWN = 1,
    SYS_OK = 0,
    SYS_ENOENT = -2,
    SYS_EINTR = -4,
    SYS_EIO = -5,
    SYS_EAGAIN = -11,
    SYS_ENOMEM = -12,
    SYS_EACCES = -13,
    SYS_EFAULT = -14,
    SYS_EBUSY = -16,
    SYS_EINVAL = -22,
    SYS_ENOSPC = -28,
    SYS_ETIMEDOUT = -110,
};

typedef struct UHardwareBiometry_* UHardwareBiometry;
typedef struct UHardwareBiometryCallback_* UHardwareBiometryCallback;

typedef void (*UHardwareBiometryEnrollResult)(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining, void *context);
typedef void (*UHardwareBiometryAcquired)(uint64_t deviceId, UHardwareBiometryFingerprintAcquiredInfo acquiredInfo, int32_t vendorCode, void *context);
typedef void (*UHardwareBiometryAuthenticated)(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, void *context);
typedef void (*UHardwareBiometryError)(uint64_t deviceId, UHardwareBiometryFingerprintError error, int32_t vendorCode, void *context);
typedef void (*UHardwareBiometryRemoved)(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining, void *context);
typedef void (*UHardwareBiometryEnumerate)(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining, void *context);

typedef struct
{
    UHardwareBiometryEnrollResult enrollresult_cb;
    UHardwareBiometryAcquired acquired_cb;
    UHardwareBiometryAuthenticated authenticated_cb;
    UHardwareBiometryError error_cb;
    UHardwareBiometryRemoved removed_cb;
    UHardwareBiometryEnumerate enumerate_cb;

    void* context;
} UHardwareBiometryParams;

/*
 You must create only one instance per process/application.
*/

BIOMETRY_DLL_PUBLIC UHardwareBiometry
u_hardware_biometry_new();

BIOMETRY_DLL_PUBLIC uint64_t
u_hardware_biometry_setNotify(UHardwareBiometry self, UHardwareBiometryParams *params);

BIOMETRY_DLL_PUBLIC uint64_t
u_hardware_biometry_preEnroll(UHardwareBiometry self);

BIOMETRY_DLL_PUBLIC UHardwareBiometryRequestStatus
u_hardware_biometry_enroll(UHardwareBiometry self, uint32_t gid, uint32_t timeoutSec, uint32_t uid);

BIOMETRY_DLL_PUBLIC UHardwareBiometryRequestStatus
u_hardware_biometry_postEnroll(UHardwareBiometry self);

BIOMETRY_DLL_PUBLIC uint64_t
u_hardware_biometry_getAuthenticatorId(UHardwareBiometry self);

BIOMETRY_DLL_PUBLIC UHardwareBiometryRequestStatus
u_hardware_biometry_cancel(UHardwareBiometry self);

BIOMETRY_DLL_PUBLIC UHardwareBiometryRequestStatus
u_hardware_biometry_enumerate(UHardwareBiometry self);

BIOMETRY_DLL_PUBLIC UHardwareBiometryRequestStatus
u_hardware_biometry_remove(UHardwareBiometry self, uint32_t gid, uint32_t fid);

BIOMETRY_DLL_PUBLIC UHardwareBiometryRequestStatus
u_hardware_biometry_setActiveGroup(UHardwareBiometry self, uint32_t gid, char *storePath);

BIOMETRY_DLL_PUBLIC UHardwareBiometryRequestStatus
u_hardware_biometry_authenticate(UHardwareBiometry self, uint64_t operationId, uint32_t gid);

#ifdef __cplusplus
}
#endif

#endif // BIOMETRY_HARDWARE_BIOMETRY_H_