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

Commit 1b28a2e7 authored by Kevin Chyn's avatar Kevin Chyn Committed by Automerger Merge Worker
Browse files

Merge "Add callback for when enrollment state changes" into sc-qpr1-dev am: ada5e056

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

Change-Id: Iea60534ff6f373cb022d2a43e138e73442b28443
parents a54db525 ada5e056
Loading
Loading
Loading
Loading
+0 −20
Original line number Original line Diff line number Diff line
@@ -849,26 +849,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        return hasEnrolledFingerprints(userId);
        return hasEnrolledFingerprints(userId);
    }
    }


    /**
     * Checks if the specified user has enrollments in any of the specified sensors.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public boolean hasEnrolledTemplatesForAnySensor(int userId,
            @NonNull List<FingerprintSensorPropertiesInternal> sensors) {
        if (mService == null) {
            Slog.w(TAG, "hasEnrolledTemplatesForAnySensor: no fingerprint service");
            return false;
        }

        try {
            return mService.hasEnrolledTemplatesForAnySensor(userId, sensors,
                    mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
    /**
     * @hide
     * @hide
     */
     */
+6 −1
Original line number Original line Diff line number Diff line
@@ -49,5 +49,10 @@ public abstract class FingerprintStateListener extends IFingerprintStateListener
     * Defines behavior in response to state update
     * Defines behavior in response to state update
     * @param newState new state of fingerprint sensor
     * @param newState new state of fingerprint sensor
     */
     */
    public abstract void onStateChanged(@FingerprintStateListener.State int newState);
    public void onStateChanged(@FingerprintStateListener.State int newState) {};

    /**
     * Invoked when enrollment state changes for the specified user
     */
    public void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {};
}
}
+0 −3
Original line number Original line Diff line number Diff line
@@ -120,9 +120,6 @@ interface IFingerprintService {
    // Determine if a user has at least one enrolled fingerprint.
    // Determine if a user has at least one enrolled fingerprint.
    boolean hasEnrolledFingerprints(int sensorId, int userId, String opPackageName);
    boolean hasEnrolledFingerprints(int sensorId, int userId, String opPackageName);


    // Determine if a user has at least one enrolled fingerprint in any of the specified sensors
    boolean hasEnrolledTemplatesForAnySensor(int userId, in List<FingerprintSensorPropertiesInternal> sensors, String opPackageName);

    // Return the LockoutTracker status for the specified user
    // Return the LockoutTracker status for the specified user
    int getLockoutModeForUser(int sensorId, int userId);
    int getLockoutModeForUser(int sensorId, int userId);


+1 −0
Original line number Original line Diff line number Diff line
@@ -24,4 +24,5 @@ import android.hardware.fingerprint.Fingerprint;
 */
 */
oneway interface IFingerprintStateListener {
oneway interface IFingerprintStateListener {
    void onStateChanged(int newState);
    void onStateChanged(int newState);
    void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments);
}
}
+25 −1
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ import android.hardware.face.FaceManager;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.FingerprintStateListener;
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
import android.hardware.fingerprint.IUdfpsHbmListener;
import android.hardware.fingerprint.IUdfpsHbmListener;
import android.os.Bundle;
import android.os.Bundle;
@@ -49,6 +50,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Log;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.WindowManager;


@@ -76,6 +78,9 @@ import kotlin.Unit;
/**
/**
 * Receives messages sent from {@link com.android.server.biometrics.BiometricService} and shows the
 * Receives messages sent from {@link com.android.server.biometrics.BiometricService} and shows the
 * appropriate biometric UI (e.g. BiometricDialogView).
 * appropriate biometric UI (e.g. BiometricDialogView).
 *
 * Also coordinates biometric-related things, such as UDFPS, with
 * {@link com.android.keyguard.KeyguardUpdateMonitor}
 */
 */
@SysUISingleton
@SysUISingleton
public class AuthController extends SystemUI implements CommandQueue.Callbacks,
public class AuthController extends SystemUI implements CommandQueue.Callbacks,
@@ -115,6 +120,8 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    @Nullable private List<FingerprintSensorPropertiesInternal> mUdfpsProps;
    @Nullable private List<FingerprintSensorPropertiesInternal> mUdfpsProps;
    @Nullable private List<FingerprintSensorPropertiesInternal> mSidefpsProps;
    @Nullable private List<FingerprintSensorPropertiesInternal> mSidefpsProps;


    @NonNull private final SparseBooleanArray mUdfpsEnrolledForUser;

    private class BiometricTaskStackListener extends TaskStackListener {
    private class BiometricTaskStackListener extends TaskStackListener {
        @Override
        @Override
        public void onTaskStackChanged() {
        public void onTaskStackChanged() {
@@ -122,6 +129,21 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        }
        }
    }
    }


    private final FingerprintStateListener mFingerprintStateListener =
            new FingerprintStateListener() {
        @Override
        public void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {
            Log.d(TAG, "onEnrollmentsChanged, userId: " + userId
                    + ", sensorId: " + sensorId
                    + ", hasEnrollments: " + hasEnrollments);
            for (FingerprintSensorPropertiesInternal prop : mUdfpsProps) {
                if (prop.sensorId == sensorId) {
                    mUdfpsEnrolledForUser.put(userId, hasEnrollments);
                }
            }
        }
    };

    @NonNull
    @NonNull
    private final IFingerprintAuthenticatorsRegisteredCallback
    private final IFingerprintAuthenticatorsRegisteredCallback
            mFingerprintAuthenticatorsRegisteredCallback =
            mFingerprintAuthenticatorsRegisteredCallback =
@@ -436,6 +458,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        mUdfpsControllerFactory = udfpsControllerFactory;
        mUdfpsControllerFactory = udfpsControllerFactory;
        mSidefpsControllerFactory = sidefpsControllerFactory;
        mSidefpsControllerFactory = sidefpsControllerFactory;
        mWindowManager = windowManager;
        mWindowManager = windowManager;
        mUdfpsEnrolledForUser = new SparseBooleanArray();
        mOrientationListener = new BiometricOrientationEventListener(context,
        mOrientationListener = new BiometricOrientationEventListener(context,
                () -> {
                () -> {
                    onOrientationChanged();
                    onOrientationChanged();
@@ -474,6 +497,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        if (mFingerprintManager != null) {
        if (mFingerprintManager != null) {
            mFingerprintManager.addAuthenticatorsRegisteredCallback(
            mFingerprintManager.addAuthenticatorsRegisteredCallback(
                    mFingerprintAuthenticatorsRegisteredCallback);
                    mFingerprintAuthenticatorsRegisteredCallback);
            mFingerprintManager.registerFingerprintStateListener(mFingerprintStateListener);
        }
        }


        mTaskStackListener = new BiometricTaskStackListener();
        mTaskStackListener = new BiometricTaskStackListener();
@@ -673,7 +697,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
            return false;
            return false;
        }
        }


        return mFingerprintManager.hasEnrolledTemplatesForAnySensor(userId, mUdfpsProps);
        return mUdfpsEnrolledForUser.get(userId);
    }
    }


    private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState) {
    private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState) {
Loading