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

Commit cf2a8811 authored by Joe Bolinger's avatar Joe Bolinger
Browse files

Always execute the user switch HAL operation.

Currently, the user id is cached at the time the operation is
scheduled and the operation is skipped if the target id matches.
This is error prone because the user may have switched due to
another operation before execution.

Fix: 188742113
Test: manual
Change-Id: I01cd423343a49a0fb2f447f7a0f4a25cc2e8200f
parent 236f2686
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -866,7 +866,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
    private void scheduleUpdateActiveUserWithoutHandler(int targetUserId) {
        final boolean hasEnrolled = !getEnrolledFaces(mSensorId, targetUserId).isEmpty();
        final FaceUpdateActiveUserClient client = new FaceUpdateActiveUserClient(mContext,
                mLazyDaemon, targetUserId, mContext.getOpPackageName(), mSensorId, mCurrentUserId,
                mLazyDaemon, targetUserId, mContext.getOpPackageName(), mSensorId,
                hasEnrolled, mAuthenticatorIds);
        mScheduler.scheduleClientMonitor(client, new BaseClientMonitor.Callback() {
            @Override
+7 −19
Original line number Diff line number Diff line
@@ -34,38 +34,23 @@ public class FaceUpdateActiveUserClient extends HalClientMonitor<IBiometricsFace
    private static final String TAG = "FaceUpdateActiveUserClient";
    private static final String FACE_DATA_DIR = "facedata";

    private final int mCurrentUserId;
    private final boolean mHasEnrolledBiometrics;
    @NonNull private final Map<Integer, Long> mAuthenticatorIds;

    FaceUpdateActiveUserClient(@NonNull Context context,
            @NonNull LazyDaemon<IBiometricsFace> lazyDaemon, int userId, @NonNull String owner,
            int sensorId, int currentUserId, boolean hasEnrolledBIometrics,
            int sensorId, boolean hasEnrolledBiometrics,
            @NonNull Map<Integer, Long> authenticatorIds) {
        super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
                0 /* cookie */, sensorId, BiometricsProtoEnums.MODALITY_UNKNOWN,
                BiometricsProtoEnums.ACTION_UNKNOWN, BiometricsProtoEnums.CLIENT_UNKNOWN);
        mCurrentUserId = currentUserId;
        mHasEnrolledBiometrics = hasEnrolledBIometrics;
        mHasEnrolledBiometrics = hasEnrolledBiometrics;
        mAuthenticatorIds = authenticatorIds;
    }

    @Override
    public void start(@NonNull Callback callback) {
        super.start(callback);

        if (mCurrentUserId == getTargetUserId()) {
            Slog.d(TAG, "Already user: " + mCurrentUserId + ", refreshing authenticatorId");
            try {
                mAuthenticatorIds.put(getTargetUserId(), mHasEnrolledBiometrics
                        ? getFreshDaemon().getAuthenticatorId().value : 0L);
            } catch (RemoteException e) {
                Slog.e(TAG, "Unable to refresh authenticatorId", e);
            }
            callback.onClientFinished(this, true /* success */);
            return;
        }

        startHalOperation();
    }

@@ -85,7 +70,10 @@ public class FaceUpdateActiveUserClient extends HalClientMonitor<IBiometricsFace
        }

        try {
            getFreshDaemon().setActiveUser(getTargetUserId(), storePath.getAbsolutePath());
            final IBiometricsFace daemon = getFreshDaemon();
            daemon.setActiveUser(getTargetUserId(), storePath.getAbsolutePath());
            mAuthenticatorIds.put(getTargetUserId(),
                    mHasEnrolledBiometrics ? daemon.getAuthenticatorId().value : 0L);
            mCallback.onClientFinished(this, true /* success */);
        } catch (RemoteException e) {
            Slog.e(TAG, "Failed to setActiveUser: " + e);