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 FINGERPRINT_DAEMON_PROXY_H_
18 #define FINGERPRINT_DAEMON_PROXY_H_
19 
20 #include "IFingerprintDaemon.h"
21 #include "IFingerprintDaemonCallback.h"
22 
23 namespace android {
24 
25 class FingerprintDaemonProxy : public BnFingerprintDaemon {
26     public:
getInstance()27         static FingerprintDaemonProxy* getInstance() {
28             if (sInstance == NULL) {
29                 sInstance = new FingerprintDaemonProxy();
30             }
31             return sInstance;
32         }
33 
34         // These reflect binder methods.
35         virtual void init(const sp<IFingerprintDaemonCallback>& callback);
36         virtual int32_t enroll(const uint8_t* token, ssize_t tokenLength, int32_t groupId, int32_t timeout);
37         virtual uint64_t preEnroll();
38         virtual int32_t postEnroll();
39         virtual int32_t stopEnrollment();
40         virtual int32_t authenticate(uint64_t sessionId, uint32_t groupId);
41         virtual int32_t stopAuthentication();
42         virtual int32_t remove(int32_t fingerId, int32_t groupId);
43         virtual int32_t enumerate();
44         virtual uint64_t getAuthenticatorId();
45         virtual int32_t setActiveGroup(int32_t groupId, const uint8_t* path, ssize_t pathLen);
46         virtual int64_t openHal();
47         virtual int32_t closeHal();
48 
49     private:
50         FingerprintDaemonProxy();
51         virtual ~FingerprintDaemonProxy();
52         void binderDied(const wp<IBinder>& who);
53         void notifyKeystore(const uint8_t *auth_token, const size_t auth_token_length);
54         static void hal_notify_callback(const fingerprint_msg_t *msg);
55 
56         static FingerprintDaemonProxy* sInstance;
57         fingerprint_module_t const* mModule;
58         fingerprint_device_t* mDevice;
59         sp<IFingerprintDaemonCallback> mCallback;
60 };
61 
62 } // namespace android
63 
64 #endif // FINGERPRINT_DAEMON_PROXY_H_
65