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

Commit 61f4241d authored by Kevin Chyn's avatar Kevin Chyn Committed by Automerger Merge Worker
Browse files

Merge "Add fingerprint enroll reason" into sc-dev am: 3919f6d2

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia6bfe3df25e48bd8ddc6a9b75eb48835710e8ab8
parents 0c94ae30 3919f6d2
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.Manifest.permission.USE_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
import static android.Manifest.permission.USE_FINGERPRINT;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresFeature;
@@ -55,6 +56,8 @@ import android.security.identity.IdentityCredential;
import android.util.Slog;
import android.view.Surface;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.security.Signature;
import java.util.ArrayList;
import java.util.List;
@@ -89,6 +92,22 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    private static final int MSG_UDFPS_POINTER_DOWN = 108;
    private static final int MSG_UDFPS_POINTER_UP = 109;

    /**
     * @hide
     */
    public static final int ENROLL_FIND_SENSOR = 1;
    /**
     * @hide
     */
    public static final int ENROLL_ENROLL = 2;

    /**
     * @hide
     */
    @IntDef({ENROLL_FIND_SENSOR, ENROLL_ENROLL})
    @Retention(RetentionPolicy.SOURCE)
    public @interface EnrollReason {}

    /**
     * Request authentication with any single sensor.
     * @hide
@@ -580,7 +599,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
     */
    @RequiresPermission(MANAGE_FINGERPRINT)
    public void enroll(byte [] hardwareAuthToken, CancellationSignal cancel, int userId,
            EnrollmentCallback callback, boolean shouldLogMetrics) {
            EnrollmentCallback callback, @EnrollReason int enrollReason) {
        if (userId == UserHandle.USER_CURRENT) {
            userId = getCurrentUserId();
        }
@@ -601,7 +620,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
            try {
                mEnrollmentCallback = callback;
                mService.enroll(mToken, hardwareAuthToken, userId, mServiceReceiver,
                        mContext.getOpPackageName(), shouldLogMetrics);
                        mContext.getOpPackageName(), enrollReason);
            } catch (RemoteException e) {
                Slog.w(TAG, "Remote exception in enroll: ", e);
                // Though this may not be a hardware issue, it will cause apps to give up or try
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ interface IFingerprintService {

    // Start fingerprint enrollment
    void enroll(IBinder token, in byte [] hardwareAuthToken, int userId, IFingerprintServiceReceiver receiver,
            String opPackageName, boolean shouldLogMetrics);
            String opPackageName, int enrollReason);

    // Cancel enrollment in progress
    void cancelEnrollment(IBinder token);
+5 −4
Original line number Diff line number Diff line
@@ -21,10 +21,11 @@ package android.hardware.fingerprint;
 */
oneway interface IUdfpsOverlayController {
    const int REASON_UNKNOWN = 0;
    const int REASON_ENROLL = 1;
    const int REASON_AUTH_BP = 2; // BiometricPrompt
    const int REASON_AUTH_FPM_KEYGUARD = 3; // FingerprintManager usage from Keyguard
    const int REASON_AUTH_FPM_OTHER = 4; // Other FingerprintManager usage
    const int REASON_ENROLL_FIND_SENSOR = 1;
    const int REASON_ENROLL_ENROLLING = 2;
    const int REASON_AUTH_BP = 3; // BiometricPrompt
    const int REASON_AUTH_FPM_KEYGUARD = 4; // FingerprintManager usage from Keyguard
    const int REASON_AUTH_FPM_OTHER = 5; // Other FingerprintManager usage

    // Shows the overlay.
    void showUdfpsOverlay(int sensorId, int reason);
+9 −6
Original line number Diff line number Diff line
@@ -96,8 +96,11 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
    public class UdfpsOverlayController extends IUdfpsOverlayController.Stub {
        @Override
        public void showUdfpsOverlay(int sensorId, int reason) {
            if (reason == IUdfpsOverlayController.REASON_ENROLL) {
                mEnrollHelper = new UdfpsEnrollHelper();
            if (reason == IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR
                    || reason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING) {
                mEnrollHelper = new UdfpsEnrollHelper(reason);
            } else {
                mEnrollHelper = null;
            }
            UdfpsController.this.showOverlay(reason);
        }
@@ -300,8 +303,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
                try {
                    Log.v(TAG, "showUdfpsOverlay | adding window");
                    final UdfpsAnimation animation = getUdfpsAnimationForReason(reason);
                    mView.setUdfpsAnimation(animation);
                    mView.setEnrollHelper(mEnrollHelper);
                    mView.setExtras(animation, mEnrollHelper);
                    mWindowManager.addView(mView, computeLayoutParams(animation));
                    mView.setOnTouchListener(mOnTouchListener);
                    mIsOverlayShowing = true;
@@ -318,7 +320,8 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
    private UdfpsAnimation getUdfpsAnimationForReason(int reason) {
        Log.d(TAG, "getUdfpsAnimationForReason: " + reason);
        switch (reason) {
            case IUdfpsOverlayController.REASON_ENROLL:
            case IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR:
            case IUdfpsOverlayController.REASON_ENROLL_ENROLLING:
                return new UdfpsAnimationEnroll(mContext);
            case IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD:
                return new UdfpsAnimationKeyguard(mView, mContext, mStatusBarStateController);
@@ -334,7 +337,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
        mFgExecutor.execute(() -> {
            if (mIsOverlayShowing) {
                Log.v(TAG, "hideUdfpsOverlay | removing window");
                mView.setUdfpsAnimation(null);
                mView.setExtras(null, null);
                mView.setOnTouchListener(null);
                // Reset the controller back to its starting state.
                onFingerUp();
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.biometrics;

import android.hardware.fingerprint.IUdfpsOverlayController;

import androidx.annotation.NonNull;

/**
@@ -24,10 +26,20 @@ import androidx.annotation.NonNull;
public class UdfpsEnrollHelper {
    private static final String TAG = "UdfpsEnrollHelper";

    // IUdfpsOverlayController reason
    private final int mEnrollReason;

    private int mTotalSteps = -1;
    private int mCurrentProgress = 0;

    public UdfpsEnrollHelper(int reason) {
        mEnrollReason = reason;
    }

    boolean shouldShowProgressBar() {
        return mEnrollReason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING;
    }

    void onEnrollmentProgress(int remaining, @NonNull UdfpsProgressBar progressBar) {
        if (mTotalSteps == -1) {
            mTotalSteps = remaining;
Loading