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

Commit aae04715 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Add fingerprint enroll reason

1) Existing metrics logging-ness can be derived from it
2) EnrollReason is clearer and can be used by other parts of the
   system, such as SysUI
3) Do not show progressbar in SysUI if it's "find sensor"

Bug: 179447737
Test: Builds
Change-Id: I84f82b5c81a668e11c1a380e6fa4e3080db53dc9
parent b92e7e8a
Loading
Loading
Loading
Loading
+21 −2
Original line number Original line 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_BIOMETRIC_INTERNAL;
import static android.Manifest.permission.USE_FINGERPRINT;
import static android.Manifest.permission.USE_FINGERPRINT;


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


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


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


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


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


package com.android.systemui.biometrics;
package com.android.systemui.biometrics;


import android.hardware.fingerprint.IUdfpsOverlayController;

import androidx.annotation.NonNull;
import androidx.annotation.NonNull;


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


    // IUdfpsOverlayController reason
    private final int mEnrollReason;


    private int mTotalSteps = -1;
    private int mTotalSteps = -1;
    private int mCurrentProgress = 0;
    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) {
    void onEnrollmentProgress(int remaining, @NonNull UdfpsProgressBar progressBar) {
        if (mTotalSteps == -1) {
        if (mTotalSteps == -1) {
            mTotalSteps = remaining;
            mTotalSteps = remaining;
Loading