forked from EnJens/vendor-sony-oss-fingerprint
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathservice.cpp
98 lines (84 loc) · 3.1 KB
/
service.cpp
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
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "[email protected]"
#include "BiometricsFingerprint.h"
#include "egistec/current/BiometricsFingerprint.h"
#include "egistec/legacy/BiometricsFingerprint.h"
#include "egistec/legacy/EGISAPTrustlet.h"
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
using android::NO_ERROR;
using android::sp;
using android::status_t;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using FPCHAL = ::fpc::BiometricsFingerprint;
using LegacyEgistecHAL = ::egistec::legacy::BiometricsFingerprint;
using CurrentEgistecHAL = ::egistec::current::BiometricsFingerprint;
int main() {
android::sp<IBiometricsFingerprint> bio;
#if defined(FINGERPRINT_TYPE_EGISTEC)
::egistec::EgisFpDevice dev;
#endif
#if defined(HAS_LEGACY_EGISTEC)
auto type = dev.GetHwId();
bool is_old_hal;
switch (type) {
case egistec::FpHwId::Egistec:
ALOGI("Egistec sensor installed");
{
::egistec::legacy::EGISAPTrustlet trustlet;
is_old_hal = trustlet.MatchFirmware();
// Scope closes trustlet. While this could be reused,
// opt for starting fresh in case the command introduces
// unexpected state changes.
}
if (is_old_hal) {
ALOGI("Using legacy Egistec (Nile) HAL");
bio = new LegacyEgistecHAL(std::move(dev));
} else {
ALOGI("Using new Egistec (Ganges+) HAL on Nile");
bio = new CurrentEgistecHAL(std::move(dev));
}
break;
case egistec::FpHwId::Fpc:
ALOGI("FPC sensor installed");
bio = new FPCHAL();
break;
default:
ALOGE("No HAL instance defined for hardware type %d", type);
return 1;
}
#elif defined(FINGERPRINT_TYPE_EGISTEC)
bio = new CurrentEgistecHAL(std::move(dev));
#else
bio = new FPCHAL();
#endif
configureRpcThreadpool(1, true /*callerWillJoin*/);
if (bio != nullptr) {
status_t status = bio->registerAsService();
if (status != NO_ERROR) {
ALOGE("Cannot start fingerprint service: %d", status);
return 1;
}
} else {
ALOGE("Can't create instance of BiometricsFingerprint, nullptr");
return 1;
}
joinRpcThreadpool();
return 0; // should never get here
}