1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <aidl/android/hardware/biometrics/common/SensorStrength.h> 20 #include <aidl/android/hardware/biometrics/face/BnSession.h> 21 #include <aidl/android/hardware/biometrics/face/FaceSensorType.h> 22 #include <aidl/android/hardware/biometrics/face/ISessionCallback.h> 23 24 #include <random> 25 26 #include <future> 27 #include <vector> 28 29 namespace aidl::android::hardware::biometrics::face { 30 31 namespace face = aidl::android::hardware::biometrics::face; 32 namespace common = aidl::android::hardware::biometrics::common; 33 namespace keymaster = aidl::android::hardware::keymaster; 34 35 using aidl::android::hardware::common::NativeHandle; 36 // A fake engine that is backed by system properties instead of hardware. 37 class FakeFaceEngine { 38 public: FakeFaceEngine()39 FakeFaceEngine() : mRandom(std::mt19937::default_seed) {} 40 41 static face::FaceSensorType GetSensorType(); 42 static common::SensorStrength GetSensorStrength(); 43 void generateChallengeImpl(ISessionCallback* cb); 44 void revokeChallengeImpl(ISessionCallback* cb, int64_t challenge); 45 void getEnrollmentConfigImpl(ISessionCallback* cb, 46 std::vector<EnrollmentStageConfig>* return_val); 47 void enrollImpl(ISessionCallback* cb, const keymaster::HardwareAuthToken& hat, 48 EnrollmentType enrollmentType, const std::vector<Feature>& features, 49 const std::future<void>& cancel); 50 void authenticateImpl(ISessionCallback* cb, int64_t operationId, 51 const std::future<void>& cancel); 52 void detectInteractionImpl(ISessionCallback* cb, const std::future<void>& cancel); 53 void enumerateEnrollmentsImpl(ISessionCallback* cb); 54 void removeEnrollmentsImpl(ISessionCallback* cb, const std::vector<int32_t>& enrollmentIds); 55 void getFeaturesImpl(ISessionCallback* cb); 56 void setFeatureImpl(ISessionCallback* cb, const keymaster::HardwareAuthToken& hat, 57 Feature feature, bool enabled); 58 void getAuthenticatorIdImpl(ISessionCallback* cb); 59 void invalidateAuthenticatorIdImpl(ISessionCallback* cb); 60 void resetLockoutImpl(ISessionCallback* cb, const keymaster::HardwareAuthToken& /*hat*/); 61 62 std::mt19937 mRandom; 63 }; 64 65 } // namespace aidl::android::hardware::biometrics::face