mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 05:49:27 +00:00
Merge "Inform framework of lockout right when the failed attempts reaches threshold" into udc-qpr-dev am: 9d838849bb
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/23846523 Change-Id: Ie523d48469435ee28f4357bfa748247d02185131 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -195,16 +195,7 @@ void FakeFingerprintEngine::onAuthenticateFingerDown(ISessionCallback* cb,
|
||||
}
|
||||
|
||||
// got lockout?
|
||||
FakeLockoutTracker::LockoutMode lockoutMode = mLockoutTracker.getMode();
|
||||
if (lockoutMode == FakeLockoutTracker::LockoutMode::kPermanent) {
|
||||
LOG(ERROR) << "Fail: lockout permanent";
|
||||
cb->onLockoutPermanent();
|
||||
return;
|
||||
} else if (lockoutMode == FakeLockoutTracker::LockoutMode::kTimed) {
|
||||
int64_t timeLeft = mLockoutTracker.getLockoutTimeLeft();
|
||||
LOG(ERROR) << "Fail: lockout timed " << timeLeft;
|
||||
cb->onLockoutTimed(timeLeft);
|
||||
}
|
||||
if (checkSensorLockout(cb)) return;
|
||||
|
||||
int i = 0;
|
||||
do {
|
||||
@@ -256,6 +247,7 @@ void FakeFingerprintEngine::onAuthenticateFingerDown(ISessionCallback* cb,
|
||||
LOG(ERROR) << "Fail: fingerprint not enrolled";
|
||||
cb->onAuthenticationFailed();
|
||||
mLockoutTracker.addFailedAttempt();
|
||||
checkSensorLockout(cb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,4 +555,18 @@ int32_t FakeFingerprintEngine::getRandomInRange(int32_t bound1, int32_t bound2)
|
||||
return dist(mRandom);
|
||||
}
|
||||
|
||||
bool FakeFingerprintEngine::checkSensorLockout(ISessionCallback* cb) {
|
||||
FakeLockoutTracker::LockoutMode lockoutMode = mLockoutTracker.getMode();
|
||||
if (lockoutMode == FakeLockoutTracker::LockoutMode::kPermanent) {
|
||||
LOG(ERROR) << "Fail: lockout permanent";
|
||||
cb->onLockoutPermanent();
|
||||
return true;
|
||||
} else if (lockoutMode == FakeLockoutTracker::LockoutMode::kTimed) {
|
||||
int64_t timeLeft = mLockoutTracker.getLockoutTimeLeft();
|
||||
LOG(ERROR) << "Fail: lockout timed " << timeLeft;
|
||||
cb->onLockoutTimed(timeLeft);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace aidl::android::hardware::biometrics::fingerprint
|
||||
|
||||
@@ -67,9 +67,13 @@ int64_t FakeLockoutTracker::getLockoutTimeLeft() {
|
||||
int64_t res = 0;
|
||||
|
||||
if (mLockoutTimedStart > 0) {
|
||||
int32_t lockoutTimedDuration =
|
||||
FingerprintHalProperties::lockout_timed_duration().value_or(10 * 100);
|
||||
auto now = Util::getSystemNanoTime();
|
||||
auto left = now - mLockoutTimedStart;
|
||||
res = (left > 0) ? (left / 1000000LL) : 0;
|
||||
auto elapsed = (now - mLockoutTimedStart) / 1000000LL;
|
||||
res = lockoutTimedDuration - elapsed;
|
||||
LOG(INFO) << "xxxxxx: elapsed=" << elapsed << " now = " << now
|
||||
<< " mLockoutTimedStart=" << mLockoutTimedStart << " res=" << res;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -113,6 +113,7 @@ class FakeFingerprintEngine {
|
||||
bool parseEnrollmentCaptureSingle(const std::string& str,
|
||||
std::vector<std::vector<int32_t>>& res);
|
||||
int32_t getRandomInRange(int32_t bound1, int32_t bound2);
|
||||
bool checkSensorLockout(ISessionCallback*);
|
||||
|
||||
FakeLockoutTracker mLockoutTracker;
|
||||
};
|
||||
|
||||
@@ -375,9 +375,7 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetectAcquired) {
|
||||
TEST_F(FakeFingerprintEngineTest, EnumerateEnrolled) {
|
||||
FingerprintHalProperties::enrollments({2, 4, 8});
|
||||
mEngine.enumerateEnrollmentsImpl(mCallback.get());
|
||||
ASSERT_EQ(
|
||||
4,
|
||||
mCallback->mLastEnrollmentEnumerated.size()); // Due to workaround. TODO (b/243129174)
|
||||
ASSERT_EQ(3, mCallback->mLastEnrollmentEnumerated.size());
|
||||
for (auto id : FingerprintHalProperties::enrollments()) {
|
||||
ASSERT_TRUE(std::find(mCallback->mLastEnrollmentEnumerated.begin(),
|
||||
mCallback->mLastEnrollmentEnumerated.end(),
|
||||
|
||||
@@ -65,11 +65,11 @@ TEST_F(FakeLockoutTrackerTest, addFailedAttemptLockoutTimed) {
|
||||
ASSERT_EQ(mLockoutTracker.getMode(), FakeLockoutTracker::LockoutMode::kTimed);
|
||||
// time left
|
||||
int N = 5;
|
||||
int64_t prevTimeLeft = INT_MIN;
|
||||
int64_t prevTimeLeft = INT_MAX;
|
||||
for (int i = 0; i < N; i++) {
|
||||
SLEEP_MS(LOCKOUT_TIMED_DURATION / N + 1);
|
||||
int64_t currTimeLeft = mLockoutTracker.getLockoutTimeLeft();
|
||||
ASSERT_TRUE(currTimeLeft > prevTimeLeft);
|
||||
ASSERT_TRUE(currTimeLeft < prevTimeLeft);
|
||||
prevTimeLeft = currTimeLeft;
|
||||
}
|
||||
ASSERT_EQ(mLockoutTracker.getMode(), FakeLockoutTracker::LockoutMode::kNone);
|
||||
|
||||
Reference in New Issue
Block a user