blob: 9db17d2df982efc81d526d643d5e161c22220964 [file] [log] [blame]
Ilya Matyukhin09166982020-10-12 13:41:03 -07001/*
2 * Copyright (C) 2020 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
Ilya Matyukhin60406be2021-07-03 00:04:43 +000019#include <random>
20
Ilya Matyukhin09166982020-10-12 13:41:03 -070021#include <aidl/android/hardware/biometrics/face/BnSession.h>
22#include <aidl/android/hardware/biometrics/face/ISessionCallback.h>
23
24namespace aidl::android::hardware::biometrics::face {
25
26namespace common = aidl::android::hardware::biometrics::common;
27namespace keymaster = aidl::android::hardware::keymaster;
28
29using aidl::android::hardware::common::NativeHandle;
30
31class Session : public BnSession {
32 public:
33 explicit Session(std::shared_ptr<ISessionCallback> cb);
34
Ilya Matyukhin66c64642021-03-23 22:33:31 -070035 ndk::ScopedAStatus generateChallenge() override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070036
Ilya Matyukhin66c64642021-03-23 22:33:31 -070037 ndk::ScopedAStatus revokeChallenge(int64_t challenge) override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070038
Ilya Matyukhin929146e2021-04-22 00:29:01 -070039 ndk::ScopedAStatus getEnrollmentConfig(EnrollmentType enrollmentType,
40 std::vector<EnrollmentStageConfig>* return_val) override;
41
Ilya Matyukhin66c64642021-03-23 22:33:31 -070042 ndk::ScopedAStatus enroll(const keymaster::HardwareAuthToken& hat,
Ilya Matyukhin26b20b92021-01-22 11:39:49 -080043 EnrollmentType enrollmentType, const std::vector<Feature>& features,
Ilya Matyukhinbde61ca2021-07-21 19:01:07 -070044 const std::optional<NativeHandle>& previewSurface,
Ilya Matyukhin26b20b92021-01-22 11:39:49 -080045 std::shared_ptr<common::ICancellationSignal>* return_val) override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070046
47 ndk::ScopedAStatus authenticate(
Ilya Matyukhin66c64642021-03-23 22:33:31 -070048 int64_t keystoreOperationId,
Ilya Matyukhin09166982020-10-12 13:41:03 -070049 std::shared_ptr<common::ICancellationSignal>* returnVal) override;
50
51 ndk::ScopedAStatus detectInteraction(
Ilya Matyukhin66c64642021-03-23 22:33:31 -070052 std::shared_ptr<common::ICancellationSignal>* returnVal) override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070053
Ilya Matyukhin66c64642021-03-23 22:33:31 -070054 ndk::ScopedAStatus enumerateEnrollments() override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070055
Ilya Matyukhin66c64642021-03-23 22:33:31 -070056 ndk::ScopedAStatus removeEnrollments(const std::vector<int32_t>& enrollmentIds) override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070057
Ilya Matyukhin9fcf6b12021-04-14 13:43:06 -070058 ndk::ScopedAStatus getFeatures() override;
Ilya Matyukhin26b20b92021-01-22 11:39:49 -080059
Ilya Matyukhin9fcf6b12021-04-14 13:43:06 -070060 ndk::ScopedAStatus setFeature(const keymaster::HardwareAuthToken& hat, Feature feature,
61 bool enabled) override;
Ilya Matyukhin26b20b92021-01-22 11:39:49 -080062
Ilya Matyukhin66c64642021-03-23 22:33:31 -070063 ndk::ScopedAStatus getAuthenticatorId() override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070064
Ilya Matyukhin66c64642021-03-23 22:33:31 -070065 ndk::ScopedAStatus invalidateAuthenticatorId() override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070066
Ilya Matyukhin66c64642021-03-23 22:33:31 -070067 ndk::ScopedAStatus resetLockout(const keymaster::HardwareAuthToken& hat) override;
Ilya Matyukhin09166982020-10-12 13:41:03 -070068
Ilya Matyukhin66c64642021-03-23 22:33:31 -070069 ndk::ScopedAStatus close() override;
Ilya Matyukhine52cae02021-02-17 16:38:56 -080070
Joe Bolinger7bd42e12022-01-12 16:27:03 -080071 ndk::ScopedAStatus authenticateWithContext(
72 int64_t operationId, const common::OperationContext& context,
73 std::shared_ptr<common::ICancellationSignal>* out) override;
74
75 ndk::ScopedAStatus enrollWithContext(
76 const keymaster::HardwareAuthToken& hat, EnrollmentType enrollmentType,
77 const std::vector<Feature>& features, const std::optional<NativeHandle>& previewSurface,
78 const common::OperationContext& context,
79 std::shared_ptr<common::ICancellationSignal>* out) override;
80
81 ndk::ScopedAStatus detectInteractionWithContext(
82 const common::OperationContext& context,
83 std::shared_ptr<common::ICancellationSignal>* out) override;
84
Joe Bolinger25e98232022-01-24 18:56:23 +000085 ndk::ScopedAStatus onContextChanged(const common::OperationContext& context) override;
86
Ilya Matyukhin09166982020-10-12 13:41:03 -070087 private:
88 std::shared_ptr<ISessionCallback> cb_;
Ilya Matyukhin60406be2021-07-03 00:04:43 +000089 std::mt19937 mRandom;
Ilya Matyukhin09166982020-10-12 13:41:03 -070090};
91
92} // namespace aidl::android::hardware::biometrics::face