aidl: fingerprint: Initial stub service
authorTim Zimmermann <tim@linux4.de>
Thu, 18 Jan 2024 05:29:15 +0000 (06:29 +0100)
committerTim Zimmermann <tim@linux4.de>
Sat, 20 Jan 2024 12:52:29 +0000 (13:52 +0100)
Change-Id: I1e0594b88d5230f8c99a6efb0a7dafcbf6ea137a

aidl/fingerprint/Android.bp [new file with mode: 0644]
aidl/fingerprint/Fingerprint.cpp [new file with mode: 0644]
aidl/fingerprint/Fingerprint.h [new file with mode: 0644]
aidl/fingerprint/Session.cpp [new file with mode: 0644]
aidl/fingerprint/Session.h [new file with mode: 0644]
aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.rc [new file with mode: 0644]
aidl/fingerprint/android.hardware.biometrics.fingerprint-service.samsung.xml [new file with mode: 0644]
aidl/fingerprint/service.cpp [new file with mode: 0644]

diff --git a/aidl/fingerprint/Android.bp b/aidl/fingerprint/Android.bp
new file mode 100644 (file)
index 0000000..8bb8efd
--- /dev/null
@@ -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 (file)
index 0000000..2e2d660
--- /dev/null
@@ -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<SensorProps>* /*out*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Fingerprint::createSession(int32_t /*sensorId*/, int32_t /*userId*/,
+                                              const std::shared_ptr<ISessionCallback>& /*cb*/,
+                                              std::shared_ptr<ISession>* /*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 (file)
index 0000000..f4655d7
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2024 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/biometrics/fingerprint/BnFingerprint.h>
+
+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<SensorProps>* _aidl_return) override;
+    ndk::ScopedAStatus createSession(int32_t sensorId, int32_t userId,
+                                     const std::shared_ptr<ISessionCallback>& cb,
+                                     std::shared_ptr<ISession>* 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 (file)
index 0000000..3a1d919
--- /dev/null
@@ -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<ICancellationSignal>* /*out*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Session::authenticate(int64_t /*operationId*/,
+                                         std::shared_ptr<ICancellationSignal>* /*out*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Session::detectInteraction(std::shared_ptr<ICancellationSignal>* /*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<int32_t>& /*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<ICancellationSignal>* /*out*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Session::enrollWithContext(const HardwareAuthToken& /*hat*/,
+                                              const OperationContext& /*context*/,
+                                              std::shared_ptr<ICancellationSignal>* /*out*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Session::detectInteractionWithContext(const OperationContext& /*context*/,
+                                              std::shared_ptr<ICancellationSignal>* /*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 (file)
index 0000000..0e314bf
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2024 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/biometrics/fingerprint/BnSession.h>
+
+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<ICancellationSignal>* out) override;
+    ndk::ScopedAStatus authenticate(int64_t operationId,
+                                    std::shared_ptr<ICancellationSignal>* out) override;
+    ndk::ScopedAStatus detectInteraction(
+            std::shared_ptr<ICancellationSignal>* out) override;
+    ndk::ScopedAStatus enumerateEnrollments() override;
+    ndk::ScopedAStatus removeEnrollments(const std::vector<int32_t>& 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<ICancellationSignal>* out) override;
+    ndk::ScopedAStatus enrollWithContext(
+            const HardwareAuthToken& hat, const OperationContext& context,
+            std::shared_ptr<ICancellationSignal>* out) override;
+    ndk::ScopedAStatus detectInteractionWithContext(
+            const OperationContext& context,
+            std::shared_ptr<ICancellationSignal>* 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 (file)
index 0000000..b54be82
--- /dev/null
@@ -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 (file)
index 0000000..89da765
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest version="1.0" type="device">
+    <hal format="aidl">
+        <name>android.hardware.biometrics.fingerprint</name>
+        <fqname>IFingerprint/default</fqname>
+    </hal>
+</manifest>
diff --git a/aidl/fingerprint/service.cpp b/aidl/fingerprint/service.cpp
new file mode 100644 (file)
index 0000000..e904e9a
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2024 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "Fingerprint.h"
+
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <android-base/logging.h>
+
+using ::aidl::android::hardware::biometrics::fingerprint::Fingerprint;
+
+int main() {
+    ABinderProcess_setThreadPoolMaxThreadCount(0);
+    std::shared_ptr<Fingerprint> fingerprint = ndk::SharedRefBase::make<Fingerprint>();
+
+    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
+}