blob: 5488383a69039a10824f40f01a5fbdd26b6dca94 [file] [log] [blame]
Jeff Pudf81c962024-03-06 10:58:17 -05001/*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
Jeff Pue0263c42024-07-17 12:33:29 -040019#include <aidl/android/hardware/biometrics/fingerprint/virtualhal/BnVirtualHal.h>
Jeff Pudf81c962024-03-06 10:58:17 -050020
21#include "Fingerprint.h"
22
23namespace aidl::android::hardware::biometrics::fingerprint {
24
Jeff Pue0263c42024-07-17 12:33:29 -040025using namespace virtualhal;
26
Jeff Pudf81c962024-03-06 10:58:17 -050027class VirtualHal : public BnVirtualHal {
28 public:
Jeff Pue0263c42024-07-17 12:33:29 -040029 VirtualHal(std::shared_ptr<Fingerprint> fp) : mFp(fp) {}
Jeff Pudf81c962024-03-06 10:58:17 -050030
31 ::ndk::ScopedAStatus setEnrollments(const std::vector<int32_t>& in_id) override;
32 ::ndk::ScopedAStatus setEnrollmentHit(int32_t in_hit_id) override;
Jeff Pue0263c42024-07-17 12:33:29 -040033 ::ndk::ScopedAStatus setNextEnrollment(const NextEnrollment& in_next_enrollment) override;
Jeff Pudf81c962024-03-06 10:58:17 -050034 ::ndk::ScopedAStatus setAuthenticatorId(int64_t in_id) override;
35 ::ndk::ScopedAStatus setChallenge(int64_t in_challenge) override;
36 ::ndk::ScopedAStatus setOperationAuthenticateFails(bool in_fail) override;
37 ::ndk::ScopedAStatus setOperationAuthenticateLatency(
38 const std::vector<int32_t>& in_latency) override;
39 ::ndk::ScopedAStatus setOperationAuthenticateDuration(int32_t in_duration) override;
40 ::ndk::ScopedAStatus setOperationAuthenticateError(int32_t in_error) override;
41 ::ndk::ScopedAStatus setOperationAuthenticateAcquired(
Jeff Pu3bc1f062024-04-19 19:37:45 +000042 const std::vector<AcquiredInfoAndVendorCode>& in_acquired) override;
Jeff Pudf81c962024-03-06 10:58:17 -050043 ::ndk::ScopedAStatus setOperationEnrollError(int32_t in_error) override;
44 ::ndk::ScopedAStatus setOperationEnrollLatency(const std::vector<int32_t>& in_latency) override;
45 ::ndk::ScopedAStatus setOperationDetectInteractionLatency(
46 const std::vector<int32_t>& in_latency) override;
47 ::ndk::ScopedAStatus setOperationDetectInteractionError(int32_t in_error) override;
48 ::ndk::ScopedAStatus setOperationDetectInteractionDuration(int32_t in_duration) override;
49 ::ndk::ScopedAStatus setOperationDetectInteractionAcquired(
Jeff Pu3bc1f062024-04-19 19:37:45 +000050 const std::vector<AcquiredInfoAndVendorCode>& in_acquired) override;
Jeff Pudf81c962024-03-06 10:58:17 -050051 ::ndk::ScopedAStatus setLockout(bool in_lockout) override;
52 ::ndk::ScopedAStatus setLockoutEnable(bool in_enable) override;
53 ::ndk::ScopedAStatus setLockoutTimedThreshold(int32_t in_threshold) override;
54 ::ndk::ScopedAStatus setLockoutTimedDuration(int32_t in_duration) override;
55 ::ndk::ScopedAStatus setLockoutPermanentThreshold(int32_t in_threshold) override;
Jeff Pu3bc1f062024-04-19 19:37:45 +000056 ::ndk::ScopedAStatus resetConfigurations() override;
Jeff Pudf81c962024-03-06 10:58:17 -050057 ::ndk::ScopedAStatus setType(
58 ::aidl::android::hardware::biometrics::fingerprint::FingerprintSensorType in_type)
59 override;
60 ::ndk::ScopedAStatus setSensorId(int32_t in_id) override;
61 ::ndk::ScopedAStatus setSensorStrength(SensorStrength in_strength) override;
62 ::ndk::ScopedAStatus setMaxEnrollmentPerUser(int32_t in_max) override;
63 ::ndk::ScopedAStatus setSensorLocation(
64 const ::aidl::android::hardware::biometrics::fingerprint::SensorLocation& in_loc)
65 override;
66 ::ndk::ScopedAStatus setNavigationGuesture(bool in_v) override;
67 ::ndk::ScopedAStatus setDetectInteraction(bool in_v) override;
68 ::ndk::ScopedAStatus setDisplayTouch(bool in_v) override;
69 ::ndk::ScopedAStatus setControlIllumination(bool in_v) override;
Jeff Pue0263c42024-07-17 12:33:29 -040070 ::ndk::ScopedAStatus getFingerprintHal(
71 std::shared_ptr<::aidl::android::hardware::biometrics::fingerprint::IFingerprint>*
72 _aidl_return);
Jeff Pudf81c962024-03-06 10:58:17 -050073
74 private:
75 OptIntVec intVec2OptIntVec(const std::vector<int32_t>& intVec);
Jeff Pu3bc1f062024-04-19 19:37:45 +000076 OptIntVec acquiredInfoVec2OptIntVec(const std::vector<AcquiredInfoAndVendorCode>& intVec);
Jeff Pudf81c962024-03-06 10:58:17 -050077 ::ndk::ScopedAStatus sanityCheckLatency(const std::vector<int32_t>& in_latency);
Jeff Pue0263c42024-07-17 12:33:29 -040078 std::shared_ptr<Fingerprint> mFp;
Jeff Pudf81c962024-03-06 10:58:17 -050079};
80
81} // namespace aidl::android::hardware::biometrics::fingerprint