diff --git a/aidl/fingerprint/Android.bp b/aidl/fingerprint/Android.bp new file mode 100644 index 00000000..8bb8efd4 --- /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 00000000..2e2d660f --- /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 00000000..f4655d7a --- /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 00000000..3a1d9190 --- /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 00000000..0e314bfd --- /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 00000000..b54be823 --- /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 00000000..89da7656 --- /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 00000000..e904e9a0 --- /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 +}