blob: a7f2f8e2945907932639f6aa049faae1a30a7ac9 [file] [log] [blame]
Jeff Pu52653182022-10-12 16:27:23 -04001/*
2 * Copyright (C) 2022 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
19#include <android/binder_to_string.h>
20#include <stdint.h>
21#include <string>
22
23namespace aidl::android::hardware::biometrics::fingerprint {
24
25class FakeLockoutTracker {
26 public:
Jeff Pub00dade2024-08-06 10:59:21 -040027 FakeLockoutTracker() : mFailedCount(0), mFailedCountTimed(0) {}
Jeff Pu52653182022-10-12 16:27:23 -040028 ~FakeLockoutTracker() {}
29
30 enum class LockoutMode : int8_t { kNone = 0, kTimed, kPermanent };
31
Jeff Pub00dade2024-08-06 10:59:21 -040032 void reset(bool dueToTimeout = false);
Jeff Pu52653182022-10-12 16:27:23 -040033 LockoutMode getMode();
34 void addFailedAttempt();
35 int64_t getLockoutTimeLeft();
36 inline std::string toString() const {
37 std::ostringstream os;
38 os << "----- FakeLockoutTracker:: -----" << std::endl;
39 os << "FakeLockoutTracker::mFailedCount:" << mFailedCount;
40 os << ", FakeLockoutTracker::mCurrentMode:" << (int)mCurrentMode;
41 os << std::endl;
42 return os.str();
43 }
44
45 private:
46 int32_t mFailedCount;
Jeff Pub00dade2024-08-06 10:59:21 -040047 int32_t mFailedCountTimed;
Jeff Pu52653182022-10-12 16:27:23 -040048 int64_t mLockoutTimedStart;
49 LockoutMode mCurrentMode;
50};
51
52} // namespace aidl::android::hardware::biometrics::fingerprint