diff options
7 files changed, 74 insertions, 16 deletions
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index 1f6a94d254b7..f64299dcd4c4 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -187,7 +187,6 @@ <!-- UDFPS colors --> <color name="udfps_enroll_icon">#000000</color> <!-- 100% black --> <color name="udfps_moving_target_fill">#cc4285f4</color> <!-- 80% blue --> - <color name="udfps_moving_target_stroke">#ff669DF6</color> <!-- 100% blue --> <color name="udfps_enroll_progress">#ff669DF6</color> <!-- 100% blue --> <!-- Logout button --> diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 67dcc8db76fe..dd339abb3a40 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -211,6 +211,12 @@ public class UdfpsController implements DozeReceiver { } } + void onAcquiredGood() { + if (mEnrollHelper != null) { + mEnrollHelper.animateIfLastStep(); + } + } + void onEnrollmentHelp() { if (mEnrollHelper != null) { mEnrollHelper.onEnrollmentHelp(); @@ -260,6 +266,11 @@ public class UdfpsController implements DozeReceiver { } mGoodCaptureReceived = true; mView.stopIllumination(); + if (mServerRequest != null) { + mServerRequest.onAcquiredGood(); + } else { + Log.e(TAG, "Null serverRequest when onAcquiredGood"); + } }); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java index 6b6e0f19d7fb..ea69b1d626ae 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java @@ -47,7 +47,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { @NonNull private final Drawable mMovingTargetFpIcon; @NonNull private final Paint mSensorOutlinePaint; @NonNull private final Paint mBlueFill; - @NonNull private final Paint mBlueStroke; @Nullable private RectF mSensorRect; @Nullable private UdfpsEnrollHelper mEnrollHelper; @@ -76,12 +75,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { mBlueFill.setColor(context.getColor(R.color.udfps_moving_target_fill)); mBlueFill.setStyle(Paint.Style.FILL); - mBlueStroke = new Paint(0 /* flags */); - mBlueStroke.setAntiAlias(true); - mBlueStroke.setColor(context.getColor(R.color.udfps_moving_target_stroke)); - mBlueStroke.setStyle(Paint.Style.STROKE); - mBlueStroke.setStrokeWidth(12); - mMovingTargetFpIcon = context.getResources().getDrawable(R.drawable.ic_fingerprint, null); mMovingTargetFpIcon.setTint(Color.WHITE); mMovingTargetFpIcon.mutate(); @@ -146,6 +139,10 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { } } + void onLastStepAcquired() { + mProgressDrawable.onLastStepAcquired(); + } + @Override public void draw(@NonNull Canvas canvas) { mProgressDrawable.draw(canvas); @@ -163,7 +160,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { canvas.scale(mCurrentScale, mCurrentScale, mSensorRect.centerX(), mSensorRect.centerY()); canvas.drawOval(mSensorRect, mBlueFill); - canvas.drawOval(mSensorRect, mBlueStroke); } mMovingTargetFpIcon.draw(canvas); @@ -188,7 +184,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { super.setAlpha(alpha); mSensorOutlinePaint.setAlpha(alpha); mBlueFill.setAlpha(alpha); - mBlueStroke.setAlpha(alpha); mMovingTargetFpIcon.setAlpha(alpha); invalidateSelf(); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java index 470fb8c1a561..6a918a6c8d39 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java @@ -49,6 +49,7 @@ public class UdfpsEnrollHelper { interface Listener { void onEnrollmentProgress(int remaining, int totalSteps); + void onLastStepAcquired(); } @NonNull private final Context mContext; @@ -178,4 +179,15 @@ public class UdfpsEnrollHelper { .get(index % mGuidedEnrollmentPoints.size()); return new PointF(originalPoint.x * scale, originalPoint.y * scale); } + + void animateIfLastStep() { + if (mListener == null) { + Log.e(TAG, "animateIfLastStep, null listener"); + return; + } + + if (mRemainingSteps <= 2 && mRemainingSteps >= 0) { + mListener.onLastStepAcquired(); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java index 5c9e52f86471..4195009937c2 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java @@ -23,6 +23,7 @@ import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.drawable.Drawable; +import android.util.Log; import android.util.TypedValue; import androidx.annotation.NonNull; @@ -46,6 +47,8 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { @Nullable private ValueAnimator mProgressAnimator; private float mProgress; + private int mRotation; // After last step, rotate the progress bar once + private boolean mLastStepAcquired; public UdfpsEnrollProgressBarDrawable(@NonNull Context context, @NonNull UdfpsEnrollDrawable parent) { @@ -81,13 +84,34 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { // Add one so that the first steps actually changes progress, but also so that the last // step ends at 1.0 final float progress = (totalSteps - remaining + 1) / (float) (totalSteps + 1); + setEnrollmentProgress(progress); + } + + private void setEnrollmentProgress(float progress) { + if (mLastStepAcquired) { + return; + } + + long animationDuration = 150; + + if (progress == 1.f) { + animationDuration = 400; + final ValueAnimator rotationAnimator = ValueAnimator.ofInt(0, 400); + rotationAnimator.setDuration(animationDuration); + rotationAnimator.addUpdateListener(animation -> { + Log.d(TAG, "Rotation: " + mRotation); + mRotation = (int) animation.getAnimatedValue(); + mParent.invalidateSelf(); + }); + rotationAnimator.start(); + } if (mProgressAnimator != null && mProgressAnimator.isRunning()) { mProgressAnimator.cancel(); } mProgressAnimator = ValueAnimator.ofFloat(mProgress, progress); - mProgressAnimator.setDuration(150); + mProgressAnimator.setDuration(animationDuration); mProgressAnimator.addUpdateListener(animation -> { mProgress = (float) animation.getAnimatedValue(); // Use the parent to invalidate, since it's the one that's attached as the view's @@ -99,12 +123,17 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { mProgressAnimator.start(); } + void onLastStepAcquired() { + setEnrollmentProgress(1.f); + mLastStepAcquired = true; + } + @Override public void draw(@NonNull Canvas canvas) { canvas.save(); // Progress starts from the top, instead of the right - canvas.rotate(-90, getBounds().centerX(), getBounds().centerY()); + canvas.rotate(-90 + mRotation, getBounds().centerX(), getBounds().centerY()); // Progress bar "background track" final float halfPaddingPx = Utils.dpToPixels(mContext, PROGRESS_BAR_THICKNESS_DP) / 2; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java index 3b3022045849..7f4d7fe01e90 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java @@ -63,8 +63,10 @@ public class UdfpsEnrollView extends UdfpsAnimationView { } void onEnrollmentProgress(int remaining, int totalSteps) { - mHandler.post(() -> { - mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps); - }); + mHandler.post(() -> mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps)); + } + + void onLastStepAcquired() { + mHandler.post(mFingerprintDrawable::onLastStepAcquired); } } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollViewController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollViewController.java index 953448d93d6a..91cc149be800 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollViewController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollViewController.java @@ -32,7 +32,17 @@ public class UdfpsEnrollViewController extends UdfpsAnimationViewController<Udfp private final int mEnrollProgressBarRadius; @NonNull private final UdfpsEnrollHelper mEnrollHelper; @NonNull private final UdfpsEnrollHelper.Listener mEnrollHelperListener = - mView::onEnrollmentProgress; + new UdfpsEnrollHelper.Listener() { + @Override + public void onEnrollmentProgress(int remaining, int totalSteps) { + mView.onEnrollmentProgress(remaining, totalSteps); + } + + @Override + public void onLastStepAcquired() { + mView.onLastStepAcquired(); + } + }; protected UdfpsEnrollViewController( @NonNull UdfpsEnrollView view, |