10/n: Add remainder of functionality to FingerprintProvider
Also makes classes package private where applicable. 1) Caches pointer to the HAL, similar to Fingerprint21 2) Finishes remaining work on FingerprintProvider class, namely A) authenticatorId-related stuff B) FingerprintDetectClient C) InternalCleanup D) rename, getEnrolledFingerprints, binderDied, dump 3) Fixes scheduleInternalCleanup parameter ordering Remaining work in Sensor.java (plumbing callbacks, etc) will be in the next CL Bug: 170497736 Test: Builds Change-Id: I82d7ceac3282deb3e13dd1f04eb4c37e3776cdba
This commit is contained in:
@@ -43,7 +43,7 @@ import java.util.ArrayList;
|
||||
* Fingerprint-specific authentication client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.IFingerprint} AIDL interface.
|
||||
*/
|
||||
public class FingerprintAuthenticationClient extends AuthenticationClient<ISession> implements
|
||||
class FingerprintAuthenticationClient extends AuthenticationClient<ISession> implements
|
||||
Udfps, LockoutConsumer {
|
||||
private static final String TAG = "FingerprintAuthenticationClient";
|
||||
|
||||
@@ -51,7 +51,7 @@ public class FingerprintAuthenticationClient extends AuthenticationClient<ISessi
|
||||
@Nullable private final IUdfpsOverlayController mUdfpsOverlayController;
|
||||
@Nullable private ICancellationSignal mCancellationSignal;
|
||||
|
||||
public FingerprintAuthenticationClient(@NonNull Context context,
|
||||
FingerprintAuthenticationClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int targetUserId, long operationId,
|
||||
boolean restricted, @NonNull String owner, int cookie, boolean requireConfirmation,
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.common.ICancellationSignal;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.AcquisitionClient;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.fingerprint.UdfpsHelper;
|
||||
|
||||
/**
|
||||
* Performs fingerprint detection without exposing any matching information (e.g. accept/reject
|
||||
* have the same haptic, lockout counter is not increased).
|
||||
*/
|
||||
class FingerprintDetectClient extends AcquisitionClient<ISession> {
|
||||
|
||||
private static final String TAG = "FingerprintDetectClient";
|
||||
|
||||
private final boolean mIsStrongBiometric;
|
||||
@Nullable private final IUdfpsOverlayController mUdfpsOverlayController;
|
||||
|
||||
@Nullable private ICancellationSignal mCancellationSignal;
|
||||
|
||||
FingerprintDetectClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int sensorId,
|
||||
@Nullable IUdfpsOverlayController udfpsOverlayController, boolean isStrongBiometric,
|
||||
int statsClient) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, 0 /* cookie */, sensorId,
|
||||
BiometricsProtoEnums.MODALITY_FINGERPRINT, BiometricsProtoEnums.ACTION_AUTHENTICATE,
|
||||
statsClient);
|
||||
mIsStrongBiometric = isStrongBiometric;
|
||||
mUdfpsOverlayController = udfpsOverlayController;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stopHalOperation() {
|
||||
UdfpsHelper.hideUdfpsOverlay(getSensorId(), mUdfpsOverlayController);
|
||||
try {
|
||||
mCancellationSignal.cancel();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
UdfpsHelper.showUdfpsOverlay(getSensorId(), mUdfpsOverlayController);
|
||||
try {
|
||||
mCancellationSignal = getFreshDaemon().detectInteraction(mSequentialId);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting finger detect", e);
|
||||
UdfpsHelper.hideUdfpsOverlay(getSensorId(), mUdfpsOverlayController);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
||||
import com.android.server.biometrics.sensors.fingerprint.UdfpsHelper;
|
||||
|
||||
public class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
|
||||
class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
|
||||
|
||||
private static final String TAG = "FingerprintEnrollClient";
|
||||
|
||||
@@ -46,7 +46,7 @@ public class FingerprintEnrollClient extends EnrollClient<ISession> implements U
|
||||
@Nullable private ICancellationSignal mCancellationSignal;
|
||||
private final int mMaxTemplatesPerUser;
|
||||
|
||||
public FingerprintEnrollClient(@NonNull Context context,
|
||||
FingerprintEnrollClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull String owner,
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.android.server.biometrics.sensors.GenerateChallengeClient;
|
||||
/**
|
||||
* Fingerprint-specific generateChallenge client for the {@link IFingerprint} AIDL HAL interface.
|
||||
*/
|
||||
public class FingerprintGenerateChallengeClient extends GenerateChallengeClient<IFingerprint> {
|
||||
class FingerprintGenerateChallengeClient extends GenerateChallengeClient<IFingerprint> {
|
||||
private static final String TAG = "FingerprintGenerateChallengeClient";
|
||||
private static final int CHALLENGE_TIMEOUT_SEC = 600; // 10 minutes
|
||||
|
||||
@@ -50,7 +50,7 @@ public class FingerprintGenerateChallengeClient extends GenerateChallengeClient<
|
||||
}
|
||||
};
|
||||
|
||||
public FingerprintGenerateChallengeClient(@NonNull Context context,
|
||||
FingerprintGenerateChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IFingerprint> lazyDaemon,
|
||||
@NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.ClientMonitor;
|
||||
|
||||
class FingerprintGetAuthenticatorIdClient extends ClientMonitor<ISession> {
|
||||
|
||||
private static final String TAG = "FingerprintGetAuthenticatorIdClient";
|
||||
|
||||
FingerprintGetAuthenticatorIdClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, @NonNull String owner,
|
||||
int sensorId) {
|
||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
|
||||
0 /* cookie */, sensorId, BiometricsProtoEnums.MODALITY_FINGERPRINT,
|
||||
BiometricsProtoEnums.ACTION_UNKNOWN, BiometricsProtoEnums.CLIENT_UNKNOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unableToStart() {
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().getAuthenticatorId(mSequentialId);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.android.server.biometrics.sensors.BiometricUtils;
|
||||
import com.android.server.biometrics.sensors.InternalCleanupClient;
|
||||
import com.android.server.biometrics.sensors.InternalEnumerateClient;
|
||||
import com.android.server.biometrics.sensors.RemovalClient;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific internal cleanup client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.IFingerprint} AIDL interface.
|
||||
*/
|
||||
class FingerprintInternalCleanupClient extends InternalCleanupClient<Fingerprint, ISession> {
|
||||
|
||||
FingerprintInternalCleanupClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, @NonNull String owner,
|
||||
int sensorId, @NonNull List<Fingerprint> enrolledList,
|
||||
@NonNull FingerprintUtils utils, @NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, userId, owner, sensorId,
|
||||
BiometricsProtoEnums.MODALITY_FINGERPRINT, enrolledList, utils, authenticatorIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InternalEnumerateClient<ISession> getEnumerateClient(Context context,
|
||||
LazyDaemon<ISession> lazyDaemon, IBinder token, int userId, String owner,
|
||||
List<Fingerprint> enrolledList, BiometricUtils<Fingerprint> utils, int sensorId) {
|
||||
return new FingerprintInternalEnumerateClient(context, lazyDaemon, token, userId, owner,
|
||||
enrolledList, utils, sensorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemovalClient<Fingerprint, ISession> getRemovalClient(Context context,
|
||||
LazyDaemon<ISession> lazyDaemon, IBinder token, int biometricId, int userId,
|
||||
String owner, BiometricUtils<Fingerprint> utils, int sensorId,
|
||||
Map<Integer, Long> authenticatorIds) {
|
||||
return new FingerprintRemovalClient(context, lazyDaemon, token,
|
||||
null /* ClientMonitorCallbackConverter */, biometricId, userId, owner, utils,
|
||||
sensorId, authenticatorIds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.BiometricUtils;
|
||||
import com.android.server.biometrics.sensors.InternalEnumerateClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific internal client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.IFingerprint} AIDL interface.
|
||||
*/
|
||||
class FingerprintInternalEnumerateClient extends InternalEnumerateClient<ISession> {
|
||||
private static final String TAG = "FingerprintInternalEnumerateClient";
|
||||
|
||||
protected FingerprintInternalEnumerateClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token, int userId,
|
||||
@NonNull String owner, @NonNull List<Fingerprint> enrolledList,
|
||||
@NonNull BiometricUtils<Fingerprint> utils, int sensorId) {
|
||||
super(context, lazyDaemon, token, userId, owner, enrolledList, utils, sensorId,
|
||||
BiometricsProtoEnums.MODALITY_FINGERPRINT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().enumerateEnrollments(mSequentialId);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting enumerate", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import android.app.ActivityTaskManager;
|
||||
import android.app.IActivityTaskManager;
|
||||
import android.app.TaskStackListener;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.SensorProps;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
@@ -35,6 +35,7 @@ import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserManager;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Surface;
|
||||
@@ -44,6 +45,7 @@ import com.android.server.biometrics.sensors.AuthenticationClient;
|
||||
import com.android.server.biometrics.sensors.ClientMonitor;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.PerformanceTracker;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDispatcher;
|
||||
import com.android.server.biometrics.sensors.fingerprint.ServiceProvider;
|
||||
@@ -69,6 +71,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
@NonNull private final IActivityTaskManager mActivityTaskManager;
|
||||
@NonNull private final BiometricTaskStackListener mTaskStackListener;
|
||||
|
||||
@Nullable private IFingerprint mDaemon;
|
||||
@Nullable private IUdfpsOverlayController mUdfpsOverlayController;
|
||||
|
||||
private final class BiometricTaskStackListener extends TaskStackListener {
|
||||
@@ -143,15 +146,21 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
|
||||
@Nullable
|
||||
private synchronized IFingerprint getHalInstance() {
|
||||
final IFingerprint daemon = IFingerprint.Stub.asInterface(
|
||||
if (mDaemon != null) {
|
||||
return mDaemon;
|
||||
}
|
||||
|
||||
Slog.d(getTag(), "Daemon was null, reconnecting");
|
||||
|
||||
mDaemon = IFingerprint.Stub.asInterface(
|
||||
ServiceManager.waitForDeclaredService(mHalInstanceName));
|
||||
if (daemon == null) {
|
||||
if (mDaemon == null) {
|
||||
Slog.e(getTag(), "Unable to get daemon");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
daemon.asBinder().linkToDeath(this, 0 /* flags */);
|
||||
mDaemon.asBinder().linkToDeath(this, 0 /* flags */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(getTag(), "Unable to linkToDeath", e);
|
||||
}
|
||||
@@ -162,7 +171,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
scheduleInternalCleanup(sensorId, ActivityManager.getCurrentUser());
|
||||
}
|
||||
|
||||
return daemon;
|
||||
return mDaemon;
|
||||
}
|
||||
|
||||
private void scheduleForSensor(int sensorId, @NonNull ClientMonitor<?> client) {
|
||||
@@ -191,14 +200,6 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
mSensors.get(sensorId).createNewSession(daemon, sensorId, userId);
|
||||
}
|
||||
|
||||
private void scheduleLoadAuthenticatorIdsWithoutHandler(int sensorId) {
|
||||
|
||||
}
|
||||
|
||||
private void scheduleLoadAuthenticatorIds(int sensorId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsSensor(int sensorId) {
|
||||
return mSensors.contains(sensorId);
|
||||
@@ -214,6 +215,38 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
return props;
|
||||
}
|
||||
|
||||
private void scheduleLoadAuthenticatorIds(int sensorId) {
|
||||
for (UserInfo user : UserManager.get(mContext).getAliveUsers()) {
|
||||
scheduleLoadAuthenticatorIdsForUser(sensorId, user.id);
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleLoadAuthenticatorIdsForUser(int sensorId, int userId) {
|
||||
mHandler.post(() -> {
|
||||
final IFingerprint daemon = getHalInstance();
|
||||
if (daemon == null) {
|
||||
Slog.e(getTag(), "Null daemon during loadAuthenticatorIds, sensorId: " + sensorId);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!mSensors.get(sensorId).hasSessionForUser(userId)) {
|
||||
createNewSessionWithoutHandler(daemon, sensorId, userId);
|
||||
}
|
||||
|
||||
final FingerprintGetAuthenticatorIdClient client =
|
||||
new FingerprintGetAuthenticatorIdClient(mContext,
|
||||
mSensors.get(sensorId).getLazySession(), userId,
|
||||
mContext.getOpPackageName(), sensorId);
|
||||
mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(getTag(), "Remote exception when scheduling loadAuthenticatorId"
|
||||
+ ", sensorId: " + sensorId
|
||||
+ ", userId: " + userId, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleResetLockout(int sensorId, int userId, @Nullable byte[] hardwareAuthToken) {
|
||||
mHandler.post(() -> {
|
||||
@@ -292,7 +325,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
public void onClientFinished(@NonNull ClientMonitor<?> clientMonitor,
|
||||
boolean success) {
|
||||
if (success) {
|
||||
scheduleLoadAuthenticatorIdsWithoutHandler(sensorId);
|
||||
scheduleLoadAuthenticatorIdsForUser(sensorId, userId);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -311,7 +344,31 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
public void scheduleFingerDetect(int sensorId, @NonNull IBinder token, int userId,
|
||||
@NonNull ClientMonitorCallbackConverter callback, @NonNull String opPackageName,
|
||||
@Nullable Surface surface, int statsClient) {
|
||||
mHandler.post(() -> {
|
||||
final IFingerprint daemon = getHalInstance();
|
||||
if (daemon == null) {
|
||||
Slog.e(getTag(), "Null daemon during finger detect, sensorId: " + sensorId);
|
||||
// If this happens, we need to send HW_UNAVAILABLE after the scheduler gets to
|
||||
// this operation. We should not send the callback yet, since the scheduler may
|
||||
// be processing something else.
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!mSensors.get(sensorId).hasSessionForUser(userId)) {
|
||||
createNewSessionWithoutHandler(daemon, sensorId, userId);
|
||||
}
|
||||
|
||||
final boolean isStrongBiometric = Utils.isStrongBiometric(sensorId);
|
||||
final FingerprintDetectClient client = new FingerprintDetectClient(mContext,
|
||||
mSensors.get(sensorId).getLazySession(), token, callback, userId,
|
||||
opPackageName, sensorId, mUdfpsOverlayController, isStrongBiometric,
|
||||
statsClient);
|
||||
mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(getTag(), "Remote exception when scheduling finger detect", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -390,24 +447,48 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleInternalCleanup(int userId, int sensorId) {
|
||||
public void scheduleInternalCleanup(int sensorId, int userId) {
|
||||
mHandler.post(() -> {
|
||||
final IFingerprint daemon = getHalInstance();
|
||||
if (daemon == null) {
|
||||
Slog.e(getTag(), "Null daemon during internal cleanup, sensorId: " + sensorId);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!mSensors.get(sensorId).hasSessionForUser(userId)) {
|
||||
createNewSessionWithoutHandler(daemon, sensorId, userId);
|
||||
}
|
||||
|
||||
final List<Fingerprint> enrolledList = getEnrolledFingerprints(sensorId, userId);
|
||||
final FingerprintInternalCleanupClient client =
|
||||
new FingerprintInternalCleanupClient(mContext,
|
||||
mSensors.get(sensorId).getLazySession(), userId,
|
||||
mContext.getOpPackageName(), sensorId, enrolledList,
|
||||
FingerprintUtils.getInstance(sensorId),
|
||||
mSensors.get(sensorId).getAuthenticatorIds());
|
||||
mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(getTag(), "Remote exception when scheduling internal cleanup", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHardwareDetected(int sensorId) {
|
||||
return false;
|
||||
return getHalInstance() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(int sensorId, int fingerId, int userId, @NonNull String name) {
|
||||
|
||||
FingerprintUtils.getInstance(sensorId)
|
||||
.renameBiometricForUser(mContext, userId, fingerId, name);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public List<Fingerprint> getEnrolledFingerprints(int sensorId, int userId) {
|
||||
return new ArrayList<>();
|
||||
return FingerprintUtils.getInstance(sensorId).getBiometricsForUser(mContext, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -417,7 +498,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
|
||||
@Override
|
||||
public long getAuthenticatorId(int sensorId, int userId) {
|
||||
return 0;
|
||||
return mSensors.get(sensorId).getAuthenticatorIds().getOrDefault(userId, 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -459,6 +540,14 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
|
||||
@Override
|
||||
public void binderDied() {
|
||||
Slog.e(getTag(), "HAL died");
|
||||
mHandler.post(() -> {
|
||||
mDaemon = null;
|
||||
|
||||
for (int i = 0; i < mSensors.size(); i++) {
|
||||
final int sensorId = mSensors.keyAt(i);
|
||||
PerformanceTracker.getInstanceForSensorId(sensorId).incrementHALDeathCount();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
@@ -35,12 +36,12 @@ import java.util.Map;
|
||||
* Fingerprint-specific removal client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.IFingerprint} interface.
|
||||
*/
|
||||
public class FingerprintRemovalClient extends RemovalClient<Fingerprint, ISession> {
|
||||
class FingerprintRemovalClient extends RemovalClient<Fingerprint, ISession> {
|
||||
private static final String TAG = "FingerprintRemovalClient";
|
||||
|
||||
public FingerprintRemovalClient(@NonNull Context context,
|
||||
FingerprintRemovalClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int biometricId, int userId,
|
||||
@Nullable ClientMonitorCallbackConverter listener, int biometricId, int userId,
|
||||
@NonNull String owner, @NonNull BiometricUtils<Fingerprint> utils, int sensorId,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, token, listener, biometricId, userId, owner, utils, sensorId,
|
||||
|
||||
@@ -35,7 +35,7 @@ import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
* Updates the framework's lockout cache and notifies clients such as Keyguard when lockout is
|
||||
* cleared.
|
||||
*/
|
||||
public class FingerprintResetLockoutClient extends ClientMonitor<ISession> {
|
||||
class FingerprintResetLockoutClient extends ClientMonitor<ISession> {
|
||||
|
||||
private static final String TAG = "FingerprintResetLockoutClient";
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FingerprintResetLockoutClient extends ClientMonitor<ISession> {
|
||||
private final LockoutCache mLockoutCache;
|
||||
private final LockoutResetDispatcher mLockoutResetDispatcher;
|
||||
|
||||
public FingerprintResetLockoutClient(@NonNull Context context,
|
||||
FingerprintResetLockoutClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, String owner, int sensorId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull LockoutCache lockoutTracker,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.android.server.biometrics.sensors.RevokeChallengeClient;
|
||||
/**
|
||||
* Fingerprint-specific revokeChallenge client for the {@link IFingerprint} AIDL HAL interface.
|
||||
*/
|
||||
public class FingerprintRevokeChallengeClient extends RevokeChallengeClient<IFingerprint> {
|
||||
class FingerprintRevokeChallengeClient extends RevokeChallengeClient<IFingerprint> {
|
||||
|
||||
private static final String TAG = "FingerpirntRevokeChallengeClient";
|
||||
|
||||
@@ -44,10 +44,8 @@ public class FingerprintRevokeChallengeClient extends RevokeChallengeClient<IFin
|
||||
}
|
||||
};
|
||||
|
||||
public FingerprintRevokeChallengeClient(
|
||||
@NonNull Context context,
|
||||
@NonNull LazyDaemon<IFingerprint> lazyDaemon,
|
||||
@NonNull IBinder token,
|
||||
FingerprintRevokeChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull String owner, int sensorId, long challenge) {
|
||||
super(context, lazyDaemon, token, owner, sensorId);
|
||||
mChallenge = challenge;
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
/**
|
||||
* For a single sensor, caches lockout states for all users.
|
||||
*/
|
||||
public class LockoutCache implements LockoutTracker {
|
||||
class LockoutCache implements LockoutTracker {
|
||||
|
||||
// Map of userId to LockoutMode
|
||||
private final SparseIntArray mUserLockoutStates;
|
||||
|
||||
@@ -100,6 +100,7 @@ class Sensor {
|
||||
return mSensorProperties;
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
boolean hasSessionForUser(int userId) {
|
||||
return mCurrentSession != null && mCurrentSession.mUserId == userId;
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleInternalCleanup(int userId, int sensorId) {
|
||||
public void scheduleInternalCleanup(int sensorId, int userId) {
|
||||
scheduleInternalCleanup(userId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user