blob: d980c5f8921d539c0e44c056df64806e7dbd118f [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#include <aidl/android/hardware/biometrics/common/BnCancellationSignal.h>
Kevin Chyn146f6c82021-02-10 11:32:35 -080018#include <android-base/logging.h>
Ilya Matyukhin09166982020-10-12 13:41:03 -070019
20#include "Session.h"
21
22namespace aidl::android::hardware::biometrics::face {
23
24class CancellationSignal : public common::BnCancellationSignal {
Kevin Chyncfb54992020-11-17 13:06:23 -080025 private:
26 std::shared_ptr<ISessionCallback> cb_;
Ilya Matyukhinaf30cde2021-01-08 09:42:50 -080027
Ilya Matyukhin09166982020-10-12 13:41:03 -070028 public:
Kevin Chyncfb54992020-11-17 13:06:23 -080029 explicit CancellationSignal(std::shared_ptr<ISessionCallback> cb) : cb_(std::move(cb)) {}
30
31 ndk::ScopedAStatus cancel() override {
32 cb_->onError(Error::CANCELED, 0 /* vendorCode */);
Kevin Chyncfb54992020-11-17 13:06:23 -080033 return ndk::ScopedAStatus::ok();
34 }
Ilya Matyukhin09166982020-10-12 13:41:03 -070035};
36
37Session::Session(std::shared_ptr<ISessionCallback> cb) : cb_(std::move(cb)) {}
38
Ilya Matyukhin66c64642021-03-23 22:33:31 -070039ndk::ScopedAStatus Session::generateChallenge() {
Kevin Chyn146f6c82021-02-10 11:32:35 -080040 LOG(INFO) << "generateChallenge";
Kevin Chyncfb54992020-11-17 13:06:23 -080041 if (cb_) {
Kevin Chyncfb54992020-11-17 13:06:23 -080042 cb_->onChallengeGenerated(0);
Kevin Chyncfb54992020-11-17 13:06:23 -080043 }
Ilya Matyukhin09166982020-10-12 13:41:03 -070044 return ndk::ScopedAStatus::ok();
45}
46
Ilya Matyukhin66c64642021-03-23 22:33:31 -070047ndk::ScopedAStatus Session::revokeChallenge(int64_t challenge) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080048 LOG(INFO) << "revokeChallenge";
Kevin Chyncfb54992020-11-17 13:06:23 -080049 if (cb_) {
Kevin Chyncfb54992020-11-17 13:06:23 -080050 cb_->onChallengeRevoked(challenge);
Kevin Chyncfb54992020-11-17 13:06:23 -080051 }
Ilya Matyukhin09166982020-10-12 13:41:03 -070052 return ndk::ScopedAStatus::ok();
53}
54
Ilya Matyukhin929146e2021-04-22 00:29:01 -070055ndk::ScopedAStatus Session::getEnrollmentConfig(EnrollmentType /*enrollmentType*/,
56 std::vector<EnrollmentStageConfig>* return_val) {
57 *return_val = {};
58 return ndk::ScopedAStatus::ok();
59}
60
Ilya Matyukhinaf30cde2021-01-08 09:42:50 -080061ndk::ScopedAStatus Session::enroll(
Ilya Matyukhin66c64642021-03-23 22:33:31 -070062 const keymaster::HardwareAuthToken& /*hat*/, EnrollmentType /*enrollmentType*/,
63 const std::vector<Feature>& /*features*/, const NativeHandle& /*previewSurface*/,
Ilya Matyukhinaf30cde2021-01-08 09:42:50 -080064 std::shared_ptr<biometrics::common::ICancellationSignal>* /*return_val*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080065 LOG(INFO) << "enroll";
Ilya Matyukhin09166982020-10-12 13:41:03 -070066 return ndk::ScopedAStatus::ok();
67}
68
Ilya Matyukhin66c64642021-03-23 22:33:31 -070069ndk::ScopedAStatus Session::authenticate(int64_t /*keystoreOperationId*/,
Ilya Matyukhin09166982020-10-12 13:41:03 -070070 std::shared_ptr<common::ICancellationSignal>* return_val) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080071 LOG(INFO) << "authenticate";
Ilya Matyukhin09166982020-10-12 13:41:03 -070072 if (cb_) {
Ilya Matyukhin66c64642021-03-23 22:33:31 -070073 cb_->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorCode */);
Ilya Matyukhin09166982020-10-12 13:41:03 -070074 }
Kevin Chyncfb54992020-11-17 13:06:23 -080075 *return_val = SharedRefBase::make<CancellationSignal>(cb_);
Ilya Matyukhin09166982020-10-12 13:41:03 -070076 return ndk::ScopedAStatus::ok();
77}
78
79ndk::ScopedAStatus Session::detectInteraction(
Ilya Matyukhin66c64642021-03-23 22:33:31 -070080 std::shared_ptr<common::ICancellationSignal>* /*return_val*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080081 LOG(INFO) << "detectInteraction";
Ilya Matyukhin09166982020-10-12 13:41:03 -070082 return ndk::ScopedAStatus::ok();
83}
84
Ilya Matyukhin66c64642021-03-23 22:33:31 -070085ndk::ScopedAStatus Session::enumerateEnrollments() {
Kevin Chyn146f6c82021-02-10 11:32:35 -080086 LOG(INFO) << "enumerateEnrollments";
Kevin Chyncfb54992020-11-17 13:06:23 -080087 if (cb_) {
Kevin Chyncfb54992020-11-17 13:06:23 -080088 cb_->onEnrollmentsEnumerated(std::vector<int32_t>());
Kevin Chyncfb54992020-11-17 13:06:23 -080089 }
Ilya Matyukhin09166982020-10-12 13:41:03 -070090 return ndk::ScopedAStatus::ok();
91}
92
Ilya Matyukhin66c64642021-03-23 22:33:31 -070093ndk::ScopedAStatus Session::removeEnrollments(const std::vector<int32_t>& /*enrollmentIds*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080094 LOG(INFO) << "removeEnrollments";
Kevin Chyncfb54992020-11-17 13:06:23 -080095 if (cb_) {
Ilya Matyukhinaf30cde2021-01-08 09:42:50 -080096 cb_->onEnrollmentsRemoved(std::vector<int32_t>());
Kevin Chyncfb54992020-11-17 13:06:23 -080097 }
Ilya Matyukhin09166982020-10-12 13:41:03 -070098 return ndk::ScopedAStatus::ok();
99}
100
Ilya Matyukhin9fcf6b12021-04-14 13:43:06 -0700101ndk::ScopedAStatus Session::getFeatures() {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800102 LOG(INFO) << "getFeatures";
Ilya Matyukhin26b20b92021-01-22 11:39:49 -0800103 return ndk::ScopedAStatus::ok();
104}
105
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700106ndk::ScopedAStatus Session::setFeature(const keymaster::HardwareAuthToken& /*hat*/,
Ilya Matyukhin9fcf6b12021-04-14 13:43:06 -0700107 Feature /*feature*/, bool /*enabled*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800108 LOG(INFO) << "setFeature";
Ilya Matyukhin26b20b92021-01-22 11:39:49 -0800109 return ndk::ScopedAStatus::ok();
110}
111
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700112ndk::ScopedAStatus Session::getAuthenticatorId() {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800113 LOG(INFO) << "getAuthenticatorId";
Kevin Chyncfb54992020-11-17 13:06:23 -0800114 if (cb_) {
Kevin Chyncfb54992020-11-17 13:06:23 -0800115 cb_->onAuthenticatorIdRetrieved(0 /* authenticatorId */);
Kevin Chyncfb54992020-11-17 13:06:23 -0800116 }
Ilya Matyukhin09166982020-10-12 13:41:03 -0700117 return ndk::ScopedAStatus::ok();
118}
119
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700120ndk::ScopedAStatus Session::invalidateAuthenticatorId() {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800121 LOG(INFO) << "invalidateAuthenticatorId";
Ilya Matyukhin09166982020-10-12 13:41:03 -0700122 return ndk::ScopedAStatus::ok();
123}
124
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700125ndk::ScopedAStatus Session::resetLockout(const keymaster::HardwareAuthToken& /*hat*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800126 LOG(INFO) << "resetLockout";
Kevin Chyncfb54992020-11-17 13:06:23 -0800127 if (cb_) {
Kevin Chyncfb54992020-11-17 13:06:23 -0800128 cb_->onLockoutCleared();
Kevin Chyncfb54992020-11-17 13:06:23 -0800129 }
Ilya Matyukhin09166982020-10-12 13:41:03 -0700130 return ndk::ScopedAStatus::ok();
131}
Ilya Matyukhinaf30cde2021-01-08 09:42:50 -0800132
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700133ndk::ScopedAStatus Session::close() {
134 if (cb_) {
135 cb_->onSessionClosed();
136 }
Ilya Matyukhine52cae02021-02-17 16:38:56 -0800137 return ndk::ScopedAStatus::ok();
138}
139
Ilya Matyukhin09166982020-10-12 13:41:03 -0700140} // namespace aidl::android::hardware::biometrics::face