Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -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 | |
Kevin Chyn | e33abd6 | 2020-09-18 10:31:50 -0700 | [diff] [blame] | 17 | #include <aidl/android/hardware/biometrics/common/BnCancellationSignal.h> |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 18 | #include <android-base/logging.h> |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 19 | |
| 20 | #include "Session.h" |
| 21 | |
| 22 | namespace aidl::android::hardware::biometrics::fingerprint { |
| 23 | |
Kevin Chyn | e33abd6 | 2020-09-18 10:31:50 -0700 | [diff] [blame] | 24 | class CancellationSignal : public common::BnCancellationSignal { |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 25 | public: |
| 26 | ndk::ScopedAStatus cancel() override { return ndk::ScopedAStatus::ok(); } |
| 27 | }; |
| 28 | |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 29 | Session::Session(std::shared_ptr<ISessionCallback> cb) : mCb(std::move(cb)) {} |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 30 | |
Ilya Matyukhin | 3d54f45 | 2020-10-15 17:32:09 -0700 | [diff] [blame] | 31 | ndk::ScopedAStatus Session::generateChallenge(int32_t /*cookie*/, int32_t /*timeoutSec*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 32 | LOG(INFO) << "generateChallenge"; |
Ilya Matyukhin | 3d54f45 | 2020-10-15 17:32:09 -0700 | [diff] [blame] | 33 | return ndk::ScopedAStatus::ok(); |
| 34 | } |
| 35 | |
| 36 | ndk::ScopedAStatus Session::revokeChallenge(int32_t /*cookie*/, int64_t /*challenge*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 37 | LOG(INFO) << "revokeChallenge"; |
Ilya Matyukhin | 3d54f45 | 2020-10-15 17:32:09 -0700 | [diff] [blame] | 38 | return ndk::ScopedAStatus::ok(); |
| 39 | } |
| 40 | |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 41 | ndk::ScopedAStatus Session::enroll(int32_t /*cookie*/, const keymaster::HardwareAuthToken& /*hat*/, |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 42 | std::shared_ptr<common::ICancellationSignal>* /*out*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 43 | LOG(INFO) << "enroll"; |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 44 | return ndk::ScopedAStatus::ok(); |
| 45 | } |
| 46 | |
| 47 | ndk::ScopedAStatus Session::authenticate(int32_t /*cookie*/, int64_t /*keystoreOperationId*/, |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 48 | std::shared_ptr<common::ICancellationSignal>* out) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 49 | LOG(INFO) << "authenticate"; |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 50 | if (mCb) { |
| 51 | mCb->onStateChanged(0, SessionState::AUTHENTICATING); |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 52 | } |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 53 | *out = SharedRefBase::make<CancellationSignal>(); |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 54 | return ndk::ScopedAStatus::ok(); |
| 55 | } |
| 56 | |
| 57 | ndk::ScopedAStatus Session::detectInteraction( |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 58 | int32_t /*cookie*/, std::shared_ptr<common::ICancellationSignal>* /*out*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 59 | LOG(INFO) << "detectInteraction"; |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 60 | return ndk::ScopedAStatus::ok(); |
| 61 | } |
| 62 | |
| 63 | ndk::ScopedAStatus Session::enumerateEnrollments(int32_t /*cookie*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 64 | LOG(INFO) << "enumerateEnrollments"; |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 65 | if (mCb) { |
| 66 | mCb->onStateChanged(0, SessionState::ENUMERATING_ENROLLMENTS); |
| 67 | mCb->onEnrollmentsEnumerated(std::vector<int32_t>()); |
Kevin Chyn | de2610f | 2020-10-20 18:26:50 -0700 | [diff] [blame] | 68 | } |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 69 | return ndk::ScopedAStatus::ok(); |
| 70 | } |
| 71 | |
| 72 | ndk::ScopedAStatus Session::removeEnrollments(int32_t /*cookie*/, |
| 73 | const std::vector<int32_t>& /*enrollmentIds*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 74 | LOG(INFO) << "removeEnrollments"; |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 75 | if (mCb) { |
| 76 | mCb->onStateChanged(0, SessionState::REMOVING_ENROLLMENTS); |
| 77 | mCb->onEnrollmentsRemoved(std::vector<int32_t>()); |
Kevin Chyn | de2610f | 2020-10-20 18:26:50 -0700 | [diff] [blame] | 78 | } |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 79 | return ndk::ScopedAStatus::ok(); |
| 80 | } |
| 81 | |
| 82 | ndk::ScopedAStatus Session::getAuthenticatorId(int32_t /*cookie*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 83 | LOG(INFO) << "getAuthenticatorId"; |
Ilya Matyukhin | 124e70a | 2021-02-12 13:00:15 -0800 | [diff] [blame] | 84 | if (mCb) { |
| 85 | mCb->onStateChanged(0, SessionState::GETTING_AUTHENTICATOR_ID); |
| 86 | mCb->onAuthenticatorIdRetrieved(0 /* authenticatorId */); |
Kevin Chyn | de2610f | 2020-10-20 18:26:50 -0700 | [diff] [blame] | 87 | } |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 88 | return ndk::ScopedAStatus::ok(); |
| 89 | } |
| 90 | |
Kevin Chyn | 4d0df26 | 2020-11-16 12:39:44 -0800 | [diff] [blame] | 91 | ndk::ScopedAStatus Session::invalidateAuthenticatorId(int32_t /*cookie*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 92 | LOG(INFO) << "invalidateAuthenticatorId"; |
Kevin Chyn | 6e862c3 | 2020-09-16 18:27:37 -0700 | [diff] [blame] | 93 | return ndk::ScopedAStatus::ok(); |
| 94 | } |
| 95 | |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 96 | ndk::ScopedAStatus Session::resetLockout(int32_t /*cookie*/, |
| 97 | const keymaster::HardwareAuthToken& /*hat*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 98 | LOG(INFO) << "resetLockout"; |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 99 | return ndk::ScopedAStatus::ok(); |
| 100 | } |
| 101 | |
Ilya Matyukhin | 71005c5 | 2021-02-17 12:44:14 -0800 | [diff] [blame] | 102 | ndk::ScopedAStatus Session::close(int32_t /*cookie*/) { |
| 103 | LOG(INFO) << "close"; |
| 104 | return ndk::ScopedAStatus::ok(); |
| 105 | } |
| 106 | |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 107 | ndk::ScopedAStatus Session::onPointerDown(int32_t /*pointerId*/, int32_t /*x*/, int32_t /*y*/, |
| 108 | float /*minor*/, float /*major*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 109 | LOG(INFO) << "onPointerDown"; |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 110 | return ndk::ScopedAStatus::ok(); |
| 111 | } |
| 112 | |
| 113 | ndk::ScopedAStatus Session::onPointerUp(int32_t /*pointerId*/) { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 114 | LOG(INFO) << "onPointerUp"; |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 115 | return ndk::ScopedAStatus::ok(); |
| 116 | } |
| 117 | |
| 118 | ndk::ScopedAStatus Session::onUiReady() { |
Kevin Chyn | 146f6c8 | 2021-02-10 11:32:35 -0800 | [diff] [blame] | 119 | LOG(INFO) << "onUiReady"; |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 120 | return ndk::ScopedAStatus::ok(); |
| 121 | } |
Ilya Matyukhin | a9a3c85 | 2020-08-18 03:09:41 -0700 | [diff] [blame] | 122 | } // namespace aidl::android::hardware::biometrics::fingerprint |