blob: c928df4dd5195b59a30f82ff553e161284b671ac [file] [log] [blame]
Ilya Matyukhina9a3c852020-08-18 03:09:41 -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
Kevin Chyne33abd62020-09-18 10:31:50 -070017#include <aidl/android/hardware/biometrics/common/BnCancellationSignal.h>
Kevin Chyn146f6c82021-02-10 11:32:35 -080018#include <android-base/logging.h>
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070019
20#include "Session.h"
21
22namespace aidl::android::hardware::biometrics::fingerprint {
23
Kevin Chyne33abd62020-09-18 10:31:50 -070024class CancellationSignal : public common::BnCancellationSignal {
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070025 public:
26 ndk::ScopedAStatus cancel() override { return ndk::ScopedAStatus::ok(); }
27};
28
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080029Session::Session(std::shared_ptr<ISessionCallback> cb) : mCb(std::move(cb)) {}
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070030
Ilya Matyukhin3d54f452020-10-15 17:32:09 -070031ndk::ScopedAStatus Session::generateChallenge(int32_t /*cookie*/, int32_t /*timeoutSec*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080032 LOG(INFO) << "generateChallenge";
Ilya Matyukhin3d54f452020-10-15 17:32:09 -070033 return ndk::ScopedAStatus::ok();
34}
35
36ndk::ScopedAStatus Session::revokeChallenge(int32_t /*cookie*/, int64_t /*challenge*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080037 LOG(INFO) << "revokeChallenge";
Ilya Matyukhin3d54f452020-10-15 17:32:09 -070038 return ndk::ScopedAStatus::ok();
39}
40
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070041ndk::ScopedAStatus Session::enroll(int32_t /*cookie*/, const keymaster::HardwareAuthToken& /*hat*/,
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080042 std::shared_ptr<common::ICancellationSignal>* /*out*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080043 LOG(INFO) << "enroll";
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070044 return ndk::ScopedAStatus::ok();
45}
46
47ndk::ScopedAStatus Session::authenticate(int32_t /*cookie*/, int64_t /*keystoreOperationId*/,
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080048 std::shared_ptr<common::ICancellationSignal>* out) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080049 LOG(INFO) << "authenticate";
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080050 if (mCb) {
51 mCb->onStateChanged(0, SessionState::AUTHENTICATING);
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070052 }
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080053 *out = SharedRefBase::make<CancellationSignal>();
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070054 return ndk::ScopedAStatus::ok();
55}
56
57ndk::ScopedAStatus Session::detectInteraction(
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080058 int32_t /*cookie*/, std::shared_ptr<common::ICancellationSignal>* /*out*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080059 LOG(INFO) << "detectInteraction";
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070060 return ndk::ScopedAStatus::ok();
61}
62
63ndk::ScopedAStatus Session::enumerateEnrollments(int32_t /*cookie*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080064 LOG(INFO) << "enumerateEnrollments";
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080065 if (mCb) {
66 mCb->onStateChanged(0, SessionState::ENUMERATING_ENROLLMENTS);
67 mCb->onEnrollmentsEnumerated(std::vector<int32_t>());
Kevin Chynde2610f2020-10-20 18:26:50 -070068 }
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070069 return ndk::ScopedAStatus::ok();
70}
71
72ndk::ScopedAStatus Session::removeEnrollments(int32_t /*cookie*/,
73 const std::vector<int32_t>& /*enrollmentIds*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080074 LOG(INFO) << "removeEnrollments";
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080075 if (mCb) {
76 mCb->onStateChanged(0, SessionState::REMOVING_ENROLLMENTS);
77 mCb->onEnrollmentsRemoved(std::vector<int32_t>());
Kevin Chynde2610f2020-10-20 18:26:50 -070078 }
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070079 return ndk::ScopedAStatus::ok();
80}
81
82ndk::ScopedAStatus Session::getAuthenticatorId(int32_t /*cookie*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080083 LOG(INFO) << "getAuthenticatorId";
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080084 if (mCb) {
85 mCb->onStateChanged(0, SessionState::GETTING_AUTHENTICATOR_ID);
86 mCb->onAuthenticatorIdRetrieved(0 /* authenticatorId */);
Kevin Chynde2610f2020-10-20 18:26:50 -070087 }
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070088 return ndk::ScopedAStatus::ok();
89}
90
Kevin Chyn4d0df262020-11-16 12:39:44 -080091ndk::ScopedAStatus Session::invalidateAuthenticatorId(int32_t /*cookie*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080092 LOG(INFO) << "invalidateAuthenticatorId";
Kevin Chyn6e862c32020-09-16 18:27:37 -070093 return ndk::ScopedAStatus::ok();
94}
95
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070096ndk::ScopedAStatus Session::resetLockout(int32_t /*cookie*/,
97 const keymaster::HardwareAuthToken& /*hat*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -080098 LOG(INFO) << "resetLockout";
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070099 return ndk::ScopedAStatus::ok();
100}
101
Ilya Matyukhin71005c52021-02-17 12:44:14 -0800102ndk::ScopedAStatus Session::close(int32_t /*cookie*/) {
103 LOG(INFO) << "close";
104 return ndk::ScopedAStatus::ok();
105}
106
Ilya Matyukhina9a3c852020-08-18 03:09:41 -0700107ndk::ScopedAStatus Session::onPointerDown(int32_t /*pointerId*/, int32_t /*x*/, int32_t /*y*/,
108 float /*minor*/, float /*major*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800109 LOG(INFO) << "onPointerDown";
Ilya Matyukhina9a3c852020-08-18 03:09:41 -0700110 return ndk::ScopedAStatus::ok();
111}
112
113ndk::ScopedAStatus Session::onPointerUp(int32_t /*pointerId*/) {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800114 LOG(INFO) << "onPointerUp";
Ilya Matyukhina9a3c852020-08-18 03:09:41 -0700115 return ndk::ScopedAStatus::ok();
116}
117
118ndk::ScopedAStatus Session::onUiReady() {
Kevin Chyn146f6c82021-02-10 11:32:35 -0800119 LOG(INFO) << "onUiReady";
Ilya Matyukhina9a3c852020-08-18 03:09:41 -0700120 return ndk::ScopedAStatus::ok();
121}
Ilya Matyukhina9a3c852020-08-18 03:09:41 -0700122} // namespace aidl::android::hardware::biometrics::fingerprint