From 6e05ff47599b6672cb780548399f2633eb78af5a Mon Sep 17 00:00:00 2001 From: Curtis Belmonte Date: Wed, 27 Oct 2021 10:41:27 -0700 Subject: [PATCH] Fix UDFPS enroll when help received on first step Fixes an issue where the UDFPS enroll progress drawable would complete if an error resulted in a help message being sent on the first enrollment step. Instead, the progress bar will now remain empty in this case. Test: Manual Bug: 201364678 Bug: 201602528 Change-Id: I7df617287e448be3c40443b2fe0f1359b6ab2b82 --- .../biometrics/UdfpsEnrollProgressBarDrawable.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java index b2a54097539dd..11addf0e906bd 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java @@ -40,7 +40,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { @Nullable private UdfpsEnrollHelper mEnrollHelper; @NonNull private List mSegments = new ArrayList<>(); - private int mTotalSteps = 1; + private int mTotalSteps = 0; private int mProgressSteps = 0; private boolean mIsShowingHelp = false; @@ -67,22 +67,19 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { void onEnrollmentProgress(int remaining, int totalSteps) { mTotalSteps = totalSteps; - updateState(getProgressSteps(remaining, totalSteps), false /* isShowingHelp */); + + // Show some progress for the initial touch. + updateState(Math.max(1, totalSteps - remaining), false /* isShowingHelp */); } void onEnrollmentHelp(int remaining, int totalSteps) { - updateState(getProgressSteps(remaining, totalSteps), true /* isShowingHelp */); + updateState(Math.max(0, totalSteps - remaining), true /* isShowingHelp */); } void onLastStepAcquired() { updateState(mTotalSteps, false /* isShowingHelp */); } - private static int getProgressSteps(int remaining, int totalSteps) { - // Show some progress for the initial touch. - return Math.max(1, totalSteps - remaining); - } - private void updateState(int progressSteps, boolean isShowingHelp) { updateProgress(progressSteps); updateFillColor(isShowingHelp);