diff options
author | Joshua Mccloskey <joshmccloskey@google.com> | 2021-08-30 12:07:46 -0700 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-09-03 01:48:44 +0000 |
commit | 8f39a3e6050682e48031b0ab6b7d2f37d14fb59e (patch) | |
tree | 532079faa56a6cd4aa360e40aa7db9e03edb8ac7 | |
parent | 1826f52f12876eb2fe90c0f59b4dd8745137d46e (diff) | |
download | base-8f39a3e6050682e48031b0ab6b7d2f37d14fb59e.tar.gz |
Udfps enrollment now focuses on fingerprint region
Test: Verified manually that the region that accesibility focuses on is
around the fingerprint sensor.
Test: Verified in landscape/reverse landscape/portrait & with/without accessibility
enabled.
Bug: 195614793
Change-Id: I2be5e5bf657254e843dc863afa56318708ec3411
(cherry picked from commit 2b229d14711971ce6d97e796b66c834ecd427146)
5 files changed, 45 insertions, 29 deletions
diff --git a/packages/SystemUI/res/layout/udfps_enroll_view.xml b/packages/SystemUI/res/layout/udfps_enroll_view.xml index f1ff6d669256..e41a632fa70a 100644 --- a/packages/SystemUI/res/layout/udfps_enroll_view.xml +++ b/packages/SystemUI/res/layout/udfps_enroll_view.xml @@ -20,10 +20,23 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + <!-- The layout height/width are placeholders, which will be overwritten by + FingerprintSensorPropertiesInternal. --> + <View + android:id="@+id/udfps_enroll_accessibility_view" + android:layout_gravity="center" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:contentDescription="@string/accessibility_fingerprint_label"/> + + <ImageView + android:id="@+id/udfps_enroll_animation_fp_progress_view" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + <!-- Fingerprint --> <ImageView android:id="@+id/udfps_enroll_animation_fp_view" android:layout_width="match_parent" - android:layout_height="match_parent" - android:contentDescription="@string/accessibility_fingerprint_label"/> + android:layout_height="match_parent"/> </com.android.systemui.biometrics.UdfpsEnrollView> diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 2de489d2ce21..39ea75d5d1da 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -759,6 +759,7 @@ public class UdfpsController implements DozeReceiver { UdfpsEnrollView enrollView = (UdfpsEnrollView) mInflater.inflate( R.layout.udfps_enroll_view, null); mView.addView(enrollView); + enrollView.updateSensorLocation(mSensorProps); return new UdfpsEnrollViewController( enrollView, mServerRequest.mEnrollHelper, diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java index ea69b1d626ae..d4077563cfea 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java @@ -43,7 +43,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { // 1 + SCALE_MAX is the maximum that the moving target will animate to private static final float SCALE_MAX = 0.25f; - @NonNull private final UdfpsEnrollProgressBarDrawable mProgressDrawable; @NonNull private final Drawable mMovingTargetFpIcon; @NonNull private final Paint mSensorOutlinePaint; @NonNull private final Paint mBlueFill; @@ -62,7 +61,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { UdfpsEnrollDrawable(@NonNull Context context) { super(context); - mProgressDrawable = new UdfpsEnrollProgressBarDrawable(context, this); mSensorOutlinePaint = new Paint(0 /* flags */); mSensorOutlinePaint.setAntiAlias(true); @@ -100,8 +98,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { } void onEnrollmentProgress(int remaining, int totalSteps) { - mProgressDrawable.setEnrollmentProgress(remaining, totalSteps); - if (mEnrollHelper.isCenterEnrollmentComplete()) { if (mAnimatorSet != null && mAnimatorSet.isRunning()) { mAnimatorSet.end(); @@ -139,14 +135,8 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { } } - void onLastStepAcquired() { - mProgressDrawable.onLastStepAcquired(); - } - @Override public void draw(@NonNull Canvas canvas) { - mProgressDrawable.draw(canvas); - if (isIlluminationShowing()) { return; } @@ -175,11 +165,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable { } @Override - public void onBoundsChange(@NonNull Rect rect) { - mProgressDrawable.setBounds(rect); - } - - @Override public void setAlpha(int alpha) { super.setAlpha(alpha); mSensorOutlinePaint.setAlpha(alpha); diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java index 4195009937c2..4c26e0c767d1 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java @@ -41,7 +41,6 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { private static final float PROGRESS_BAR_THICKNESS_DP = 12; @NonNull private final Context mContext; - @NonNull private final UdfpsEnrollDrawable mParent; @NonNull private final Paint mBackgroundCirclePaint; @NonNull private final Paint mProgressPaint; @@ -50,10 +49,8 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { private int mRotation; // After last step, rotate the progress bar once private boolean mLastStepAcquired; - public UdfpsEnrollProgressBarDrawable(@NonNull Context context, - @NonNull UdfpsEnrollDrawable parent) { + public UdfpsEnrollProgressBarDrawable(@NonNull Context context) { mContext = context; - mParent = parent; mBackgroundCirclePaint = new Paint(); mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP)); @@ -101,7 +98,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { rotationAnimator.addUpdateListener(animation -> { Log.d(TAG, "Rotation: " + mRotation); mRotation = (int) animation.getAnimatedValue(); - mParent.invalidateSelf(); + invalidateSelf(); }); rotationAnimator.start(); } @@ -114,11 +111,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable { 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 - // drawable and has its callback set automatically. Invalidating via - // `this.invalidateSelf` actually does not invoke draw(), since this drawable's callback - // is not really set. - mParent.invalidateSelf(); + invalidateSelf(); }); mProgressAnimator.start(); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java index 2cdf49d6fc3c..5e58e0841bd0 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java @@ -17,9 +17,12 @@ package com.android.systemui.biometrics; import android.content.Context; +import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; import android.os.Handler; import android.os.Looper; import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; @@ -32,20 +35,25 @@ import com.android.systemui.R; */ public class UdfpsEnrollView extends UdfpsAnimationView { @NonNull private final UdfpsEnrollDrawable mFingerprintDrawable; + @NonNull private final UdfpsEnrollProgressBarDrawable mFingerprintProgressDrawable; @NonNull private final Handler mHandler; @NonNull private ImageView mFingerprintView; + @NonNull private ImageView mFingerprintProgressView; public UdfpsEnrollView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); mFingerprintDrawable = new UdfpsEnrollDrawable(mContext); + mFingerprintProgressDrawable = new UdfpsEnrollProgressBarDrawable(context); mHandler = new Handler(Looper.getMainLooper()); } @Override protected void onFinishInflate() { mFingerprintView = findViewById(R.id.udfps_enroll_animation_fp_view); + mFingerprintProgressView = findViewById(R.id.udfps_enroll_animation_fp_progress_view); mFingerprintView.setImageDrawable(mFingerprintDrawable); + mFingerprintProgressView.setImageDrawable(mFingerprintProgressDrawable); } @Override @@ -53,15 +61,31 @@ public class UdfpsEnrollView extends UdfpsAnimationView { return mFingerprintDrawable; } + void updateSensorLocation(@NonNull FingerprintSensorPropertiesInternal sensorProps) { + View fingerprintAccessibilityView = findViewById(R.id.udfps_enroll_accessibility_view); + final int sensorHeight = sensorProps.sensorRadius * 2; + final int sensorWidth = sensorHeight; + ViewGroup.LayoutParams params = fingerprintAccessibilityView.getLayoutParams(); + params.width = sensorWidth; + params.height = sensorHeight; + fingerprintAccessibilityView.setLayoutParams(params); + fingerprintAccessibilityView.requestLayout(); + } + void setEnrollHelper(UdfpsEnrollHelper enrollHelper) { mFingerprintDrawable.setEnrollHelper(enrollHelper); } void onEnrollmentProgress(int remaining, int totalSteps) { - mHandler.post(() -> mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps)); + mHandler.post(() -> { + mFingerprintProgressDrawable.setEnrollmentProgress(remaining, totalSteps); + mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps); + }); } void onLastStepAcquired() { - mHandler.post(mFingerprintDrawable::onLastStepAcquired); + mHandler.post(() -> { + mFingerprintProgressDrawable.onLastStepAcquired(); + }); } } |