Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60406bea authored by Ilya Matyukhin's avatar Ilya Matyukhin
Browse files

IFace: update default implementation

Bug: 170651283
Test: atest VtsHalBiometricsFaceTargetTest
Change-Id: I6f8e6ec12e597034264e2b1383bc7325b0f697b7
parent 53bd75df
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -34,12 +34,15 @@ class CancellationSignal : public common::BnCancellationSignal {
    }
};

Session::Session(std::shared_ptr<ISessionCallback> cb) : cb_(std::move(cb)) {}
Session::Session(std::shared_ptr<ISessionCallback> cb)
    : cb_(std::move(cb)), mRandom(std::mt19937::default_seed) {}

ndk::ScopedAStatus Session::generateChallenge() {
    LOG(INFO) << "generateChallenge";
    if (cb_) {
        cb_->onChallengeGenerated(0);
        std::uniform_int_distribution<int64_t> dist;
        auto challenge = dist(mRandom);
        cb_->onChallengeGenerated(challenge);
    }
    return ndk::ScopedAStatus::ok();
}
@@ -63,6 +66,9 @@ ndk::ScopedAStatus Session::enroll(
        const std::vector<Feature>& /*features*/, const NativeHandle& /*previewSurface*/,
        std::shared_ptr<biometrics::common::ICancellationSignal>* /*return_val*/) {
    LOG(INFO) << "enroll";
    if (cb_) {
        cb_->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorError */);
    }
    return ndk::ScopedAStatus::ok();
}

@@ -100,6 +106,9 @@ ndk::ScopedAStatus Session::removeEnrollments(const std::vector<int32_t>& /*enro

ndk::ScopedAStatus Session::getFeatures() {
    LOG(INFO) << "getFeatures";
    if (cb_) {
        cb_->onFeaturesRetrieved({});
    }
    return ndk::ScopedAStatus::ok();
}

@@ -119,6 +128,9 @@ ndk::ScopedAStatus Session::getAuthenticatorId() {

ndk::ScopedAStatus Session::invalidateAuthenticatorId() {
    LOG(INFO) << "invalidateAuthenticatorId";
    if (cb_) {
        cb_->onAuthenticatorIdInvalidated(0);
    }
    return ndk::ScopedAStatus::ok();
}

+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#pragma once

#include <random>

#include <aidl/android/hardware/biometrics/face/BnSession.h>
#include <aidl/android/hardware/biometrics/face/ISessionCallback.h>

@@ -68,6 +70,7 @@ class Session : public BnSession {

  private:
    std::shared_ptr<ISessionCallback> cb_;
    std::mt19937 mRandom;
};

}  // namespace aidl::android::hardware::biometrics::face