Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 171b2938 authored by Joshua Mccloskey's avatar Joshua Mccloskey Committed by Automerger Merge Worker
Browse files

Merge "Udfps enrollment now focuses on fingerprint region" into sc-dev am: f375efdd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15718086

Change-Id: Ifc0411c8dbef96851ce56361355c0760f74bccfe
parents 9bbdf18d f375efdd
Loading
Loading
Loading
Loading
+15 −2
Original line number Original line Diff line number Diff line
@@ -20,10 +20,23 @@
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:layout_height="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 -->
    <!-- Fingerprint -->
    <ImageView
    <ImageView
        android:id="@+id/udfps_enroll_animation_fp_view"
        android:id="@+id/udfps_enroll_animation_fp_view"
        android:layout_width="match_parent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_height="match_parent"/>
        android:contentDescription="@string/accessibility_fingerprint_label"/>
</com.android.systemui.biometrics.UdfpsEnrollView>
</com.android.systemui.biometrics.UdfpsEnrollView>
+1 −0
Original line number Original line Diff line number Diff line
@@ -759,6 +759,7 @@ public class UdfpsController implements DozeReceiver {
                UdfpsEnrollView enrollView = (UdfpsEnrollView) mInflater.inflate(
                UdfpsEnrollView enrollView = (UdfpsEnrollView) mInflater.inflate(
                        R.layout.udfps_enroll_view, null);
                        R.layout.udfps_enroll_view, null);
                mView.addView(enrollView);
                mView.addView(enrollView);
                enrollView.updateSensorLocation(mSensorProps);
                return new UdfpsEnrollViewController(
                return new UdfpsEnrollViewController(
                        enrollView,
                        enrollView,
                        mServerRequest.mEnrollHelper,
                        mServerRequest.mEnrollHelper,
+0 −15
Original line number Original line Diff line number Diff line
@@ -43,7 +43,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
    // 1 + SCALE_MAX is the maximum that the moving target will animate to
    // 1 + SCALE_MAX is the maximum that the moving target will animate to
    private static final float SCALE_MAX = 0.25f;
    private static final float SCALE_MAX = 0.25f;


    @NonNull private final UdfpsEnrollProgressBarDrawable mProgressDrawable;
    @NonNull private final Drawable mMovingTargetFpIcon;
    @NonNull private final Drawable mMovingTargetFpIcon;
    @NonNull private final Paint mSensorOutlinePaint;
    @NonNull private final Paint mSensorOutlinePaint;
    @NonNull private final Paint mBlueFill;
    @NonNull private final Paint mBlueFill;
@@ -62,7 +61,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
    UdfpsEnrollDrawable(@NonNull Context context) {
    UdfpsEnrollDrawable(@NonNull Context context) {
        super(context);
        super(context);


        mProgressDrawable = new UdfpsEnrollProgressBarDrawable(context, this);


        mSensorOutlinePaint = new Paint(0 /* flags */);
        mSensorOutlinePaint = new Paint(0 /* flags */);
        mSensorOutlinePaint.setAntiAlias(true);
        mSensorOutlinePaint.setAntiAlias(true);
@@ -100,8 +98,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
    }
    }


    void onEnrollmentProgress(int remaining, int totalSteps) {
    void onEnrollmentProgress(int remaining, int totalSteps) {
        mProgressDrawable.setEnrollmentProgress(remaining, totalSteps);

        if (mEnrollHelper.isCenterEnrollmentComplete()) {
        if (mEnrollHelper.isCenterEnrollmentComplete()) {
            if (mAnimatorSet != null && mAnimatorSet.isRunning()) {
            if (mAnimatorSet != null && mAnimatorSet.isRunning()) {
                mAnimatorSet.end();
                mAnimatorSet.end();
@@ -139,14 +135,8 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
        }
        }
    }
    }


    void onLastStepAcquired() {
        mProgressDrawable.onLastStepAcquired();
    }

    @Override
    @Override
    public void draw(@NonNull Canvas canvas) {
    public void draw(@NonNull Canvas canvas) {
        mProgressDrawable.draw(canvas);

        if (isIlluminationShowing()) {
        if (isIlluminationShowing()) {
            return;
            return;
        }
        }
@@ -174,11 +164,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
        }
        }
    }
    }


    @Override
    public void onBoundsChange(@NonNull Rect rect) {
        mProgressDrawable.setBounds(rect);
    }

    @Override
    @Override
    public void setAlpha(int alpha) {
    public void setAlpha(int alpha) {
        super.setAlpha(alpha);
        super.setAlpha(alpha);
+3 −10
Original line number Original line Diff line number Diff line
@@ -41,7 +41,6 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
    private static final float PROGRESS_BAR_THICKNESS_DP = 12;
    private static final float PROGRESS_BAR_THICKNESS_DP = 12;


    @NonNull private final Context mContext;
    @NonNull private final Context mContext;
    @NonNull private final UdfpsEnrollDrawable mParent;
    @NonNull private final Paint mBackgroundCirclePaint;
    @NonNull private final Paint mBackgroundCirclePaint;
    @NonNull private final Paint mProgressPaint;
    @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 int mRotation; // After last step, rotate the progress bar once
    private boolean mLastStepAcquired;
    private boolean mLastStepAcquired;


    public UdfpsEnrollProgressBarDrawable(@NonNull Context context,
    public UdfpsEnrollProgressBarDrawable(@NonNull Context context) {
            @NonNull UdfpsEnrollDrawable parent) {
        mContext = context;
        mContext = context;
        mParent = parent;


        mBackgroundCirclePaint = new Paint();
        mBackgroundCirclePaint = new Paint();
        mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
        mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
@@ -101,7 +98,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
            rotationAnimator.addUpdateListener(animation -> {
            rotationAnimator.addUpdateListener(animation -> {
                Log.d(TAG, "Rotation: " + mRotation);
                Log.d(TAG, "Rotation: " + mRotation);
                mRotation = (int) animation.getAnimatedValue();
                mRotation = (int) animation.getAnimatedValue();
                mParent.invalidateSelf();
                invalidateSelf();
            });
            });
            rotationAnimator.start();
            rotationAnimator.start();
        }
        }
@@ -114,11 +111,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        mProgressAnimator.setDuration(animationDuration);
        mProgressAnimator.setDuration(animationDuration);
        mProgressAnimator.addUpdateListener(animation -> {
        mProgressAnimator.addUpdateListener(animation -> {
            mProgress = (float) animation.getAnimatedValue();
            mProgress = (float) animation.getAnimatedValue();
            // Use the parent to invalidate, since it's the one that's attached as the view's
            invalidateSelf();
            // 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();
        });
        });
        mProgressAnimator.start();
        mProgressAnimator.start();
    }
    }
+26 −2
Original line number Original line Diff line number Diff line
@@ -17,9 +17,12 @@
package com.android.systemui.biometrics;
package com.android.systemui.biometrics;


import android.content.Context;
import android.content.Context;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ImageView;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
@@ -32,20 +35,25 @@ import com.android.systemui.R;
 */
 */
public class UdfpsEnrollView extends UdfpsAnimationView {
public class UdfpsEnrollView extends UdfpsAnimationView {
    @NonNull private final UdfpsEnrollDrawable mFingerprintDrawable;
    @NonNull private final UdfpsEnrollDrawable mFingerprintDrawable;
    @NonNull private final UdfpsEnrollProgressBarDrawable mFingerprintProgressDrawable;
    @NonNull private final Handler mHandler;
    @NonNull private final Handler mHandler;


    @NonNull private ImageView mFingerprintView;
    @NonNull private ImageView mFingerprintView;
    @NonNull private ImageView mFingerprintProgressView;


    public UdfpsEnrollView(Context context, @Nullable AttributeSet attrs) {
    public UdfpsEnrollView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
        mFingerprintDrawable = new UdfpsEnrollDrawable(mContext);
        mFingerprintDrawable = new UdfpsEnrollDrawable(mContext);
        mFingerprintProgressDrawable = new UdfpsEnrollProgressBarDrawable(context);
        mHandler = new Handler(Looper.getMainLooper());
        mHandler = new Handler(Looper.getMainLooper());
    }
    }


    @Override
    @Override
    protected void onFinishInflate() {
    protected void onFinishInflate() {
        mFingerprintView = findViewById(R.id.udfps_enroll_animation_fp_view);
        mFingerprintView = findViewById(R.id.udfps_enroll_animation_fp_view);
        mFingerprintProgressView = findViewById(R.id.udfps_enroll_animation_fp_progress_view);
        mFingerprintView.setImageDrawable(mFingerprintDrawable);
        mFingerprintView.setImageDrawable(mFingerprintDrawable);
        mFingerprintProgressView.setImageDrawable(mFingerprintProgressDrawable);
    }
    }


    @Override
    @Override
@@ -53,15 +61,31 @@ public class UdfpsEnrollView extends UdfpsAnimationView {
        return mFingerprintDrawable;
        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) {
    void setEnrollHelper(UdfpsEnrollHelper enrollHelper) {
        mFingerprintDrawable.setEnrollHelper(enrollHelper);
        mFingerprintDrawable.setEnrollHelper(enrollHelper);
    }
    }


    void onEnrollmentProgress(int remaining, int totalSteps) {
    void onEnrollmentProgress(int remaining, int totalSteps) {
        mHandler.post(() -> mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps));
        mHandler.post(() -> {
            mFingerprintProgressDrawable.setEnrollmentProgress(remaining, totalSteps);
            mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps);
        });
    }
    }


    void onLastStepAcquired() {
    void onLastStepAcquired() {
        mHandler.post(mFingerprintDrawable::onLastStepAcquired);
        mHandler.post(() -> {
            mFingerprintProgressDrawable.onLastStepAcquired();
        });
    }
    }
}
}