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

Commit f3c53e9c authored by Ilya Matyukhin's avatar Ilya Matyukhin Committed by Automerger Merge Worker
Browse files

IFingerprint: update default implementation am: 1d524385

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

Change-Id: I9072ef742649bb4258071c43f1fda7cc6d75db0d
parents 4891b80c 1d524385
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -17,14 +17,19 @@
#pragma once
#pragma once


#include <android-base/logging.h>
#include <android-base/logging.h>
#include <random>


namespace aidl::android::hardware::biometrics::fingerprint {
namespace aidl::android::hardware::biometrics::fingerprint {


class FakeFingerprintEngine {
class FakeFingerprintEngine {
  public:
  public:
    FakeFingerprintEngine() : mRandom(std::mt19937::default_seed) {}

    void generateChallengeImpl(ISessionCallback* cb) {
    void generateChallengeImpl(ISessionCallback* cb) {
        LOG(INFO) << "generateChallengeImpl";
        LOG(INFO) << "generateChallengeImpl";
        cb->onChallengeGenerated(0 /* challenge */);
        std::uniform_int_distribution<int64_t> dist;
        auto challenge = dist(mRandom);
        cb->onChallengeGenerated(challenge);
    }
    }


    void revokeChallengeImpl(ISessionCallback* cb, int64_t challenge) {
    void revokeChallengeImpl(ISessionCallback* cb, int64_t challenge) {
@@ -32,8 +37,13 @@ class FakeFingerprintEngine {
        cb->onChallengeRevoked(challenge);
        cb->onChallengeRevoked(challenge);
    }
    }


    void enrollImpl(ISessionCallback* cb, const keymaster::HardwareAuthToken& /*hat*/) {
    void enrollImpl(ISessionCallback* cb, const keymaster::HardwareAuthToken& hat) {
        LOG(INFO) << "enrollImpl";
        LOG(INFO) << "enrollImpl";
        // Do proper HAT verification in the real implementation.
        if (hat.mac.empty()) {
            cb->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorError */);
            return;
        }
        cb->onEnrollmentProgress(0 /* enrollmentId */, 0 /* remaining */);
        cb->onEnrollmentProgress(0 /* enrollmentId */, 0 /* remaining */);
    }
    }


@@ -71,6 +81,8 @@ class FakeFingerprintEngine {
        LOG(INFO) << "resetLockoutImpl";
        LOG(INFO) << "resetLockoutImpl";
        cb->onLockoutCleared();
        cb->onLockoutCleared();
    }
    }

    std::mt19937 mRandom;
};
};


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