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