Merge "Retrieve authenticatorId when already targetUserId" into sc-dev
This commit is contained in:
@@ -390,7 +390,6 @@ public class BiometricManager {
|
|||||||
* in Keystore land as SIDs, and are used during key generation.
|
* in Keystore land as SIDs, and are used during key generation.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
|
|
||||||
public long[] getAuthenticatorIds() {
|
public long[] getAuthenticatorIds() {
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -463,26 +463,33 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
|||||||
for (UserInfo user : UserManager.get(mContext).getAliveUsers()) {
|
for (UserInfo user : UserManager.get(mContext).getAliveUsers()) {
|
||||||
final int targetUserId = user.id;
|
final int targetUserId = user.id;
|
||||||
if (!mAuthenticatorIds.containsKey(targetUserId)) {
|
if (!mAuthenticatorIds.containsKey(targetUserId)) {
|
||||||
scheduleUpdateActiveUserWithoutHandler(targetUserId);
|
scheduleUpdateActiveUserWithoutHandler(targetUserId, true /* force */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void scheduleUpdateActiveUserWithoutHandler(int targetUserId) {
|
||||||
|
scheduleUpdateActiveUserWithoutHandler(targetUserId, false /* force */);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules the {@link FingerprintUpdateActiveUserClient} without posting the work onto the
|
* Schedules the {@link FingerprintUpdateActiveUserClient} without posting the work onto the
|
||||||
* handler. Many/most APIs are user-specific. However, the HAL requires explicit "setActiveUser"
|
* handler. Many/most APIs are user-specific. However, the HAL requires explicit "setActiveUser"
|
||||||
* invocation prior to authenticate/enroll/etc. Thus, internally we usually want to schedule
|
* invocation prior to authenticate/enroll/etc. Thus, internally we usually want to schedule
|
||||||
* this operation on the same lambda/runnable as those operations so that the ordering is
|
* this operation on the same lambda/runnable as those operations so that the ordering is
|
||||||
* correct.
|
* correct.
|
||||||
|
*
|
||||||
|
* @param targetUserId Switch to this user, and update their authenticatorId
|
||||||
|
* @param force Always retrieve the authenticatorId, even if we are already the targetUserId
|
||||||
*/
|
*/
|
||||||
private void scheduleUpdateActiveUserWithoutHandler(int targetUserId) {
|
private void scheduleUpdateActiveUserWithoutHandler(int targetUserId, boolean force) {
|
||||||
final boolean hasEnrolled =
|
final boolean hasEnrolled =
|
||||||
!getEnrolledFingerprints(mSensorProperties.sensorId, targetUserId).isEmpty();
|
!getEnrolledFingerprints(mSensorProperties.sensorId, targetUserId).isEmpty();
|
||||||
final FingerprintUpdateActiveUserClient client =
|
final FingerprintUpdateActiveUserClient client =
|
||||||
new FingerprintUpdateActiveUserClient(mContext, mLazyDaemon, targetUserId,
|
new FingerprintUpdateActiveUserClient(mContext, mLazyDaemon, targetUserId,
|
||||||
mContext.getOpPackageName(), mSensorProperties.sensorId, mCurrentUserId,
|
mContext.getOpPackageName(), mSensorProperties.sensorId, mCurrentUserId,
|
||||||
hasEnrolled, mAuthenticatorIds);
|
hasEnrolled, mAuthenticatorIds, force);
|
||||||
mScheduler.scheduleClientMonitor(client, new BaseClientMonitor.Callback() {
|
mScheduler.scheduleClientMonitor(client, new BaseClientMonitor.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
|
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
|
||||||
@@ -563,7 +570,8 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
|||||||
boolean success) {
|
boolean success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
// Update authenticatorIds
|
// Update authenticatorIds
|
||||||
scheduleUpdateActiveUserWithoutHandler(clientMonitor.getTargetUserId());
|
scheduleUpdateActiveUserWithoutHandler(clientMonitor.getTargetUserId(),
|
||||||
|
true /* force */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class FingerprintUpdateActiveUserClient extends HalClientMonitor<IBiometr
|
|||||||
private static final String FP_DATA_DIR = "fpdata";
|
private static final String FP_DATA_DIR = "fpdata";
|
||||||
|
|
||||||
private final int mCurrentUserId;
|
private final int mCurrentUserId;
|
||||||
|
private final boolean mForceUpdateAuthenticatorId;
|
||||||
private final boolean mHasEnrolledBiometrics;
|
private final boolean mHasEnrolledBiometrics;
|
||||||
private final Map<Integer, Long> mAuthenticatorIds;
|
private final Map<Integer, Long> mAuthenticatorIds;
|
||||||
private File mDirectory;
|
private File mDirectory;
|
||||||
@@ -48,11 +49,12 @@ public class FingerprintUpdateActiveUserClient extends HalClientMonitor<IBiometr
|
|||||||
FingerprintUpdateActiveUserClient(@NonNull Context context,
|
FingerprintUpdateActiveUserClient(@NonNull Context context,
|
||||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, int userId,
|
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, int userId,
|
||||||
@NonNull String owner, int sensorId, int currentUserId, boolean hasEnrolledBiometrics,
|
@NonNull String owner, int sensorId, int currentUserId, boolean hasEnrolledBiometrics,
|
||||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
@NonNull Map<Integer, Long> authenticatorIds, boolean forceUpdateAuthenticatorId) {
|
||||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
|
super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
|
||||||
0 /* cookie */, sensorId, BiometricsProtoEnums.MODALITY_UNKNOWN,
|
0 /* cookie */, sensorId, BiometricsProtoEnums.MODALITY_UNKNOWN,
|
||||||
BiometricsProtoEnums.ACTION_UNKNOWN, BiometricsProtoEnums.CLIENT_UNKNOWN);
|
BiometricsProtoEnums.ACTION_UNKNOWN, BiometricsProtoEnums.CLIENT_UNKNOWN);
|
||||||
mCurrentUserId = currentUserId;
|
mCurrentUserId = currentUserId;
|
||||||
|
mForceUpdateAuthenticatorId = forceUpdateAuthenticatorId;
|
||||||
mHasEnrolledBiometrics = hasEnrolledBiometrics;
|
mHasEnrolledBiometrics = hasEnrolledBiometrics;
|
||||||
mAuthenticatorIds = authenticatorIds;
|
mAuthenticatorIds = authenticatorIds;
|
||||||
}
|
}
|
||||||
@@ -61,7 +63,7 @@ public class FingerprintUpdateActiveUserClient extends HalClientMonitor<IBiometr
|
|||||||
public void start(@NonNull Callback callback) {
|
public void start(@NonNull Callback callback) {
|
||||||
super.start(callback);
|
super.start(callback);
|
||||||
|
|
||||||
if (mCurrentUserId == getTargetUserId()) {
|
if (mCurrentUserId == getTargetUserId() && !mForceUpdateAuthenticatorId) {
|
||||||
Slog.d(TAG, "Already user: " + mCurrentUserId + ", returning");
|
Slog.d(TAG, "Already user: " + mCurrentUserId + ", returning");
|
||||||
callback.onClientFinished(this, true /* success */);
|
callback.onClientFinished(this, true /* success */);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user