Tim Zimmermann | b7dca12 | 2024-01-20 05:54:32 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2024 The LineageOS Project |
| 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | */ |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | namespace aidl { |
| 10 | namespace android { |
| 11 | namespace hardware { |
| 12 | namespace biometrics { |
| 13 | namespace fingerprint { |
| 14 | |
| 15 | #define LOCKOUT_TIMED_THRESHOLD 5 |
| 16 | #define LOCKOUT_TIMED_DURATION 30 * 1000 |
| 17 | #define LOCKOUT_PERMANENT_THRESHOLD 20 |
| 18 | |
| 19 | enum class LockoutMode { |
| 20 | NONE, |
| 21 | TIMED, |
| 22 | PERMANENT |
| 23 | }; |
| 24 | |
| 25 | class LockoutTracker { |
| 26 | public: |
| 27 | void reset(bool clearAttemptCounter); |
| 28 | LockoutMode getMode(); |
| 29 | void addFailedAttempt(); |
| 30 | int64_t getLockoutTimeLeft(); |
| 31 | |
| 32 | private: |
| 33 | int32_t mFailedCount = 0; |
| 34 | int64_t mLockoutTimedStart; |
| 35 | LockoutMode mCurrentMode; |
| 36 | }; |
| 37 | |
| 38 | } // namespace fingerprint |
| 39 | } // namespace biometrics |
| 40 | } // namespace hardware |
| 41 | } // namespace android |
| 42 | } // namespace aidl |