Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 1 | /* |
| 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 Matyukhin | 60406be | 2021-07-03 00:04:43 +0000 | [diff] [blame] | 19 | #include <random> |
| 20 | |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 21 | #include <aidl/android/hardware/biometrics/face/BnSession.h> |
| 22 | #include <aidl/android/hardware/biometrics/face/ISessionCallback.h> |
| 23 | |
| 24 | namespace aidl::android::hardware::biometrics::face { |
| 25 | |
| 26 | namespace common = aidl::android::hardware::biometrics::common; |
| 27 | namespace keymaster = aidl::android::hardware::keymaster; |
| 28 | |
| 29 | using aidl::android::hardware::common::NativeHandle; |
| 30 | |
| 31 | class Session : public BnSession { |
| 32 | public: |
| 33 | explicit Session(std::shared_ptr<ISessionCallback> cb); |
| 34 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 35 | ndk::ScopedAStatus generateChallenge() override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 36 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 37 | ndk::ScopedAStatus revokeChallenge(int64_t challenge) override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 38 | |
Ilya Matyukhin | 929146e | 2021-04-22 00:29:01 -0700 | [diff] [blame] | 39 | ndk::ScopedAStatus getEnrollmentConfig(EnrollmentType enrollmentType, |
| 40 | std::vector<EnrollmentStageConfig>* return_val) override; |
| 41 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 42 | ndk::ScopedAStatus enroll(const keymaster::HardwareAuthToken& hat, |
Ilya Matyukhin | 26b20b9 | 2021-01-22 11:39:49 -0800 | [diff] [blame] | 43 | EnrollmentType enrollmentType, const std::vector<Feature>& features, |
Ilya Matyukhin | bde61ca | 2021-07-21 19:01:07 -0700 | [diff] [blame] | 44 | const std::optional<NativeHandle>& previewSurface, |
Ilya Matyukhin | 26b20b9 | 2021-01-22 11:39:49 -0800 | [diff] [blame] | 45 | std::shared_ptr<common::ICancellationSignal>* return_val) override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 46 | |
| 47 | ndk::ScopedAStatus authenticate( |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 48 | int64_t keystoreOperationId, |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 49 | std::shared_ptr<common::ICancellationSignal>* returnVal) override; |
| 50 | |
| 51 | ndk::ScopedAStatus detectInteraction( |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 52 | std::shared_ptr<common::ICancellationSignal>* returnVal) override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 53 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 54 | ndk::ScopedAStatus enumerateEnrollments() override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 55 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 56 | ndk::ScopedAStatus removeEnrollments(const std::vector<int32_t>& enrollmentIds) override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 57 | |
Ilya Matyukhin | 9fcf6b1 | 2021-04-14 13:43:06 -0700 | [diff] [blame] | 58 | ndk::ScopedAStatus getFeatures() override; |
Ilya Matyukhin | 26b20b9 | 2021-01-22 11:39:49 -0800 | [diff] [blame] | 59 | |
Ilya Matyukhin | 9fcf6b1 | 2021-04-14 13:43:06 -0700 | [diff] [blame] | 60 | ndk::ScopedAStatus setFeature(const keymaster::HardwareAuthToken& hat, Feature feature, |
| 61 | bool enabled) override; |
Ilya Matyukhin | 26b20b9 | 2021-01-22 11:39:49 -0800 | [diff] [blame] | 62 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 63 | ndk::ScopedAStatus getAuthenticatorId() override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 64 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 65 | ndk::ScopedAStatus invalidateAuthenticatorId() override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 66 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 67 | ndk::ScopedAStatus resetLockout(const keymaster::HardwareAuthToken& hat) override; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 68 | |
Ilya Matyukhin | 66c6464 | 2021-03-23 22:33:31 -0700 | [diff] [blame] | 69 | ndk::ScopedAStatus close() override; |
Ilya Matyukhin | e52cae0 | 2021-02-17 16:38:56 -0800 | [diff] [blame] | 70 | |
Joe Bolinger | 7bd42e1 | 2022-01-12 16:27:03 -0800 | [diff] [blame] | 71 | 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 Bolinger | 25e9823 | 2022-01-24 18:56:23 +0000 | [diff] [blame] | 85 | ndk::ScopedAStatus onContextChanged(const common::OperationContext& context) override; |
| 86 | |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 87 | private: |
| 88 | std::shared_ptr<ISessionCallback> cb_; |
Ilya Matyukhin | 60406be | 2021-07-03 00:04:43 +0000 | [diff] [blame] | 89 | std::mt19937 mRandom; |
Ilya Matyukhin | 0916698 | 2020-10-12 13:41:03 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | } // namespace aidl::android::hardware::biometrics::face |