1 /*
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 
23 namespace aidl::android::hardware::biometrics::fingerprint {
24 
25 class FakeLockoutTracker {
26   public:
FakeLockoutTracker()27     FakeLockoutTracker() : mFailedCount(0) {}
~FakeLockoutTracker()28     ~FakeLockoutTracker() {}
29 
30     enum class LockoutMode : int8_t { kNone = 0, kTimed, kPermanent };
31 
32     void reset();
33     LockoutMode getMode();
34     void addFailedAttempt();
35     int64_t getLockoutTimeLeft();
toString()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;
47     int64_t mLockoutTimedStart;
48     LockoutMode mCurrentMode;
49 };
50 
51 }  // namespace aidl::android::hardware::biometrics::fingerprint
52