dubai: Introduce biometric 2.3 hal

* wrap 2.1 hal and add additional function

Change-Id: I4a66760fb8ca88de4e9229b7aec90052470ce6f0
This commit is contained in:
TheScarastic 2022-09-23 16:05:58 +05:30 committed by Marc Bourgoin
parent 330d1745d6
commit da9f091436
7 changed files with 257 additions and 1 deletions

View file

@ -51,7 +51,7 @@ PRODUCT_COPY_FILES += \
# Fingerprint
PRODUCT_PACKAGES += \
android.hardware.biometrics.fingerprint@2.1.vendor
android.hardware.biometrics.fingerprint@2.3-service.dubai
# Init
$(foreach f,$(wildcard $(LOCAL_PATH)/rootdir/etc/init/hw/*.rc),\

21
fingerprint/Android.bp Normal file
View file

@ -0,0 +1,21 @@
cc_binary {
name: "android.hardware.biometrics.fingerprint@2.3-service.dubai",
defaults: ["hidl_defaults"],
init_rc: ["android.hardware.biometrics.fingerprint@2.3-service.dubai.rc"],
vintf_fragments: ["android.hardware.biometrics.fingerprint@2.3-service.dubai.xml"],
relative_install_path: "hw",
srcs: [
"service.cpp",
"BiometricsFingerprint.cpp",
],
vendor: true,
shared_libs: [
"libbase",
"libhidlbase",
"liblog",
"libutils",
"android.hardware.biometrics.fingerprint@2.1",
"android.hardware.biometrics.fingerprint@2.2",
"android.hardware.biometrics.fingerprint@2.3",
],
}

View file

@ -0,0 +1,97 @@
/*
* 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 "android.hardware.biometrics.fingerprint@2.3-service.dubai"
#include "BiometricsFingerprint.h"
#include <android-base/logging.h>
#include <fstream>
#include <cmath>
#include <thread>
#include <fcntl.h>
#include <poll.h>
#include <sys/stat.h>
namespace android {
namespace hardware {
namespace biometrics {
namespace fingerprint {
namespace V2_3 {
namespace implementation {
BiometricsFingerprint::BiometricsFingerprint() {
biometrics_2_1_service = IBiometricsFingerprint_2_1::getService();
}
Return<uint64_t> BiometricsFingerprint::setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
return biometrics_2_1_service->setNotify(clientCallback);
}
Return<uint64_t> BiometricsFingerprint::preEnroll() {
return biometrics_2_1_service->preEnroll();
}
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) {
return biometrics_2_1_service->enroll(hat, gid, timeoutSec);
}
Return<RequestStatus> BiometricsFingerprint::postEnroll() {
return biometrics_2_1_service->postEnroll();
}
Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
return biometrics_2_1_service->getAuthenticatorId();
}
Return<RequestStatus> BiometricsFingerprint::cancel() {
return biometrics_2_1_service->cancel();
}
Return<RequestStatus> BiometricsFingerprint::enumerate() {
return biometrics_2_1_service->enumerate();
}
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) {
return biometrics_2_1_service->remove(gid, fid);
}
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid, const hidl_string& storePath) {
return biometrics_2_1_service->setActiveGroup(gid, storePath);
}
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) {
return biometrics_2_1_service->authenticate(operationId, gid);
}
Return<bool> BiometricsFingerprint::isUdfps(uint32_t) {
return true;
}
Return<void> BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, float) {
return Void();
}
Return<void> BiometricsFingerprint::onFingerUp() {
return Void();
}
} // namespace implementation
} // namespace V2_3
} // namespace fingerprint
} // namespace biometrics
} // namespace hardware
} // namespace android

View file

@ -0,0 +1,71 @@
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
#include <android/hardware/biometrics/fingerprint/2.3/IBiometricsFingerprint.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace biometrics {
namespace fingerprint {
namespace V2_3 {
namespace implementation {
using IBiometricsFingerprint_2_1 = ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
struct BiometricsFingerprint : public IBiometricsFingerprint {
BiometricsFingerprint();
// Methods from ::V2_1::IBiometricsFingerprint follow.
Return<uint64_t> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
Return<uint64_t> preEnroll() override;
Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override;
Return<RequestStatus> postEnroll() override;
Return<uint64_t> getAuthenticatorId() override;
Return<RequestStatus> cancel() override;
Return<RequestStatus> enumerate() override;
Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
// ::V2_3::IBiometricsFingerprint follow.
Return<bool> isUdfps(uint32_t sensorId) override;
Return<void> onFingerDown(uint32_t x, uint32_t y, float minor, float major) override;
Return<void> onFingerUp() override;
private:
sp<IBiometricsFingerprint_2_1> biometrics_2_1_service;
};
} // namespace implementation
} // namespace V2_3
} // namespace fingerprint
} // namespace biometrics
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H

View file

@ -0,0 +1,8 @@
service fps_hal.dubai /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.3-service.dubai
# "class hal" causes a race condition on some devices due to files created
# in /data. As a workaround, postpone startup until later in boot once
# /data is mounted.
class late_start
user system
group system input uhid
writepid /dev/cpuset/system-background/tasks

View file

@ -0,0 +1,11 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>android.hardware.biometrics.fingerprint</name>
<transport>hwbinder</transport>
<version>2.3</version>
<interface>
<name>IBiometricsFingerprint</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

48
fingerprint/service.cpp Normal file
View file

@ -0,0 +1,48 @@
/*
* 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 "android.hardware.biometrics.fingerprint@2.3-service.dubai"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include "BiometricsFingerprint.h"
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
using android::hardware::biometrics::fingerprint::V2_3::implementation::BiometricsFingerprint;
using android::OK;
using android::status_t;
int main() {
android::sp<IBiometricsFingerprint> service = new BiometricsFingerprint();
configureRpcThreadpool(1, true);
status_t status = service->registerAsService();
if (status != OK) {
LOG(ERROR) << "Cannot register Biometrics 2.3 HAL service.";
return 1;
}
LOG(INFO) << "Biometrics 2.3 HAL service ready.";
joinRpcThreadpool();
LOG(ERROR) << "Biometrics 2.3 HAL service failed to join thread pool.";
return 1;
}