blob: 4438d35ba4da34b918312b51d25f1f22bfcdc844 [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 Matyukhinaf30cde2021-01-08 09:42:50 -080055ndk::ScopedAStatus Session::enroll(
Ilya Matyukhin66c64642021-03-23 22:33:31 -070056 const keymaster::HardwareAuthToken& /*hat*/, EnrollmentType /*enrollmentType*/,
57 const std::vector<Feature>& /*features*/, const NativeHandle& /*previewSurface*/,
Ilya Matyukhinaf30cde2021-01-08 09:42:50 -080058 std::shared_ptr<biometrics::common::ICancellationSignal>* /*return_val*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080059 LOG(INFO) << "enroll";
Ilya Matyukhin09166982020-10-12 13:41:03 -070060 return ndk::ScopedAStatus::ok();
61}
62
Ilya Matyukhin66c64642021-03-23 22:33:31 -070063ndk::ScopedAStatus Session::authenticate(int64_t /*keystoreOperationId*/,
Ilya Matyukhin09166982020-10-12 13:41:03 -070064 std::shared_ptr<common::ICancellationSignal>* return_val) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080065 LOG(INFO) << "authenticate";
Ilya Matyukhin09166982020-10-12 13:41:03 -070066 if (cb_) {
Ilya Matyukhin66c64642021-03-23 22:33:31 -070067 cb_->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorCode */);
Ilya Matyukhin09166982020-10-12 13:41:03 -070068 }
Kevin Chyncfb54992020-11-17 13:06:23 -080069 *return_val = SharedRefBase::make<CancellationSignal>(cb_);
Ilya Matyukhin09166982020-10-12 13:41:03 -070070 return ndk::ScopedAStatus::ok();
71}
72
73ndk::ScopedAStatus Session::detectInteraction(
Ilya Matyukhin66c64642021-03-23 22:33:31 -070074 std::shared_ptr<common::ICancellationSignal>* /*return_val*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080075 LOG(INFO) << "detectInteraction";
Ilya Matyukhin09166982020-10-12 13:41:03 -070076 return ndk::ScopedAStatus::ok();
77}
78
Ilya Matyukhin66c64642021-03-23 22:33:31 -070079ndk::ScopedAStatus Session::enumerateEnrollments() {
Kevin Chyn146f6c82021-02-10 11:32:35 -080080 LOG(INFO) << "enumerateEnrollments";
Kevin Chyncfb54992020-11-17 13:06:23 -080081 if (cb_) {
Kevin Chyncfb54992020-11-17 13:06:23 -080082 cb_->onEnrollmentsEnumerated(std::vector<int32_t>());
Kevin Chyncfb54992020-11-17 13:06:23 -080083 }
Ilya Matyukhin09166982020-10-12 13:41:03 -070084 return ndk::ScopedAStatus::ok();
85}
86
Ilya Matyukhin66c64642021-03-23 22:33:31 -070087ndk::ScopedAStatus Session::removeEnrollments(const std::vector<int32_t>& /*enrollmentIds*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080088 LOG(INFO) << "removeEnrollments";
Kevin Chyncfb54992020-11-17 13:06:23 -080089 if (cb_) {
Ilya Matyukhinaf30cde2021-01-08 09:42:50 -080090 cb_->onEnrollmentsRemoved(std::vector<int32_t>());
Kevin Chyncfb54992020-11-17 13:06:23 -080091 }
Ilya Matyukhin09166982020-10-12 13:41:03 -070092 return ndk::ScopedAStatus::ok();
93}
94
Ilya Matyukhin9fcf6b12021-04-14 13:43:06 -070095ndk::ScopedAStatus Session::getFeatures() {
Kevin Chyn146f6c82021-02-10 11:32:35 -080096 LOG(INFO) << "getFeatures";
Ilya Matyukhin26b20b92021-01-22 11:39:49 -080097 return ndk::ScopedAStatus::ok();
98}
99
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700100ndk::ScopedAStatus Session::setFeature(const keymaster::HardwareAuthToken& /*hat*/,
Ilya Matyukhin9fcf6b12021-04-14 13:43:06 -0700101 Feature /*feature*/, bool /*enabled*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800102 LOG(INFO) << "setFeature";
Ilya Matyukhin26b20b92021-01-22 11:39:49 -0800103 return ndk::ScopedAStatus::ok();
104}
105
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700106ndk::ScopedAStatus Session::getAuthenticatorId() {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800107 LOG(INFO) << "getAuthenticatorId";
Kevin Chyncfb54992020-11-17 13:06:23 -0800108 if (cb_) {
Kevin Chyncfb54992020-11-17 13:06:23 -0800109 cb_->onAuthenticatorIdRetrieved(0 /* authenticatorId */);
Kevin Chyncfb54992020-11-17 13:06:23 -0800110 }
Ilya Matyukhin09166982020-10-12 13:41:03 -0700111 return ndk::ScopedAStatus::ok();
112}
113
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700114ndk::ScopedAStatus Session::invalidateAuthenticatorId() {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800115 LOG(INFO) << "invalidateAuthenticatorId";
Ilya Matyukhin09166982020-10-12 13:41:03 -0700116 return ndk::ScopedAStatus::ok();
117}
118
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700119ndk::ScopedAStatus Session::resetLockout(const keymaster::HardwareAuthToken& /*hat*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800120 LOG(INFO) << "resetLockout";
Kevin Chyncfb54992020-11-17 13:06:23 -0800121 if (cb_) {
Kevin Chyncfb54992020-11-17 13:06:23 -0800122 cb_->onLockoutCleared();
Kevin Chyncfb54992020-11-17 13:06:23 -0800123 }
Ilya Matyukhin09166982020-10-12 13:41:03 -0700124 return ndk::ScopedAStatus::ok();
125}
Ilya Matyukhinaf30cde2021-01-08 09:42:50 -0800126
Ilya Matyukhin66c64642021-03-23 22:33:31 -0700127ndk::ScopedAStatus Session::close() {
128 if (cb_) {
129 cb_->onSessionClosed();
130 }
Ilya Matyukhine52cae02021-02-17 16:38:56 -0800131 return ndk::ScopedAStatus::ok();
132}
133
Ilya Matyukhin09166982020-10-12 13:41:03 -0700134} // namespace aidl::android::hardware::biometrics::face