mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Fix: Fingerprint detect should not depend on enrollment match" into main
This commit is contained in:
@@ -32,7 +32,9 @@ using ::android::base::ParseInt;
|
||||
namespace aidl::android::hardware::biometrics::fingerprint {
|
||||
|
||||
FakeFingerprintEngine::FakeFingerprintEngine()
|
||||
: mRandom(std::mt19937::default_seed), mWorkMode(WorkMode::kIdle) {}
|
||||
: mRandom(std::mt19937::default_seed),
|
||||
mWorkMode(WorkMode::kIdle),
|
||||
isLockoutTimerSupported(true) {}
|
||||
|
||||
void FakeFingerprintEngine::generateChallengeImpl(ISessionCallback* cb) {
|
||||
BEGIN_OP(0);
|
||||
@@ -305,15 +307,6 @@ bool FakeFingerprintEngine::onDetectInteractFingerDown(ISessionCallback* cb,
|
||||
SLEEP_MS(duration / N);
|
||||
} while (!Util::hasElapsed(now, duration));
|
||||
|
||||
auto id = FingerprintHalProperties::enrollment_hit().value_or(0);
|
||||
auto enrolls = FingerprintHalProperties::enrollments();
|
||||
auto isEnrolled = std::find(enrolls.begin(), enrolls.end(), id) != enrolls.end();
|
||||
if (id <= 0 || !isEnrolled) {
|
||||
LOG(ERROR) << "Fail: not enrolled";
|
||||
cb->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorError */);
|
||||
return true;
|
||||
}
|
||||
|
||||
cb->onInteractionDetected();
|
||||
|
||||
return true;
|
||||
@@ -386,7 +379,7 @@ void FakeFingerprintEngine::resetLockoutImpl(ISessionCallback* cb,
|
||||
return;
|
||||
}
|
||||
clearLockout(cb);
|
||||
isLockoutTimerAborted = true;
|
||||
if (isLockoutTimerStarted) isLockoutTimerAborted = true;
|
||||
}
|
||||
|
||||
void FakeFingerprintEngine::clearLockout(ISessionCallback* cb) {
|
||||
@@ -533,6 +526,7 @@ void FakeFingerprintEngine::startLockoutTimer(int64_t timeout, ISessionCallback*
|
||||
isLockoutTimerStarted = true;
|
||||
}
|
||||
void FakeFingerprintEngine::lockoutTimerExpired(ISessionCallback* cb) {
|
||||
BEGIN_OP(0);
|
||||
if (!isLockoutTimerAborted) {
|
||||
clearLockout(cb);
|
||||
}
|
||||
|
||||
@@ -27,9 +27,7 @@ using namespace ::android::fingerprint::virt;
|
||||
|
||||
namespace aidl::android::hardware::biometrics::fingerprint {
|
||||
|
||||
FakeFingerprintEngineSide::FakeFingerprintEngineSide() : FakeFingerprintEngine() {
|
||||
isLockoutTimerSupported = true;
|
||||
}
|
||||
FakeFingerprintEngineSide::FakeFingerprintEngineSide() : FakeFingerprintEngine() {}
|
||||
|
||||
SensorLocation FakeFingerprintEngineSide::defaultSensorLocation() {
|
||||
return SensorLocation{.sensorLocationX = defaultSensorLocationX,
|
||||
|
||||
@@ -357,7 +357,7 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetectNotSet) {
|
||||
FingerprintHalProperties::enrollment_hit({});
|
||||
mEngine.detectInteractionImpl(mCallback.get(), mCancel.get_future());
|
||||
mEngine.fingerDownAction();
|
||||
ASSERT_EQ(0, mCallback->mInteractionDetectedCount);
|
||||
ASSERT_EQ(1, mCallback->mInteractionDetectedCount);
|
||||
}
|
||||
|
||||
TEST_F(FakeFingerprintEngineTest, InteractionDetectNotEnrolled) {
|
||||
@@ -365,7 +365,7 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetectNotEnrolled) {
|
||||
FingerprintHalProperties::enrollment_hit(25);
|
||||
mEngine.detectInteractionImpl(mCallback.get(), mCancel.get_future());
|
||||
mEngine.fingerDownAction();
|
||||
ASSERT_EQ(0, mCallback->mInteractionDetectedCount);
|
||||
ASSERT_EQ(1, mCallback->mInteractionDetectedCount);
|
||||
}
|
||||
|
||||
TEST_F(FakeFingerprintEngineTest, InteractionDetectError) {
|
||||
@@ -508,7 +508,7 @@ TEST_F(FakeFingerprintEngineTest, randomLatency) {
|
||||
TEST_F(FakeFingerprintEngineTest, lockoutTimer) {
|
||||
mEngine.startLockoutTimer(200, mCallback.get());
|
||||
ASSERT_TRUE(mEngine.getLockoutTimerStarted());
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(230));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
||||
ASSERT_FALSE(mEngine.getLockoutTimerStarted());
|
||||
ASSERT_TRUE(mCallback->mLockoutCleared);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user