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

Commit 86a2d7f4 authored by Jeff Pu's avatar Jeff Pu
Browse files

Remove InternalCleanupClient enrolled list cache

(mEnrolledList), retrieve the enrolled list from framework
when the client starts.

Bug: 268695802
Test: atest com.android.server.biometrics
      atest CtsBiometricsTestCases
      atest CtsBiometricsHostTestCases
Change-Id: Iab3663d0dde2f9a96cdcf5aced629451e874b674
parent bdad0383
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ public abstract class InternalCleanupClient<S extends BiometricAuthenticator.Ide
    private final ArrayList<UserTemplate> mUnknownHALTemplates = new ArrayList<>();
    private final BiometricUtils<S> mBiometricUtils;
    private final Map<Integer, Long> mAuthenticatorIds;
    private final List<S> mEnrolledList;
    private final boolean mHasEnrollmentsBeforeStarting;
    private BaseClientMonitor mCurrentTask;
    private boolean mFavorHalEnrollments = false;
@@ -135,13 +134,12 @@ public abstract class InternalCleanupClient<S extends BiometricAuthenticator.Ide
    protected InternalCleanupClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
            int userId, @NonNull String owner, int sensorId,
            @NonNull BiometricLogger logger, @NonNull BiometricContext biometricContext,
            @NonNull List<S> enrolledList, @NonNull BiometricUtils<S> utils,
            @NonNull BiometricUtils<S> utils,
            @NonNull Map<Integer, Long> authenticatorIds) {
        super(context, lazyDaemon, null /* token */, null /* ClientMonitorCallbackConverter */,
                userId, owner, 0 /* cookie */, sensorId, logger, biometricContext);
        mBiometricUtils = utils;
        mAuthenticatorIds = authenticatorIds;
        mEnrolledList = enrolledList;
        mHasEnrollmentsBeforeStarting = !utils.getBiometricsForUser(context, userId).isEmpty();
    }

@@ -169,12 +167,16 @@ public abstract class InternalCleanupClient<S extends BiometricAuthenticator.Ide
    public void start(@NonNull ClientMonitorCallback callback) {
        super.start(callback);

        final List<S> enrolledList =
                mBiometricUtils.getBiometricsForUser(getContext(), getTargetUserId());

        // Start enumeration. Removal will start if necessary, when enumeration is completed.
        mCurrentTask = getEnumerateClient(getContext(), mLazyDaemon, getToken(), getTargetUserId(),
                getOwnerString(), mEnrolledList, mBiometricUtils, getSensorId(), getLogger(),
                getOwnerString(), enrolledList, mBiometricUtils, getSensorId(), getLogger(),
                getBiometricContext());

        Slog.d(TAG, "Starting enumerate: " + mCurrentTask);
        Slog.d(TAG, "Starting enumerate: " + mCurrentTask + " enrolledList size:"
                + enrolledList.size());
        mCurrentTask.start(mEnumerateCallback);
    }

+2 −2
Original line number Diff line number Diff line
@@ -43,10 +43,10 @@ class FaceInternalCleanupClient extends InternalCleanupClient<Face, AidlSession>
    FaceInternalCleanupClient(@NonNull Context context,
            @NonNull Supplier<AidlSession> lazyDaemon, int userId, @NonNull String owner,
            int sensorId, @NonNull BiometricLogger logger,
            @NonNull BiometricContext biometricContext, @NonNull List<Face> enrolledList,
            @NonNull BiometricContext biometricContext,
            @NonNull BiometricUtils<Face> utils, @NonNull Map<Integer, Long> authenticatorIds) {
        super(context, lazyDaemon, userId, owner, sensorId, logger, biometricContext,
                enrolledList, utils, authenticatorIds);
                utils, authenticatorIds);
    }

    @Override
+1 −2
Original line number Diff line number Diff line
@@ -595,14 +595,13 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
    public void scheduleInternalCleanup(int sensorId, int userId,
            @Nullable ClientMonitorCallback callback, boolean favorHalEnrollments) {
        mHandler.post(() -> {
            final List<Face> enrolledList = getEnrolledFaces(sensorId, userId);
            final FaceInternalCleanupClient client =
                    new FaceInternalCleanupClient(mContext,
                            mSensors.get(sensorId).getLazySession(), userId,
                            mContext.getOpPackageName(), sensorId,
                            createLogger(BiometricsProtoEnums.ACTION_ENUMERATE,
                                    BiometricsProtoEnums.CLIENT_UNKNOWN),
                            mBiometricContext, enrolledList,
                            mBiometricContext,
                            FaceUtils.getInstance(sensorId),
                            mSensors.get(sensorId).getAuthenticatorIds());
            if (favorHalEnrollments) {
+1 −2
Original line number Diff line number Diff line
@@ -818,12 +818,11 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
        mHandler.post(() -> {
            scheduleUpdateActiveUserWithoutHandler(userId);

            final List<Face> enrolledList = getEnrolledFaces(mSensorId, userId);
            final FaceInternalCleanupClient client = new FaceInternalCleanupClient(mContext,
                    mLazyDaemon, userId, mContext.getOpPackageName(), mSensorId,
                    createLogger(BiometricsProtoEnums.ACTION_ENUMERATE,
                            BiometricsProtoEnums.CLIENT_UNKNOWN),
                    mBiometricContext, enrolledList,
                    mBiometricContext,
                    FaceUtils.getLegacyInstance(mSensorId), mAuthenticatorIds);
            mScheduler.scheduleClientMonitor(client, new ClientMonitorCompositeCallback(callback,
                    mBiometricStateCallback));
+2 −2
Original line number Diff line number Diff line
@@ -42,10 +42,10 @@ class FaceInternalCleanupClient extends InternalCleanupClient<Face, IBiometricsF
    FaceInternalCleanupClient(@NonNull Context context,
            @NonNull Supplier<IBiometricsFace> lazyDaemon, int userId, @NonNull String owner,
            int sensorId, @NonNull BiometricLogger logger,
            @NonNull BiometricContext biometricContext, @NonNull List<Face> enrolledList,
            @NonNull BiometricContext biometricContext,
            @NonNull BiometricUtils<Face> utils, @NonNull Map<Integer, Long> authenticatorIds) {
        super(context, lazyDaemon, userId, owner, sensorId, logger, biometricContext,
                enrolledList, utils, authenticatorIds);
                utils, authenticatorIds);
    }

    @Override
Loading