mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 05:49:27 +00:00
Fix fingerprint vhal permanent lockout
Separate timed lockout failure count from permanent one, so it can be reset independently Bug: 357671325 Test: atest android.hardware.biometrics.fingerprint.* -c Change-Id: I08a8283a8eb464201b0f06c9c9bb7ba7635a54ac
This commit is contained in:
@@ -389,10 +389,10 @@ void FakeFingerprintEngine::resetLockoutImpl(ISessionCallback* cb,
|
||||
if (isLockoutTimerStarted) isLockoutTimerAborted = true;
|
||||
}
|
||||
|
||||
void FakeFingerprintEngine::clearLockout(ISessionCallback* cb) {
|
||||
void FakeFingerprintEngine::clearLockout(ISessionCallback* cb, bool dueToTimeout) {
|
||||
Fingerprint::cfg().set<bool>("lockout", false);
|
||||
cb->onLockoutCleared();
|
||||
mLockoutTracker.reset();
|
||||
mLockoutTracker.reset(dueToTimeout);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus FakeFingerprintEngine::onPointerDownImpl(int32_t /*pointerId*/, int32_t /*x*/,
|
||||
@@ -536,7 +536,7 @@ void FakeFingerprintEngine::startLockoutTimer(int64_t timeout, ISessionCallback*
|
||||
void FakeFingerprintEngine::lockoutTimerExpired(ISessionCallback* cb) {
|
||||
BEGIN_OP(0);
|
||||
if (!isLockoutTimerAborted) {
|
||||
clearLockout(cb);
|
||||
clearLockout(cb, true);
|
||||
}
|
||||
isLockoutTimerStarted = false;
|
||||
isLockoutTimerAborted = false;
|
||||
|
||||
@@ -23,8 +23,11 @@ using namespace ::android::fingerprint::virt;
|
||||
|
||||
namespace aidl::android::hardware::biometrics::fingerprint {
|
||||
|
||||
void FakeLockoutTracker::reset() {
|
||||
mFailedCount = 0;
|
||||
void FakeLockoutTracker::reset(bool dueToTimeout) {
|
||||
if (!dueToTimeout) {
|
||||
mFailedCount = 0;
|
||||
}
|
||||
mFailedCountTimed = 0;
|
||||
mLockoutTimedStart = 0;
|
||||
mCurrentMode = LockoutMode::kNone;
|
||||
}
|
||||
@@ -33,6 +36,7 @@ void FakeLockoutTracker::addFailedAttempt() {
|
||||
bool enabled = Fingerprint::cfg().get<bool>("lockout_enable");
|
||||
if (enabled) {
|
||||
mFailedCount++;
|
||||
mFailedCountTimed++;
|
||||
int32_t lockoutTimedThreshold =
|
||||
Fingerprint::cfg().get<std::int32_t>("lockout_timed_threshold");
|
||||
int32_t lockoutPermanetThreshold =
|
||||
@@ -40,7 +44,7 @@ void FakeLockoutTracker::addFailedAttempt() {
|
||||
if (mFailedCount >= lockoutPermanetThreshold) {
|
||||
mCurrentMode = LockoutMode::kPermanent;
|
||||
Fingerprint::cfg().set<bool>("lockout", true);
|
||||
} else if (mFailedCount >= lockoutTimedThreshold) {
|
||||
} else if (mFailedCountTimed >= lockoutTimedThreshold) {
|
||||
if (mCurrentMode == LockoutMode::kNone) {
|
||||
mCurrentMode = LockoutMode::kTimed;
|
||||
mLockoutTimedStart = Util::getSystemNanoTime();
|
||||
|
||||
@@ -110,7 +110,7 @@ class FakeFingerprintEngine {
|
||||
std::pair<Error, int32_t> convertError(int32_t code);
|
||||
int32_t getRandomInRange(int32_t bound1, int32_t bound2);
|
||||
bool checkSensorLockout(ISessionCallback*);
|
||||
void clearLockout(ISessionCallback* cb);
|
||||
void clearLockout(ISessionCallback* cb, bool dueToTimeout = false);
|
||||
void waitForFingerDown(ISessionCallback* cb, const std::future<void>& cancel);
|
||||
|
||||
FakeLockoutTracker mLockoutTracker;
|
||||
|
||||
@@ -24,12 +24,12 @@ namespace aidl::android::hardware::biometrics::fingerprint {
|
||||
|
||||
class FakeLockoutTracker {
|
||||
public:
|
||||
FakeLockoutTracker() : mFailedCount(0) {}
|
||||
FakeLockoutTracker() : mFailedCount(0), mFailedCountTimed(0) {}
|
||||
~FakeLockoutTracker() {}
|
||||
|
||||
enum class LockoutMode : int8_t { kNone = 0, kTimed, kPermanent };
|
||||
|
||||
void reset();
|
||||
void reset(bool dueToTimeout = false);
|
||||
LockoutMode getMode();
|
||||
void addFailedAttempt();
|
||||
int64_t getLockoutTimeLeft();
|
||||
@@ -44,6 +44,7 @@ class FakeLockoutTracker {
|
||||
|
||||
private:
|
||||
int32_t mFailedCount;
|
||||
int32_t mFailedCountTimed;
|
||||
int64_t mLockoutTimedStart;
|
||||
LockoutMode mCurrentMode;
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ TEST_F(FakeLockoutTrackerTest, addFailedAttemptLockoutTimed) {
|
||||
prevTimeLeft = currTimeLeft;
|
||||
}
|
||||
ASSERT_EQ(mLockoutTracker.getMode(), FakeLockoutTracker::LockoutMode::kNone);
|
||||
mLockoutTracker.reset();
|
||||
mLockoutTracker.reset(true);
|
||||
}
|
||||
|
||||
TEST_F(FakeLockoutTrackerTest, addFailedAttemptPermanent) {
|
||||
|
||||
Reference in New Issue
Block a user