1 /* 2 * Copyright (C) 2023 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 package com.android.settings.biometrics.fingerprint.feature; 18 19 import android.animation.Animator; 20 import android.content.Context; 21 import android.view.View; 22 23 import androidx.annotation.NonNull; 24 25 import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling; 26 27 import com.airbnb.lottie.LottieAnimationView; 28 29 import java.util.function.Function; 30 import java.util.function.Supplier; 31 32 public interface SfpsEnrollmentFeature { 33 34 /** 35 * Gets current SFPS enrollment stage. 36 * @param progressSteps current step of enrollment 37 * @param mapper a mapper to map each stage to its threshold 38 * @return current enrollment stage 39 */ getCurrentSfpsEnrollStage(int progressSteps, Function<Integer, Integer> mapper)40 int getCurrentSfpsEnrollStage(int progressSteps, Function<Integer, Integer> mapper); 41 42 /** 43 * Gets the vendor string by feature. 44 * @param context Context 45 * @param id An integer identifying the error message 46 * @param msg A human-readable string that can be shown in UI 47 * @return A human-readable string of specific feature 48 */ getFeaturedVendorString(Context context, int id, CharSequence msg)49 default CharSequence getFeaturedVendorString(Context context, int id, CharSequence msg) { 50 return msg; 51 } 52 53 /** 54 * Gets the stage header string by feature. 55 * @param stage the specific stage 56 * @return the resource id of the header text of the specific stage 57 */ getFeaturedStageHeaderResource(int stage)58 int getFeaturedStageHeaderResource(int stage); 59 60 /** 61 * Gets the enrollment lottie resource id per stage 62 * @param stage current enrollment stage 63 * @return enrollment lottie resource id 64 */ getSfpsEnrollLottiePerStage(int stage)65 int getSfpsEnrollLottiePerStage(int stage); 66 67 /** 68 * Handles extra stuffs on receiving enrollment help. 69 * @param helpMsgId help message id 70 * @param helpString help message 71 * @param enrollingSupplier supplier of enrolling context 72 */ handleOnEnrollmentHelp(int helpMsgId, CharSequence helpString, Supplier<FingerprintEnrollEnrolling> enrollingSupplier)73 default void handleOnEnrollmentHelp(int helpMsgId, CharSequence helpString, 74 Supplier<FingerprintEnrollEnrolling> enrollingSupplier) {} 75 76 /** 77 * Gets the fingerprint enrollment threshold. 78 * @param context context 79 * @param index the enrollment stage index 80 * @return threshold 81 */ getEnrollStageThreshold(@onNull Context context, int index)82 float getEnrollStageThreshold(@NonNull Context context, int index); 83 84 /** 85 * Gets the help animator used when get help message. 86 * @param target the target view to animate 87 * @return animator 88 */ getHelpAnimator(@onNull View target)89 Animator getHelpAnimator(@NonNull View target); 90 91 /** 92 * Handles extra stuffs on lottie composition. 93 * @param lottieView the view related to the lottie 94 */ handleOnEnrollmentLottieComposition(LottieAnimationView lottieView)95 default void handleOnEnrollmentLottieComposition(LottieAnimationView lottieView) {} 96 97 /** 98 * Indicates if the title and description should be updated. 99 * @return true to update the title and description; false otherwise. 100 */ shouldUpdateTitleAndDescription()101 default boolean shouldUpdateTitleAndDescription() { 102 return true; 103 } 104 105 /** 106 * Notifies an acquisition happens. 107 * @param isAcquiredGood isAcquiredGood 108 */ handleOnAcquired(boolean isAcquiredGood)109 default void handleOnAcquired(boolean isAcquiredGood) {} 110 111 /** 112 * Notifies an enrollment progress changes event. 113 * @param steps steps 114 * @param remaining remaining 115 */ handleOnEnrollmentProgressChange(int steps, int remaining)116 default void handleOnEnrollmentProgressChange(int steps, int remaining) {} 117 } 118