From 37b235d802f9edebbefd86e8e601dfa77b12bcb0 Mon Sep 17 00:00:00 2001 From: Tim Zimmermann Date: Thu, 18 Jan 2024 06:29:15 +0100 Subject: [PATCH] aidl: fingerprint: Initial stub service Change-Id: I1e0594b88d5230f8c99a6efb0a7dafcbf6ea137a --- aidl/fingerprint/Android.bp | 26 ++++ aidl/fingerprint/Fingerprint.cpp | 29 +++++ aidl/fingerprint/Fingerprint.h | 33 +++++ aidl/fingerprint/Session.cpp | 115 ++++++++++++++++++ aidl/fingerprint/Session.h | 62 ++++++++++ ....biometrics.fingerprint-service.samsung.rc | 5 + ...biometrics.fingerprint-service.samsung.xml | 6 + aidl/fingerprint/service.cpp | 25 ++++ 8 files changed, 301 insertions(+) create mode 100644 aidl/fingerprint/Android.bp create mode 100644 aidl/fingerprint/Fingerprint.cpp create mode 100644 aidl/fingerprint/Fingerprint.h create mode 100644 aidl/fingerprint/Session.cpp create mode 100644 aidl/fingerprint/Session.h create mode 100644 aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.rc create mode 100644 aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.xml create mode 100644 aidl/fingerprint/service.cpp diff --git a/aidl/fingerprint/Android.bp b/aidl/fingerprint/Android.bp new file mode 100644 index 0000000..8bb8efd --- /dev/null +++ b/aidl/fingerprint/Android.bp @@ -0,0 +1,26 @@ +// +// Copyright (C) 2024 The LineageOS Project +// +// SPDX-License-Identifier: Apache-2.0 +// + +cc_binary { + name: "android.hardware.biometrics.fingerprint-service.samsung", + relative_install_path: "hw", + init_rc: ["android.hardware.biometrics.fingerprint-service.samsung.rc"], + vintf_fragments: ["android.hardware.biometrics.fingerprint-service.samsung.xml"], + srcs: [ + "Fingerprint.cpp", + "Session.cpp", + "service.cpp", + ], + shared_libs: [ + "libbase", + "libbinder_ndk", + "android.hardware.biometrics.fingerprint-V3-ndk", + "android.hardware.biometrics.common-V3-ndk", + "android.hardware.biometrics.common.thread", + "android.hardware.biometrics.common.util", + ], + vendor: true, +} diff --git a/aidl/fingerprint/Fingerprint.cpp b/aidl/fingerprint/Fingerprint.cpp new file mode 100644 index 0000000..2e2d660 --- /dev/null +++ b/aidl/fingerprint/Fingerprint.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "Fingerprint.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace biometrics { +namespace fingerprint { + +ndk::ScopedAStatus Fingerprint::getSensorProps(std::vector* /*out*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Fingerprint::createSession(int32_t /*sensorId*/, int32_t /*userId*/, + const std::shared_ptr& /*cb*/, + std::shared_ptr* /*out*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +} // namespace fingerprint +} // namespace biometrics +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/aidl/fingerprint/Fingerprint.h b/aidl/fingerprint/Fingerprint.h new file mode 100644 index 0000000..f4655d7 --- /dev/null +++ b/aidl/fingerprint/Fingerprint.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +using ::aidl::android::hardware::biometrics::fingerprint::ISession; +using ::aidl::android::hardware::biometrics::fingerprint::ISessionCallback; +using ::aidl::android::hardware::biometrics::fingerprint::SensorProps; + +namespace aidl { +namespace android { +namespace hardware { +namespace biometrics { +namespace fingerprint { + +class Fingerprint : public BnFingerprint { +public: + ndk::ScopedAStatus getSensorProps(std::vector* _aidl_return) override; + ndk::ScopedAStatus createSession(int32_t sensorId, int32_t userId, + const std::shared_ptr& cb, + std::shared_ptr* out) override; +}; + +} // namespace fingerprint +} // namespace biometrics +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/aidl/fingerprint/Session.cpp b/aidl/fingerprint/Session.cpp new file mode 100644 index 0000000..3a1d919 --- /dev/null +++ b/aidl/fingerprint/Session.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2024 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "Session.h" + +namespace aidl { +namespace android { +namespace hardware { +namespace biometrics { +namespace fingerprint { + +ndk::ScopedAStatus Session::generateChallenge() { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::revokeChallenge(int64_t /*challenge*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::enroll(const HardwareAuthToken& /*hat*/, + std::shared_ptr* /*out*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::authenticate(int64_t /*operationId*/, + std::shared_ptr* /*out*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::detectInteraction(std::shared_ptr* /*out*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::enumerateEnrollments() { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::removeEnrollments(const std::vector& /*enrollmentIds*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::getAuthenticatorId() { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::invalidateAuthenticatorId() { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::resetLockout(const HardwareAuthToken& /*hat*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::close() { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::onPointerDown(int32_t /*pointerId*/, int32_t /*x*/, int32_t /*y*/, float /*minor*/, + float /*major*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::onPointerUp(int32_t /*pointerId*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::onUiReady() { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::authenticateWithContext( + int64_t /*operationId*/, const OperationContext& /*context*/, + std::shared_ptr* /*out*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::enrollWithContext(const HardwareAuthToken& /*hat*/, + const OperationContext& /*context*/, + std::shared_ptr* /*out*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::detectInteractionWithContext(const OperationContext& /*context*/, + std::shared_ptr* /*out*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::onPointerDownWithContext(const PointerContext& /*context*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::onPointerUpWithContext(const PointerContext& /*context*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::onContextChanged(const OperationContext& /*context*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::onPointerCancelWithContext(const PointerContext& /*context*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +ndk::ScopedAStatus Session::setIgnoreDisplayTouches(bool /*shouldIgnore*/) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + +} // namespace fingerprint +} // namespace biometrics +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/aidl/fingerprint/Session.h b/aidl/fingerprint/Session.h new file mode 100644 index 0000000..0e314bf --- /dev/null +++ b/aidl/fingerprint/Session.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2024 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +using ::aidl::android::hardware::biometrics::common::ICancellationSignal; +using ::aidl::android::hardware::biometrics::common::OperationContext; +using ::aidl::android::hardware::biometrics::fingerprint::PointerContext; +using ::aidl::android::hardware::keymaster::HardwareAuthToken; + +namespace aidl { +namespace android { +namespace hardware { +namespace biometrics { +namespace fingerprint { + +class Session : public BnSession { +public: + ndk::ScopedAStatus generateChallenge() override; + ndk::ScopedAStatus revokeChallenge(int64_t challenge) override; + ndk::ScopedAStatus enroll(const HardwareAuthToken& hat, + std::shared_ptr* out) override; + ndk::ScopedAStatus authenticate(int64_t operationId, + std::shared_ptr* out) override; + ndk::ScopedAStatus detectInteraction( + std::shared_ptr* out) override; + ndk::ScopedAStatus enumerateEnrollments() override; + ndk::ScopedAStatus removeEnrollments(const std::vector& enrollmentIds) override; + ndk::ScopedAStatus getAuthenticatorId() override; + ndk::ScopedAStatus invalidateAuthenticatorId() override; + ndk::ScopedAStatus resetLockout(const HardwareAuthToken& hat) override; + ndk::ScopedAStatus close() override; + ndk::ScopedAStatus onPointerDown(int32_t pointerId, int32_t x, int32_t y, float minor, + float major) override; + ndk::ScopedAStatus onPointerUp(int32_t pointerId) override; + ndk::ScopedAStatus onUiReady() override; + ndk::ScopedAStatus authenticateWithContext( + int64_t operationId, const OperationContext& context, + std::shared_ptr* out) override; + ndk::ScopedAStatus enrollWithContext( + const HardwareAuthToken& hat, const OperationContext& context, + std::shared_ptr* out) override; + ndk::ScopedAStatus detectInteractionWithContext( + const OperationContext& context, + std::shared_ptr* out) override; + ndk::ScopedAStatus onPointerDownWithContext(const PointerContext& context) override; + ndk::ScopedAStatus onPointerUpWithContext(const PointerContext& context) override; + ndk::ScopedAStatus onContextChanged(const OperationContext& context) override; + ndk::ScopedAStatus onPointerCancelWithContext(const PointerContext& context) override; + ndk::ScopedAStatus setIgnoreDisplayTouches(bool shouldIgnore) override; +}; + +} // namespace fingerprint +} // namespace biometrics +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.rc b/aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.rc new file mode 100644 index 0000000..b54be82 --- /dev/null +++ b/aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.rc @@ -0,0 +1,5 @@ +service vendor.fingerprint-default /vendor/bin/hw/android.hardware.biometrics.fingerprint-service.samsung + class hal + user system + group system input uhid + shutdown critical diff --git a/aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.xml b/aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.xml new file mode 100644 index 0000000..89da765 --- /dev/null +++ b/aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.xml @@ -0,0 +1,6 @@ + + + android.hardware.biometrics.fingerprint + IFingerprint/default + + diff --git a/aidl/fingerprint/service.cpp b/aidl/fingerprint/service.cpp new file mode 100644 index 0000000..e904e9a --- /dev/null +++ b/aidl/fingerprint/service.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "Fingerprint.h" + +#include +#include +#include + +using ::aidl::android::hardware::biometrics::fingerprint::Fingerprint; + +int main() { + ABinderProcess_setThreadPoolMaxThreadCount(0); + std::shared_ptr fingerprint = ndk::SharedRefBase::make(); + + const std::string instance = std::string() + Fingerprint::descriptor + "/default"; + binder_status_t status = AServiceManager_addService(fingerprint->asBinder().get(), instance.c_str()); + CHECK(status == STATUS_OK); + + ABinderProcess_joinThreadPool(); + return EXIT_FAILURE; // should not reach +} -- 2.20.1