Merge changes Ia90c6390,I5b3ed1b8 into sc-dev am: 9581a89057

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/15350855

Change-Id: Iab349f408d00ce5521f6fcea5cbf0b362c85231e
This commit is contained in:
Ilya Matyukhin 2021-07-22 18:59:08 +00:00 committed by Automerger Merge Worker
commit c0d9308881
2 changed files with 11 additions and 4 deletions

View file

@ -107,7 +107,8 @@ ndk::ScopedAStatus Session::removeEnrollments(const std::vector<int32_t>& /*enro
ndk::ScopedAStatus Session::getFeatures() {
LOG(INFO) << "getFeatures";
if (cb_) {
cb_->onFeaturesRetrieved({});
// Must error out with UNABLE_TO_PROCESS when no faces are enrolled.
cb_->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorCode */);
}
return ndk::ScopedAStatus::ok();
}

View file

@ -60,9 +60,10 @@ class SessionCallback : public BnSessionCallback {
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus onError(Error error, int32_t /*vendorCode*/) override {
ndk::ScopedAStatus onError(Error error, int32_t vendorCode) override {
auto lock = std::lock_guard<std::mutex>{mMutex};
mError = error;
mVendorCode = vendorCode;
mOnErrorInvoked = true;
mCv.notify_one();
return ndk::ScopedAStatus::ok();
@ -141,6 +142,7 @@ class SessionCallback : public BnSessionCallback {
std::mutex mMutex;
std::condition_variable mCv;
Error mError = Error::UNKNOWN;
int32_t mVendorCode = 0;
int64_t mGeneratedChallenge = 0;
int64_t mRevokedChallenge = 0;
bool mOnChallengeGeneratedInvoked = false;
@ -218,6 +220,8 @@ TEST_P(Face, EnrollWithBadHatResultsInErrorTest) {
// Make sure an error is returned.
auto lock = std::unique_lock{mCb->mMutex};
mCb->mCv.wait(lock, [this] { return mCb->mOnErrorInvoked; });
EXPECT_EQ(mCb->mError, Error::UNABLE_TO_PROCESS);
EXPECT_EQ(mCb->mVendorCode, 0);
}
TEST_P(Face, GenerateChallengeProducesUniqueChallengesTest) {
@ -287,13 +291,15 @@ TEST_P(Face, RemoveEnrollmentsWorksTest) {
mCb->mCv.wait(lock, [this] { return mCb->mOnEnrollmentsRemovedInvoked; });
}
TEST_P(Face, GetFeaturesWorksTest) {
TEST_P(Face, GetFeaturesWithoutEnrollmentsResultsInUnableToProcess) {
// Call the method.
ASSERT_TRUE(mSession->getFeatures().isOk());
// Wait for the result.
auto lock = std::unique_lock{mCb->mMutex};
mCb->mCv.wait(lock, [this] { return mCb->mOnFeaturesRetrievedInvoked; });
mCb->mCv.wait(lock, [this] { return mCb->mOnErrorInvoked; });
EXPECT_EQ(mCb->mError, Error::UNABLE_TO_PROCESS);
EXPECT_EQ(mCb->mVendorCode, 0);
}
TEST_P(Face, GetAuthenticatorIdWorksTest) {