1/*
2 * Copyright (C) 2015 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
17#ifndef IFINGERPRINT_DAEMON_H_
18#define IFINGERPRINT_DAEMON_H_
19
20#include <binder/IInterface.h>
21#include <binder/Parcel.h>
22
23namespace android {
24
25class IFingerprintDaemonCallback;
26
27/*
28* Abstract base class for native implementation of FingerprintService.
29*
30* Note: This must be kept manually in sync with IFingerprintDaemon.aidl
31*/
32class IFingerprintDaemon : public IInterface, public IBinder::DeathRecipient {
33    public:
34        enum {
35           AUTHENTICATE = IBinder::FIRST_CALL_TRANSACTION + 0,
36           CANCEL_AUTHENTICATION = IBinder::FIRST_CALL_TRANSACTION + 1,
37           ENROLL = IBinder::FIRST_CALL_TRANSACTION + 2,
38           CANCEL_ENROLLMENT = IBinder::FIRST_CALL_TRANSACTION + 3,
39           PRE_ENROLL = IBinder::FIRST_CALL_TRANSACTION + 4,
40           REMOVE = IBinder::FIRST_CALL_TRANSACTION + 5,
41           GET_AUTHENTICATOR_ID = IBinder::FIRST_CALL_TRANSACTION + 6,
42           SET_ACTIVE_GROUP = IBinder::FIRST_CALL_TRANSACTION + 7,
43           OPEN_HAL = IBinder::FIRST_CALL_TRANSACTION + 8,
44           CLOSE_HAL = IBinder::FIRST_CALL_TRANSACTION + 9,
45           INIT = IBinder::FIRST_CALL_TRANSACTION + 10,
46           POST_ENROLL = IBinder::FIRST_CALL_TRANSACTION + 11,
47           ENUMERATE = IBinder::FIRST_CALL_TRANSACTION + 12,
48        };
49
50        IFingerprintDaemon() { }
51        virtual ~IFingerprintDaemon() { }
52        virtual const android::String16& getInterfaceDescriptor() const;
53
54        // Binder interface methods
55        virtual void init(const sp<IFingerprintDaemonCallback>& callback) = 0;
56        virtual int32_t enroll(const uint8_t* token, ssize_t tokenLength, int32_t groupId,
57                int32_t timeout) = 0;
58        virtual uint64_t preEnroll() = 0;
59        virtual int32_t postEnroll() = 0;
60        virtual int32_t stopEnrollment() = 0;
61        virtual int32_t authenticate(uint64_t sessionId, uint32_t groupId) = 0;
62        virtual int32_t stopAuthentication() = 0;
63        virtual int32_t remove(int32_t fingerId, int32_t groupId) = 0;
64        virtual int32_t enumerate() = 0;
65        virtual uint64_t getAuthenticatorId() = 0;
66        virtual int32_t setActiveGroup(int32_t groupId, const uint8_t* path, ssize_t pathLen) = 0;
67        virtual int64_t openHal() = 0;
68        virtual int32_t closeHal() = 0;
69
70        // DECLARE_META_INTERFACE - C++ client interface not needed
71        static const android::String16 descriptor;
72        static void hal_notify_callback(const fingerprint_msg_t *msg);
73};
74
75// ----------------------------------------------------------------------------
76
77class BnFingerprintDaemon: public BnInterface<IFingerprintDaemon> {
78    public:
79       virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply,
80               uint32_t flags = 0);
81    private:
82       bool checkPermission(const String16& permission);
83};
84
85} // namespace android
86
87#endif // IFINGERPRINT_DAEMON_H_
88
89