/* * Copyright 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "BiometricsFace.h" namespace android::hardware::biometrics::face::implementation { using android::hardware::biometrics::face::V1_0::FaceError; using android::hardware::biometrics::face::V1_0::OptionalUint64; // Arbitrary value. constexpr uint64_t kDeviceId = 123; // Arbitrary value. constexpr uint64_t kAuthenticatorId = 987; // Not locked out. constexpr uint64_t kLockoutDuration = 0; BiometricsFace::BiometricsFace() : mRandom(std::mt19937::default_seed) {} // Methods from IBiometricsFace follow. Return BiometricsFace::setCallback(const sp& clientCallback, setCallback_cb _hidl_cb) { mClientCallback = clientCallback; _hidl_cb({Status::OK, kDeviceId}); return Void(); } Return BiometricsFace::setActiveUser(int32_t userId, const hidl_string& storePath) { if (userId < 0 || storePath.empty() || std::string(storePath).find("/data") != 0) { return Status::ILLEGAL_ARGUMENT; } mUserId = userId; mClientCallback->onLockoutChanged(kLockoutDuration); return Status::OK; } Return BiometricsFace::generateChallenge(uint32_t /* challengeTimeoutSec */, generateChallenge_cb _hidl_cb) { std::uniform_int_distribution dist; _hidl_cb({Status::OK, dist(mRandom)}); return Void(); } Return BiometricsFace::enroll(const hidl_vec& /* hat */, uint32_t /* timeoutSec */, const hidl_vec& /* disabledFeatures */) { // hat can never be valid in this implementation. mClientCallback->onError(kDeviceId, mUserId, FaceError::UNABLE_TO_PROCESS, 0 /* vendorCode */); return Status::OK; } Return BiometricsFace::revokeChallenge() { return Status::OK; } Return BiometricsFace::setFeature(Feature /* feature */, bool /* enabled */, const hidl_vec& /* hat */, uint32_t /* faceId */) { // hat can never be valid in this implementation. return Status::ILLEGAL_ARGUMENT; } Return BiometricsFace::getFeature(Feature /* feature */, uint32_t /* faceId */, getFeature_cb _hidl_cb) { // hat can never be valid in this implementation. _hidl_cb({Status::ILLEGAL_ARGUMENT, false}); return Void(); } Return BiometricsFace::getAuthenticatorId(getAuthenticatorId_cb _hidl_cb) { _hidl_cb({Status::OK, kAuthenticatorId}); return Void(); } Return BiometricsFace::cancel() { mClientCallback->onError(kDeviceId, mUserId, FaceError::CANCELED, 0 /* vendorCode */); return Status::OK; } Return BiometricsFace::enumerate() { mClientCallback->onEnumerate(kDeviceId, {}, mUserId); return Status::OK; } Return BiometricsFace::remove(uint32_t /* faceId */) { return Status::OK; } Return BiometricsFace::authenticate(uint64_t /* operationId */) { mClientCallback->onError(kDeviceId, mUserId, FaceError::HW_UNAVAILABLE, 0 /* vendorCode */); return Status::OK; } Return BiometricsFace::userActivity() { return Status::OK; } Return BiometricsFace::resetLockout(const hidl_vec& /* hat */) { return Status::OK; } } // namespace android::hardware::biometrics::face::implementation