Merge "Simulate finger touch with virtual fingerprint hal" into udc-qpr-dev

This commit is contained in:
Jeff Pu 2023-06-21 17:28:36 +00:00 committed by Android (Google) Code Review
commit fd1e1e58fc
8 changed files with 135 additions and 106 deletions

View file

@ -31,6 +31,9 @@ using ::android::base::ParseInt;
namespace aidl::android::hardware::biometrics::fingerprint {
FakeFingerprintEngine::FakeFingerprintEngine()
: mRandom(std::mt19937::default_seed), mWorkMode(WorkMode::kIdle) {}
void FakeFingerprintEngine::generateChallengeImpl(ISessionCallback* cb) {
BEGIN_OP(0);
std::uniform_int_distribution<int64_t> dist;
@ -48,6 +51,64 @@ void FakeFingerprintEngine::revokeChallengeImpl(ISessionCallback* cb, int64_t ch
void FakeFingerprintEngine::enrollImpl(ISessionCallback* cb,
const keymaster::HardwareAuthToken& hat,
const std::future<void>& cancel) {
BEGIN_OP(0);
updateContext(WorkMode::kEnroll, cb, const_cast<std::future<void>&>(cancel), 0, hat);
}
void FakeFingerprintEngine::authenticateImpl(ISessionCallback* cb, int64_t operationId,
const std::future<void>& cancel) {
BEGIN_OP(0);
updateContext(WorkMode::kAuthenticate, cb, const_cast<std::future<void>&>(cancel), operationId,
keymaster::HardwareAuthToken());
}
void FakeFingerprintEngine::detectInteractionImpl(ISessionCallback* cb,
const std::future<void>& cancel) {
BEGIN_OP(0);
auto detectInteractionSupported =
FingerprintHalProperties::detect_interaction().value_or(false);
if (!detectInteractionSupported) {
LOG(ERROR) << "Detect interaction is not supported";
cb->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorError */);
return;
}
updateContext(WorkMode::kDetectInteract, cb, const_cast<std::future<void>&>(cancel), 0,
keymaster::HardwareAuthToken());
}
void FakeFingerprintEngine::updateContext(WorkMode mode, ISessionCallback* cb,
std::future<void>& cancel, int64_t operationId,
const keymaster::HardwareAuthToken& hat) {
mCancel = std::move(cancel);
mWorkMode = mode;
mCb = cb;
mOperationId = operationId;
mHat = hat;
}
void FakeFingerprintEngine::fingerDownAction() {
LOG(INFO) << __func__;
switch (mWorkMode) {
case WorkMode::kAuthenticate:
onAuthenticateFingerDown(mCb, mOperationId, mCancel);
break;
case WorkMode::kEnroll:
onEnrollFingerDown(mCb, mHat, mCancel);
break;
case WorkMode::kDetectInteract:
onDetectInteractFingerDown(mCb, mCancel);
break;
default:
LOG(WARNING) << "unexpected mode: on fingerDownAction(), " << (int)mWorkMode;
break;
}
}
void FakeFingerprintEngine::onEnrollFingerDown(ISessionCallback* cb,
const keymaster::HardwareAuthToken& hat,
const std::future<void>& cancel) {
BEGIN_OP(getLatency(FingerprintHalProperties::operation_enroll_latency()));
// Do proper HAT verification in the real implementation.
@ -116,8 +177,9 @@ void FakeFingerprintEngine::enrollImpl(ISessionCallback* cb,
}
}
void FakeFingerprintEngine::authenticateImpl(ISessionCallback* cb, int64_t /* operationId */,
const std::future<void>& cancel) {
void FakeFingerprintEngine::onAuthenticateFingerDown(ISessionCallback* cb,
int64_t /* operationId */,
const std::future<void>& cancel) {
BEGIN_OP(getLatency(FingerprintHalProperties::operation_authenticate_latency()));
int64_t now = Util::getSystemNanoTime();
@ -197,21 +259,13 @@ void FakeFingerprintEngine::authenticateImpl(ISessionCallback* cb, int64_t /* op
}
}
void FakeFingerprintEngine::detectInteractionImpl(ISessionCallback* cb,
const std::future<void>& cancel) {
void FakeFingerprintEngine::onDetectInteractFingerDown(ISessionCallback* cb,
const std::future<void>& cancel) {
BEGIN_OP(getLatency(FingerprintHalProperties::operation_detect_interaction_latency()));
int64_t duration =
FingerprintHalProperties::operation_detect_interaction_duration().value_or(10);
auto detectInteractionSupported =
FingerprintHalProperties::detect_interaction().value_or(false);
if (!detectInteractionSupported) {
LOG(ERROR) << "Detect interaction is not supported";
cb->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorError */);
return;
}
auto acquired = FingerprintHalProperties::operation_detect_interaction_acquired().value_or("1");
auto acquiredInfos = parseIntSequence(acquired);
int N = acquiredInfos.size();
@ -334,6 +388,7 @@ ndk::ScopedAStatus FakeFingerprintEngine::onPointerDownImpl(int32_t /*pointerId*
int32_t /*y*/, float /*minor*/,
float /*major*/) {
BEGIN_OP(0);
fingerDownAction();
return ndk::ScopedAStatus::ok();
}
@ -364,7 +419,8 @@ bool FakeFingerprintEngine::getSensorLocationConfig(SensorLocation& out) {
if (dim.size() >= 4) {
d = dim[3];
}
if (isValidStr) out = {0, x, y, r, d};
if (isValidStr)
out = {.sensorLocationX = x, .sensorLocationY = y, .sensorRadius = r, .display = d};
return isValidStr;
}
@ -380,8 +436,7 @@ SensorLocation FakeFingerprintEngine::getSensorLocation() {
}
SensorLocation FakeFingerprintEngine::defaultSensorLocation() {
return {0 /* displayId (not used) */, 0 /* sensorLocationX */, 0 /* sensorLocationY */,
0 /* sensorRadius */, "" /* display */};
return SensorLocation();
}
std::vector<int32_t> FakeFingerprintEngine::parseIntSequence(const std::string& str,

View file

@ -28,10 +28,8 @@ using namespace ::android::fingerprint::virt;
namespace aidl::android::hardware::biometrics::fingerprint {
SensorLocation FakeFingerprintEngineSide::defaultSensorLocation() {
SensorLocation location;
return {0 /* displayId (not used) */, defaultSensorLocationX /* sensorLocationX */,
defaultSensorLocationY /* sensorLocationY */, defaultSensorRadius /* sensorRadius */,
"" /* display */};
return SensorLocation{.sensorLocationX = defaultSensorLocationX,
.sensorLocationY = defaultSensorLocationY,
.sensorRadius = defaultSensorRadius};
}
} // namespace aidl::android::hardware::biometrics::fingerprint

View file

@ -31,12 +31,12 @@ using namespace ::android::fingerprint::virt;
namespace aidl::android::hardware::biometrics::fingerprint {
FakeFingerprintEngineUdfps::FakeFingerprintEngineUdfps()
: FakeFingerprintEngine(), mWorkMode(WorkMode::kIdle), mPointerDownTime(0), mUiReadyTime(0) {}
: FakeFingerprintEngine(), mPointerDownTime(0), mUiReadyTime(0) {}
SensorLocation FakeFingerprintEngineUdfps::defaultSensorLocation() {
return {0 /* displayId (not used) */, defaultSensorLocationX /* sensorLocationX */,
defaultSensorLocationY /* sensorLocationY */, defaultSensorRadius /* sensorRadius */,
"" /* display */};
return SensorLocation{.sensorLocationX = defaultSensorLocationX,
.sensorLocationY = defaultSensorLocationY,
.sensorRadius = defaultSensorRadius};
}
ndk::ScopedAStatus FakeFingerprintEngineUdfps::onPointerDownImpl(int32_t /*pointerId*/,
@ -70,68 +70,17 @@ ndk::ScopedAStatus FakeFingerprintEngineUdfps::onUiReadyImpl() {
}
void FakeFingerprintEngineUdfps::fingerDownAction() {
switch (mWorkMode) {
case WorkMode::kAuthenticate:
onAuthenticateFingerDown();
break;
case WorkMode::kEnroll:
onEnrollFingerDown();
break;
case WorkMode::kDetectInteract:
onDetectInteractFingerDown();
break;
default:
LOG(WARNING) << "unexpected call: onUiReady()";
break;
}
FakeFingerprintEngine::fingerDownAction();
mUiReadyTime = 0;
mPointerDownTime = 0;
}
void FakeFingerprintEngineUdfps::onAuthenticateFingerDown() {
FakeFingerprintEngine::authenticateImpl(mCb, mOperationId, mCancelVec[0]);
}
void FakeFingerprintEngineUdfps::onEnrollFingerDown() {
// Any use case to emulate display touch for each capture during enrollment?
FakeFingerprintEngine::enrollImpl(mCb, mHat, mCancelVec[0]);
}
void FakeFingerprintEngineUdfps::onDetectInteractFingerDown() {
FakeFingerprintEngine::detectInteractionImpl(mCb, mCancelVec[0]);
}
void FakeFingerprintEngineUdfps::enrollImpl(ISessionCallback* cb,
const keymaster::HardwareAuthToken& hat,
const std::future<void>& cancel) {
updateContext(WorkMode::kEnroll, cb, const_cast<std::future<void>&>(cancel), 0, hat);
}
void FakeFingerprintEngineUdfps::authenticateImpl(ISessionCallback* cb, int64_t operationId,
const std::future<void>& cancel) {
updateContext(WorkMode::kAuthenticate, cb, const_cast<std::future<void>&>(cancel), operationId,
keymaster::HardwareAuthToken());
}
void FakeFingerprintEngineUdfps::detectInteractionImpl(ISessionCallback* cb,
const std::future<void>& cancel) {
updateContext(WorkMode::kDetectInteract, cb, const_cast<std::future<void>&>(cancel), 0,
keymaster::HardwareAuthToken());
}
void FakeFingerprintEngineUdfps::updateContext(WorkMode mode, ISessionCallback* cb,
std::future<void>& cancel, int64_t operationId,
const keymaster::HardwareAuthToken& hat) {
FakeFingerprintEngine::updateContext(mode, cb, cancel, operationId, hat);
mPointerDownTime = 0;
mUiReadyTime = 0;
mCancelVec.clear();
mCancelVec.push_back(std::move(cancel));
mWorkMode = mode;
mCb = cb;
mOperationId = operationId;
mHat = hat;
}
} // namespace aidl::android::hardware::biometrics::fingerprint

View file

@ -17,6 +17,7 @@
#include "Fingerprint.h"
#include "Session.h"
#include <android-base/properties.h>
#include <fingerprint.sysprop.h>
#include <android-base/file.h>
@ -59,6 +60,7 @@ Fingerprint::Fingerprint() : mWorker(MAX_WORKER_QUEUE_SIZE) {
<< sensorTypeProp;
}
LOG(INFO) << "sensorTypeProp:" << sensorTypeProp;
LOG(INFO) << "ro.product.name=" << ::android::base::GetProperty("ro.product.name", "UNKNOWN");
}
ndk::ScopedAStatus Fingerprint::getSensorProps(std::vector<SensorProps>* out) {
@ -105,16 +107,16 @@ ndk::ScopedAStatus Fingerprint::createSession(int32_t sensorId, int32_t userId,
mSession->linkToDeath(cb->asBinder().get());
LOG(INFO) << "createSession: sensorId:" << sensorId << " userId:" << userId;
LOG(INFO) << __func__ << ": sensorId:" << sensorId << " userId:" << userId;
return ndk::ScopedAStatus::ok();
}
binder_status_t Fingerprint::dump(int fd, const char** /*args*/, uint32_t numArgs) {
if (fd < 0) {
LOG(ERROR) << "Fingerprint::dump fd invalid: " << fd;
LOG(ERROR) << __func__ << "fd invalid: " << fd;
return STATUS_BAD_VALUE;
} else {
LOG(INFO) << "Fingerprint::dump fd:" << fd << "numArgs:" << numArgs;
LOG(INFO) << __func__ << " fd:" << fd << "numArgs:" << numArgs;
}
dprintf(fd, "----- FingerprintVirtualHal::dump -----\n");
@ -131,11 +133,11 @@ binder_status_t Fingerprint::dump(int fd, const char** /*args*/, uint32_t numArg
binder_status_t Fingerprint::handleShellCommand(int in, int out, int err, const char** args,
uint32_t numArgs) {
LOG(INFO) << "Fingerprint::handleShellCommand in:" << in << " out:" << out << " err:" << err
LOG(INFO) << __func__ << " in:" << in << " out:" << out << " err:" << err
<< " numArgs:" << numArgs;
if (numArgs == 0) {
LOG(INFO) << "Fingerprint::handleShellCommand: available commands";
LOG(INFO) << __func__ << ": available commands";
onHelp(out);
return STATUS_OK;
}
@ -163,7 +165,7 @@ void Fingerprint::onHelp(int fd) {
}
void Fingerprint::resetConfigToDefault() {
LOG(INFO) << "reset virtual HAL configuration to default";
LOG(INFO) << __func__ << ": reset virtual HAL configuration to default";
#define RESET_CONFIG_O(__NAME__) \
if (FingerprintHalProperties::__NAME__()) FingerprintHalProperties::__NAME__(std::nullopt)
#define RESET_CONFIG_V(__NAME__) \

View file

@ -38,7 +38,7 @@ namespace aidl::android::hardware::biometrics::fingerprint {
// A fake engine that is backed by system properties instead of hardware.
class FakeFingerprintEngine {
public:
FakeFingerprintEngine() : mRandom(std::mt19937::default_seed) {}
FakeFingerprintEngine();
virtual ~FakeFingerprintEngine() {}
void generateChallengeImpl(ISessionCallback* cb);
@ -66,6 +66,8 @@ class FakeFingerprintEngine {
virtual SensorLocation defaultSensorLocation();
virtual void fingerDownAction();
std::vector<int32_t> parseIntSequence(const std::string& str, const std::string& sep = ",");
std::vector<std::vector<int32_t>> parseEnrollmentCapture(const std::string& str);
@ -74,15 +76,35 @@ class FakeFingerprintEngine {
std::mt19937 mRandom;
enum class WorkMode : int8_t { kIdle = 0, kAuthenticate, kEnroll, kDetectInteract };
WorkMode getWorkMode() { return mWorkMode; }
virtual std::string toString() const {
std::ostringstream os;
os << "----- FakeFingerprintEngine:: -----" << std::endl;
os << "mWorkMode:" << (int)mWorkMode;
os << "acquiredVendorInfoBase:" << FINGERPRINT_ACQUIRED_VENDOR_BASE;
os << ", errorVendorBase:" << FINGERPRINT_ERROR_VENDOR_BASE << std::endl;
os << mLockoutTracker.toString();
return os.str();
}
protected:
virtual void updateContext(WorkMode mode, ISessionCallback* cb, std::future<void>& cancel,
int64_t operationId, const keymaster::HardwareAuthToken& hat);
void onEnrollFingerDown(ISessionCallback* cb, const keymaster::HardwareAuthToken& hat,
const std::future<void>& cancel);
void onAuthenticateFingerDown(ISessionCallback* cb, int64_t, const std::future<void>& cancel);
void onDetectInteractFingerDown(ISessionCallback* cb, const std::future<void>& cancel);
WorkMode mWorkMode;
ISessionCallback* mCb;
keymaster::HardwareAuthToken mHat;
std::future<void> mCancel;
int64_t mOperationId;
private:
static constexpr int32_t FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000;
static constexpr int32_t FINGERPRINT_ERROR_VENDOR_BASE = 1000;

View file

@ -42,39 +42,20 @@ class FakeFingerprintEngineUdfps : public FakeFingerprintEngine {
SensorLocation defaultSensorLocation() override;
void enrollImpl(ISessionCallback* cb, const keymaster::HardwareAuthToken& hat,
const std::future<void>& cancel);
void authenticateImpl(ISessionCallback* cb, int64_t operationId,
const std::future<void>& cancel);
void detectInteractionImpl(ISessionCallback* cb, const std::future<void>& cancel);
enum class WorkMode : int8_t { kIdle = 0, kAuthenticate, kEnroll, kDetectInteract };
WorkMode getWorkMode() { return mWorkMode; }
void updateContext(WorkMode mode, ISessionCallback* cb, std::future<void>& cancel,
int64_t operationId, const keymaster::HardwareAuthToken& hat);
void fingerDownAction();
std::string toString() const {
std::ostringstream os;
os << FakeFingerprintEngine::toString();
os << "----- FakeFingerprintEngineUdfps -----" << std::endl;
os << "mWorkMode:" << (int)mWorkMode;
os << ", mUiReadyTime:" << mUiReadyTime;
os << ", mPointerDownTime:" << mPointerDownTime << std::endl;
return os.str();
}
private:
void onAuthenticateFingerDown();
void onEnrollFingerDown();
void onDetectInteractFingerDown();
void fingerDownAction();
void updateContext(WorkMode mode, ISessionCallback* cb, std::future<void>& cancel,
int64_t operationId, const keymaster::HardwareAuthToken& hat);
WorkMode mWorkMode;
ISessionCallback* mCb;
keymaster::HardwareAuthToken mHat;
std::vector<std::future<void>> mCancelVec;
int64_t mOperationId;
int64_t mPointerDownTime;
int64_t mUiReadyTime;
};

View file

@ -43,6 +43,7 @@ class Fingerprint : public BnFingerprint {
private:
void resetConfigToDefault();
void onHelp(int);
void onSimFingerDown();
std::unique_ptr<FakeFingerprintEngine> mEngine;
WorkerThread mWorker;

View file

@ -178,6 +178,8 @@ TEST_F(FakeFingerprintEngineTest, Enroll) {
FingerprintHalProperties::next_enrollment("4:0,0:true");
keymaster::HardwareAuthToken hat{.mac = {2, 4}};
mEngine.enrollImpl(mCallback.get(), hat, mCancel.get_future());
ASSERT_EQ(mEngine.getWorkMode(), FakeFingerprintEngine::WorkMode::kEnroll);
mEngine.fingerDownAction();
ASSERT_FALSE(FingerprintHalProperties::next_enrollment().has_value());
ASSERT_EQ(1, FingerprintHalProperties::enrollments().size());
ASSERT_EQ(4, FingerprintHalProperties::enrollments()[0].value());
@ -192,6 +194,7 @@ TEST_F(FakeFingerprintEngineTest, EnrollCancel) {
keymaster::HardwareAuthToken hat{.mac = {2, 4}};
mCancel.set_value();
mEngine.enrollImpl(mCallback.get(), hat, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(Error::CANCELED, mCallback->mError);
ASSERT_EQ(-1, mCallback->mLastEnrolled);
ASSERT_EQ(0, FingerprintHalProperties::enrollments().size());
@ -204,6 +207,7 @@ TEST_F(FakeFingerprintEngineTest, EnrollFail) {
FingerprintHalProperties::next_enrollment(next);
keymaster::HardwareAuthToken hat{.mac = {2, 4}};
mEngine.enrollImpl(mCallback.get(), hat, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(Error::UNABLE_TO_PROCESS, mCallback->mError);
ASSERT_EQ(-1, mCallback->mLastEnrolled);
ASSERT_EQ(0, FingerprintHalProperties::enrollments().size());
@ -216,6 +220,7 @@ TEST_F(FakeFingerprintEngineTest, EnrollAcquired) {
keymaster::HardwareAuthToken hat{.mac = {2, 4}};
int32_t prevCnt = mCallback->mLastAcquiredCount;
mEngine.enrollImpl(mCallback.get(), hat, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_FALSE(FingerprintHalProperties::next_enrollment().has_value());
ASSERT_EQ(1, FingerprintHalProperties::enrollments().size());
ASSERT_EQ(4, FingerprintHalProperties::enrollments()[0].value());
@ -229,6 +234,8 @@ TEST_F(FakeFingerprintEngineTest, Authenticate) {
FingerprintHalProperties::enrollments({1, 2});
FingerprintHalProperties::enrollment_hit(2);
mEngine.authenticateImpl(mCallback.get(), 0, mCancel.get_future());
ASSERT_EQ(mEngine.getWorkMode(), FakeFingerprintEngine::WorkMode::kAuthenticate);
mEngine.fingerDownAction();
ASSERT_FALSE(mCallback->mAuthenticateFailed);
ASSERT_EQ(2, mCallback->mLastAuthenticated);
ASSERT_EQ(1, mCallback->mLastAcquiredInfo);
@ -239,6 +246,7 @@ TEST_F(FakeFingerprintEngineTest, AuthenticateCancel) {
FingerprintHalProperties::enrollment_hit(2);
mCancel.set_value();
mEngine.authenticateImpl(mCallback.get(), 0, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(Error::CANCELED, mCallback->mError);
ASSERT_EQ(-1, mCallback->mLastAuthenticated);
}
@ -247,6 +255,7 @@ TEST_F(FakeFingerprintEngineTest, AuthenticateNotSet) {
FingerprintHalProperties::enrollments({1, 2});
FingerprintHalProperties::enrollment_hit({});
mEngine.authenticateImpl(mCallback.get(), 0, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_TRUE(mCallback->mAuthenticateFailed);
}
@ -254,6 +263,7 @@ TEST_F(FakeFingerprintEngineTest, AuthenticateNotEnrolled) {
FingerprintHalProperties::enrollments({1, 2});
FingerprintHalProperties::enrollment_hit(3);
mEngine.authenticateImpl(mCallback.get(), 0, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_TRUE(mCallback->mAuthenticateFailed);
}
@ -262,6 +272,7 @@ TEST_F(FakeFingerprintEngineTest, AuthenticateLockout) {
FingerprintHalProperties::enrollment_hit(2);
FingerprintHalProperties::lockout(true);
mEngine.authenticateImpl(mCallback.get(), 0, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_TRUE(mCallback->mLockoutPermanent);
ASSERT_NE(mCallback->mError, Error::UNKNOWN);
}
@ -269,6 +280,7 @@ TEST_F(FakeFingerprintEngineTest, AuthenticateLockout) {
TEST_F(FakeFingerprintEngineTest, AuthenticateError8) {
FingerprintHalProperties::operation_authenticate_error(8);
mEngine.authenticateImpl(mCallback.get(), 0, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(mCallback->mError, (Error)8);
ASSERT_EQ(mCallback->mErrorVendorCode, 0);
}
@ -276,6 +288,7 @@ TEST_F(FakeFingerprintEngineTest, AuthenticateError8) {
TEST_F(FakeFingerprintEngineTest, AuthenticateError9) {
FingerprintHalProperties::operation_authenticate_error(1009);
mEngine.authenticateImpl(mCallback.get(), 0, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(mCallback->mError, (Error)7);
ASSERT_EQ(mCallback->mErrorVendorCode, 9);
}
@ -287,6 +300,7 @@ TEST_F(FakeFingerprintEngineTest, AuthenticateAcquired) {
FingerprintHalProperties::operation_authenticate_acquired("4,1009");
int32_t prevCount = mCallback->mLastAcquiredCount;
mEngine.authenticateImpl(mCallback.get(), 0, mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_FALSE(mCallback->mAuthenticateFailed);
ASSERT_EQ(2, mCallback->mLastAuthenticated);
ASSERT_EQ(prevCount + 2, mCallback->mLastAcquiredCount);
@ -300,6 +314,8 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetect) {
FingerprintHalProperties::enrollment_hit(2);
FingerprintHalProperties::operation_detect_interaction_acquired("");
mEngine.detectInteractionImpl(mCallback.get(), mCancel.get_future());
ASSERT_EQ(mEngine.getWorkMode(), FakeFingerprintEngine::WorkMode::kDetectInteract);
mEngine.fingerDownAction();
ASSERT_EQ(1, mCallback->mInteractionDetectedCount);
ASSERT_EQ(1, mCallback->mLastAcquiredInfo);
}
@ -310,6 +326,7 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetectCancel) {
FingerprintHalProperties::enrollment_hit(2);
mCancel.set_value();
mEngine.detectInteractionImpl(mCallback.get(), mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(Error::CANCELED, mCallback->mError);
ASSERT_EQ(0, mCallback->mInteractionDetectedCount);
}
@ -319,6 +336,7 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetectNotSet) {
FingerprintHalProperties::enrollments({1, 2});
FingerprintHalProperties::enrollment_hit({});
mEngine.detectInteractionImpl(mCallback.get(), mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(0, mCallback->mInteractionDetectedCount);
}
@ -326,6 +344,7 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetectNotEnrolled) {
FingerprintHalProperties::enrollments({1, 2});
FingerprintHalProperties::enrollment_hit(25);
mEngine.detectInteractionImpl(mCallback.get(), mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(0, mCallback->mInteractionDetectedCount);
}
@ -333,6 +352,7 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetectError) {
FingerprintHalProperties::detect_interaction(true);
FingerprintHalProperties::operation_detect_interaction_error(8);
mEngine.detectInteractionImpl(mCallback.get(), mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(0, mCallback->mInteractionDetectedCount);
ASSERT_EQ(mCallback->mError, (Error)8);
ASSERT_EQ(mCallback->mErrorVendorCode, 0);
@ -345,6 +365,7 @@ TEST_F(FakeFingerprintEngineTest, InteractionDetectAcquired) {
FingerprintHalProperties::operation_detect_interaction_acquired("4,1013");
int32_t prevCount = mCallback->mLastAcquiredCount;
mEngine.detectInteractionImpl(mCallback.get(), mCancel.get_future());
mEngine.fingerDownAction();
ASSERT_EQ(1, mCallback->mInteractionDetectedCount);
ASSERT_EQ(prevCount + 2, mCallback->mLastAcquiredCount);
ASSERT_EQ(7, mCallback->mLastAcquiredInfo);