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

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

Add callback for when enrollment state changes

Bug: 195663312

(New tests):
Test: manual, FingerprintManager no longer shows up in strict
      mode logs when changing keyguard states
Test: atest FingerprintStateCallbackTest

(Existing cases below):
Test: atest com.android.server.biometrics
Test: atest CtsBiometricsTestCases
Test: atest com.android.systemui.biometrics
Test: atest KeyguardUpdateMonitorTest

Change-Id: I57304f9ed938cbe4ec63683b826ead086cc33a5b
parent 85f26920
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -849,26 +849,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        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
     */
+6 −1
Original line number Diff line number Diff line
@@ -49,5 +49,10 @@ public abstract class FingerprintStateListener extends IFingerprintStateListener
     * Defines behavior in response to state update
     * @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 Diff line number Diff line
@@ -120,9 +120,6 @@ interface IFingerprintService {
    // Determine if a user has at least one enrolled fingerprint.
    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
    int getLockoutModeForUser(int sensorId, int userId);

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

@@ -76,6 +78,9 @@ import kotlin.Unit;
/**
 * Receives messages sent from {@link com.android.server.biometrics.BiometricService} and shows the
 * appropriate biometric UI (e.g. BiometricDialogView).
 *
 * Also coordinates biometric-related things, such as UDFPS, with
 * {@link com.android.keyguard.KeyguardUpdateMonitor}
 */
@SysUISingleton
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> mSidefpsProps;

    @NonNull private final SparseBooleanArray mUdfpsEnrolledForUser;

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

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

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

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