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
This commit is contained in:
Joe Bolinger
2021-06-22 16:49:52 -07:00
parent 236f268650
commit cf2a88114f
2 changed files with 8 additions and 20 deletions

View File

@@ -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

View File

@@ -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,
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon, int userId, @NonNull String owner,
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);