Added Fingerprint Virtual HAL AIDL extension

Bug: 326227403
Test: atest android.hardware.biometrics.fingerprint.* -c
Change-Id: I967c009c99f8dc279f89c21a59cf0462d9590296
diff --git a/biometrics/fingerprint/aidl/default/include/Fingerprint.h b/biometrics/fingerprint/aidl/default/include/Fingerprint.h
index 1576f07..90f89cb 100644
--- a/biometrics/fingerprint/aidl/default/include/Fingerprint.h
+++ b/biometrics/fingerprint/aidl/default/include/Fingerprint.h
@@ -40,6 +40,7 @@
                                      std::shared_ptr<ISession>* out) override;
     binder_status_t dump(int fd, const char** args, uint32_t numArgs);
     binder_status_t handleShellCommand(int in, int out, int err, const char** argv, uint32_t argc);
+    bool connected() { return mEngine != nullptr; }
 
     static FingerprintConfig& cfg() {
         static FingerprintConfig* cfg = nullptr;
@@ -49,9 +50,10 @@
         }
         return *cfg;
     }
+    void resetConfigToDefault();
+    static const char* type2String(FingerprintSensorType type);
 
   private:
-    void resetConfigToDefault();
     void onHelp(int);
     void onSimFingerDown();
     void clearConfigSysprop();
diff --git a/biometrics/fingerprint/aidl/default/include/VirtualHal.h b/biometrics/fingerprint/aidl/default/include/VirtualHal.h
new file mode 100644
index 0000000..6cc4b66
--- /dev/null
+++ b/biometrics/fingerprint/aidl/default/include/VirtualHal.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2024 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.
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/biometrics/fingerprint/BnVirtualHal.h>
+
+#include "Fingerprint.h"
+
+namespace aidl::android::hardware::biometrics::fingerprint {
+
+class VirtualHal : public BnVirtualHal {
+  public:
+    VirtualHal(Fingerprint* fp) : mFp(fp) {}
+
+    ::ndk::ScopedAStatus setEnrollments(const std::vector<int32_t>& in_id) override;
+    ::ndk::ScopedAStatus setEnrollmentHit(int32_t in_hit_id) override;
+    ::ndk::ScopedAStatus setAuthenticatorId(int64_t in_id) override;
+    ::ndk::ScopedAStatus setChallenge(int64_t in_challenge) override;
+    ::ndk::ScopedAStatus setOperationAuthenticateFails(bool in_fail) override;
+    ::ndk::ScopedAStatus setOperationAuthenticateLatency(
+            const std::vector<int32_t>& in_latency) override;
+    ::ndk::ScopedAStatus setOperationAuthenticateDuration(int32_t in_duration) override;
+    ::ndk::ScopedAStatus setOperationAuthenticateError(int32_t in_error) override;
+    ::ndk::ScopedAStatus setOperationAuthenticateAcquired(
+            const std::vector<int32_t>& in_acquired) override;
+    ::ndk::ScopedAStatus setOperationEnrollError(int32_t in_error) override;
+    ::ndk::ScopedAStatus setOperationEnrollLatency(const std::vector<int32_t>& in_latency) override;
+    ::ndk::ScopedAStatus setOperationDetectInteractionLatency(
+            const std::vector<int32_t>& in_latency) override;
+    ::ndk::ScopedAStatus setOperationDetectInteractionError(int32_t in_error) override;
+    ::ndk::ScopedAStatus setOperationDetectInteractionDuration(int32_t in_duration) override;
+    ::ndk::ScopedAStatus setOperationDetectInteractionAcquired(
+            const std::vector<int32_t>& in_acquired) override;
+    ::ndk::ScopedAStatus setLockout(bool in_lockout) override;
+    ::ndk::ScopedAStatus setLockoutEnable(bool in_enable) override;
+    ::ndk::ScopedAStatus setLockoutTimedThreshold(int32_t in_threshold) override;
+    ::ndk::ScopedAStatus setLockoutTimedDuration(int32_t in_duration) override;
+    ::ndk::ScopedAStatus setLockoutPermanentThreshold(int32_t in_threshold) override;
+    ::ndk::ScopedAStatus setType(
+            ::aidl::android::hardware::biometrics::fingerprint::FingerprintSensorType in_type)
+            override;
+    ::ndk::ScopedAStatus setSensorId(int32_t in_id) override;
+    ::ndk::ScopedAStatus setSensorStrength(SensorStrength in_strength) override;
+    ::ndk::ScopedAStatus setMaxEnrollmentPerUser(int32_t in_max) override;
+    ::ndk::ScopedAStatus setSensorLocation(
+            const ::aidl::android::hardware::biometrics::fingerprint::SensorLocation& in_loc)
+            override;
+    ::ndk::ScopedAStatus setNavigationGuesture(bool in_v) override;
+    ::ndk::ScopedAStatus setDetectInteraction(bool in_v) override;
+    ::ndk::ScopedAStatus setDisplayTouch(bool in_v) override;
+    ::ndk::ScopedAStatus setControlIllumination(bool in_v) override;
+
+  private:
+    OptIntVec intVec2OptIntVec(const std::vector<int32_t>& intVec);
+    ::ndk::ScopedAStatus sanityCheckLatency(const std::vector<int32_t>& in_latency);
+    Fingerprint* mFp;
+};
+
+}  // namespace aidl::android::hardware::biometrics::fingerprint