Refactor FingerprintStateListener to BiometricStateListener am: 861744dde9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17697407 Change-Id: Ia4400b196ceeb7f3862dc4d39c1bd158ee193986 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.fingerprint;
|
||||
package android.hardware.biometrics;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Interface for handling state changes in fingerprint-related events.
|
||||
* Interface for handling state changes in biometric sensors.
|
||||
* @hide
|
||||
*/
|
||||
public abstract class FingerprintStateListener extends IFingerprintStateListener.Stub {
|
||||
public abstract class BiometricStateListener extends IBiometricStateListener.Stub {
|
||||
// Operation has not started yet.
|
||||
public static final int STATE_IDLE = 0;
|
||||
|
||||
@@ -43,16 +43,19 @@ public abstract class FingerprintStateListener extends IFingerprintStateListener
|
||||
|
||||
@IntDef({STATE_IDLE, STATE_ENROLLING, STATE_KEYGUARD_AUTH, STATE_BP_AUTH, STATE_AUTH_OTHER})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface State {}
|
||||
public @interface State {
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines behavior in response to state update
|
||||
* @param newState new state of fingerprint sensor
|
||||
* @param newState new state of the biometric sensor
|
||||
*/
|
||||
public void onStateChanged(@FingerprintStateListener.State int newState) {}
|
||||
public void onStateChanged(@BiometricStateListener.State int newState) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when enrollment state changes for the specified user
|
||||
*/
|
||||
public void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {}
|
||||
public void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2022 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.
|
||||
@@ -13,16 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package android.hardware.fingerprint;
|
||||
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
package android.hardware.biometrics;
|
||||
|
||||
/**
|
||||
* Communication channel for FingerprintManager to register the FingerprintStateListener
|
||||
* in FingerprintService.
|
||||
* Communication channel between <Biometric>Manager and <Biometric>Service for passing the
|
||||
* listener.
|
||||
* @hide
|
||||
*/
|
||||
oneway interface IFingerprintStateListener {
|
||||
oneway interface IBiometricStateListener {
|
||||
void onStateChanged(int newState);
|
||||
void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments);
|
||||
}
|
||||
@@ -45,6 +45,7 @@ import android.hardware.biometrics.BiometricAuthenticator;
|
||||
import android.hardware.biometrics.BiometricConstants;
|
||||
import android.hardware.biometrics.BiometricFingerprintConstants;
|
||||
import android.hardware.biometrics.BiometricPrompt;
|
||||
import android.hardware.biometrics.BiometricStateListener;
|
||||
import android.hardware.biometrics.BiometricTestSession;
|
||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||
import android.hardware.biometrics.SensorProperties;
|
||||
@@ -918,13 +919,13 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
|
||||
|
||||
/**
|
||||
* Forwards FingerprintStateListener to FingerprintService
|
||||
* @param listener new FingerprintStateListener being added
|
||||
* Forwards BiometricStateListener to FingerprintService
|
||||
* @param listener new BiometricStateListener being added
|
||||
* @hide
|
||||
*/
|
||||
public void registerFingerprintStateListener(@NonNull FingerprintStateListener listener) {
|
||||
public void registerBiometricStateListener(@NonNull BiometricStateListener listener) {
|
||||
try {
|
||||
mService.registerFingerprintStateListener(listener);
|
||||
mService.registerBiometricStateListener(listener);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ package android.hardware.fingerprint;
|
||||
|
||||
import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||
import android.hardware.biometrics.IBiometricStateListener;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.fingerprint.IFingerprintClientActiveCallback;
|
||||
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
|
||||
import android.hardware.fingerprint.IFingerprintServiceReceiver;
|
||||
import android.hardware.fingerprint.IFingerprintStateListener;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
import android.hardware.fingerprint.ISidefpsController;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
@@ -169,6 +169,6 @@ interface IFingerprintService {
|
||||
// Sets the controller for managing the SideFPS overlay.
|
||||
void setSidefpsController(in ISidefpsController controller);
|
||||
|
||||
// Registers FingerprintStateListener in list stored by FingerprintService.
|
||||
void registerFingerprintStateListener(IFingerprintStateListener listener);
|
||||
// Registers BiometricStateListener.
|
||||
void registerBiometricStateListener(IBiometricStateListener listener);
|
||||
}
|
||||
|
||||
@@ -2194,7 +2194,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
}
|
||||
|
||||
// don't start running fingerprint until they're registered
|
||||
if (!mAuthController.areAllAuthenticatorsRegistered()) {
|
||||
if (!mAuthController.areAllFingerprintAuthenticatorsRegistered()) {
|
||||
return;
|
||||
}
|
||||
final boolean shouldListenForFingerprint = shouldListenForFingerprint(isUdfpsSupported());
|
||||
@@ -3619,8 +3619,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
final int strongAuthFlags = mStrongAuthTracker.getStrongAuthForUser(userId);
|
||||
BiometricAuthenticated fingerprint = mUserFingerprintAuthenticated.get(userId);
|
||||
pw.println(" Fingerprint state (user=" + userId + ")");
|
||||
pw.println(" areAllAuthenticatorsRegistered="
|
||||
+ mAuthController.areAllAuthenticatorsRegistered());
|
||||
pw.println(" areAllFpAuthenticatorsRegistered="
|
||||
+ mAuthController.areAllFingerprintAuthenticatorsRegistered());
|
||||
pw.println(" allowed="
|
||||
+ (fingerprint != null
|
||||
&& isUnlockingWithBiometricAllowed(fingerprint.mIsStrongBiometric)));
|
||||
|
||||
@@ -37,6 +37,7 @@ import android.hardware.biometrics.BiometricConstants;
|
||||
import android.hardware.biometrics.BiometricManager.Authenticators;
|
||||
import android.hardware.biometrics.BiometricManager.BiometricMultiSensorMode;
|
||||
import android.hardware.biometrics.BiometricPrompt;
|
||||
import android.hardware.biometrics.BiometricStateListener;
|
||||
import android.hardware.biometrics.IBiometricContextListener;
|
||||
import android.hardware.biometrics.IBiometricSysuiReceiver;
|
||||
import android.hardware.biometrics.PromptInfo;
|
||||
@@ -45,7 +46,6 @@ import android.hardware.face.FaceManager;
|
||||
import android.hardware.face.FaceSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintStateListener;
|
||||
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
|
||||
import android.hardware.fingerprint.IUdfpsHbmListener;
|
||||
import android.os.Bundle;
|
||||
@@ -138,7 +138,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
|
||||
@NonNull private final SparseBooleanArray mUdfpsEnrolledForUser;
|
||||
@NonNull private final SensorPrivacyManager mSensorPrivacyManager;
|
||||
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
private boolean mAllAuthenticatorsRegistered;
|
||||
private boolean mAllFingerprintAuthenticatorsRegistered;
|
||||
@NonNull private final UserManager mUserManager;
|
||||
@NonNull private final LockPatternUtils mLockPatternUtils;
|
||||
private final @Background DelayableExecutor mBackgroundExecutor;
|
||||
@@ -157,12 +157,12 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
|
||||
@Override
|
||||
public void onAllAuthenticatorsRegistered(
|
||||
List<FingerprintSensorPropertiesInternal> sensors) {
|
||||
mHandler.post(() -> handleAllAuthenticatorsRegistered(sensors));
|
||||
mHandler.post(() -> handleAllFingerprintAuthenticatorsRegistered(sensors));
|
||||
}
|
||||
};
|
||||
|
||||
private final FingerprintStateListener mFingerprintStateListener =
|
||||
new FingerprintStateListener() {
|
||||
private final BiometricStateListener mBiometricStateListener =
|
||||
new BiometricStateListener() {
|
||||
@Override
|
||||
public void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {
|
||||
mHandler.post(
|
||||
@@ -234,20 +234,20 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether all authentictors have been registered.
|
||||
* Whether all fingerprint authentictors have been registered.
|
||||
*/
|
||||
public boolean areAllAuthenticatorsRegistered() {
|
||||
return mAllAuthenticatorsRegistered;
|
||||
public boolean areAllFingerprintAuthenticatorsRegistered() {
|
||||
return mAllFingerprintAuthenticatorsRegistered;
|
||||
}
|
||||
|
||||
private void handleAllAuthenticatorsRegistered(
|
||||
private void handleAllFingerprintAuthenticatorsRegistered(
|
||||
List<FingerprintSensorPropertiesInternal> sensors) {
|
||||
mExecution.assertIsMainThread();
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "handleAllAuthenticatorsRegistered | sensors: " + Arrays.toString(
|
||||
sensors.toArray()));
|
||||
}
|
||||
mAllAuthenticatorsRegistered = true;
|
||||
mAllFingerprintAuthenticatorsRegistered = true;
|
||||
mFpProps = sensors;
|
||||
List<FingerprintSensorPropertiesInternal> udfpsProps = new ArrayList<>();
|
||||
List<FingerprintSensorPropertiesInternal> sidefpsProps = new ArrayList<>();
|
||||
@@ -281,7 +281,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
|
||||
for (Callback cb : mCallbacks) {
|
||||
cb.onAllAuthenticatorsRegistered();
|
||||
}
|
||||
mFingerprintManager.registerFingerprintStateListener(mFingerprintStateListener);
|
||||
mFingerprintManager.registerBiometricStateListener(mBiometricStateListener);
|
||||
}
|
||||
|
||||
private void handleEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {
|
||||
|
||||
@@ -269,7 +269,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
mKeyguardUpdateMonitor.registerCallback(mTestCallback);
|
||||
|
||||
mTestableLooper.processAllMessages();
|
||||
when(mAuthController.areAllAuthenticatorsRegistered()).thenReturn(true);
|
||||
when(mAuthController.areAllFingerprintAuthenticatorsRegistered()).thenReturn(true);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -499,7 +499,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void test_doesNotTryToAuthenticateFingerprint_whenAuthenticatorsNotRegistered() {
|
||||
when(mAuthController.areAllAuthenticatorsRegistered()).thenReturn(false);
|
||||
when(mAuthController.areAllFingerprintAuthenticatorsRegistered()).thenReturn(false);
|
||||
|
||||
mKeyguardUpdateMonitor.dispatchStartedGoingToSleep(0 /* why */);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
@@ -50,6 +50,7 @@ import android.hardware.biometrics.BiometricAuthenticator;
|
||||
import android.hardware.biometrics.BiometricConstants;
|
||||
import android.hardware.biometrics.BiometricManager;
|
||||
import android.hardware.biometrics.BiometricPrompt;
|
||||
import android.hardware.biometrics.BiometricStateListener;
|
||||
import android.hardware.biometrics.ComponentInfoInternal;
|
||||
import android.hardware.biometrics.IBiometricContextListener;
|
||||
import android.hardware.biometrics.IBiometricSysuiReceiver;
|
||||
@@ -60,7 +61,6 @@ import android.hardware.face.FaceManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorProperties;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintStateListener;
|
||||
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -151,7 +151,7 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
@Captor
|
||||
ArgumentCaptor<IFingerprintAuthenticatorsRegisteredCallback> mAuthenticatorsRegisteredCaptor;
|
||||
@Captor
|
||||
ArgumentCaptor<FingerprintStateListener> mFingerprintStateCaptor;
|
||||
ArgumentCaptor<BiometricStateListener> mBiometricStateCaptor;
|
||||
@Captor
|
||||
ArgumentCaptor<StatusBarStateController.StateListener> mStatusBarStateListenerCaptor;
|
||||
|
||||
@@ -226,7 +226,7 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
// Callback tests
|
||||
|
||||
@Test
|
||||
public void testRegistersFingerprintStateListener_afterAllAuthenticatorsAreRegistered()
|
||||
public void testRegistersBiometricStateListener_afterAllAuthenticatorsAreRegistered()
|
||||
throws RemoteException {
|
||||
// This test is sensitive to prior FingerprintManager interactions.
|
||||
reset(mFingerprintManager);
|
||||
@@ -242,12 +242,12 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
mAuthenticatorsRegisteredCaptor.capture());
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
verify(mFingerprintManager, never()).registerFingerprintStateListener(any());
|
||||
verify(mFingerprintManager, never()).registerBiometricStateListener(any());
|
||||
|
||||
mAuthenticatorsRegisteredCaptor.getValue().onAllAuthenticatorsRegistered(new ArrayList<>());
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
verify(mFingerprintManager).registerFingerprintStateListener(any());
|
||||
verify(mFingerprintManager).registerBiometricStateListener(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -269,11 +269,11 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
mAuthenticatorsRegisteredCaptor.getValue().onAllAuthenticatorsRegistered(new ArrayList<>());
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
verify(mFingerprintManager).registerFingerprintStateListener(
|
||||
mFingerprintStateCaptor.capture());
|
||||
verify(mFingerprintManager).registerBiometricStateListener(
|
||||
mBiometricStateCaptor.capture());
|
||||
|
||||
// Enrollments changed for an unknown sensor.
|
||||
mFingerprintStateCaptor.getValue().onEnrollmentsChanged(0 /* userId */,
|
||||
mBiometricStateCaptor.getValue().onEnrollmentsChanged(0 /* userId */,
|
||||
0xbeef /* sensorId */, true /* hasEnrollments */);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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;
|
||||
|
||||
import static android.hardware.biometrics.BiometricStateListener.STATE_AUTH_OTHER;
|
||||
import static android.hardware.biometrics.BiometricStateListener.STATE_BP_AUTH;
|
||||
import static android.hardware.biometrics.BiometricStateListener.STATE_ENROLLING;
|
||||
import static android.hardware.biometrics.BiometricStateListener.STATE_IDLE;
|
||||
import static android.hardware.biometrics.BiometricStateListener.STATE_KEYGUARD_AUTH;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.hardware.biometrics.BiometricStateListener;
|
||||
import android.hardware.biometrics.IBiometricStateListener;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.Utils;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* A callback for receiving notifications about biometric sensor state changes.
|
||||
*/
|
||||
public class BiometricStateCallback implements ClientMonitorCallback {
|
||||
|
||||
private static final String TAG = "BiometricStateCallback";
|
||||
|
||||
@NonNull
|
||||
private final CopyOnWriteArrayList<IBiometricStateListener>
|
||||
mBiometricStateListeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private @BiometricStateListener.State int mBiometricState;
|
||||
|
||||
public BiometricStateCallback() {
|
||||
mBiometricState = STATE_IDLE;
|
||||
}
|
||||
|
||||
public int getBiometricState() {
|
||||
return mBiometricState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientStarted(@NonNull BaseClientMonitor client) {
|
||||
final int previousBiometricState = mBiometricState;
|
||||
|
||||
if (client instanceof AuthenticationClient) {
|
||||
final AuthenticationClient<?> authClient = (AuthenticationClient<?>) client;
|
||||
if (authClient.isKeyguard()) {
|
||||
mBiometricState = STATE_KEYGUARD_AUTH;
|
||||
} else if (authClient.isBiometricPrompt()) {
|
||||
mBiometricState = STATE_BP_AUTH;
|
||||
} else {
|
||||
mBiometricState = STATE_AUTH_OTHER;
|
||||
}
|
||||
} else if (client instanceof EnrollClient) {
|
||||
mBiometricState = STATE_ENROLLING;
|
||||
} else {
|
||||
Slog.w(TAG, "Other authentication client: " + Utils.getClientName(client));
|
||||
mBiometricState = STATE_IDLE;
|
||||
}
|
||||
|
||||
Slog.d(TAG, "State updated from " + previousBiometricState + " to " + mBiometricState
|
||||
+ ", client " + client);
|
||||
notifyBiometricStateListeners(mBiometricState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientFinished(@NonNull BaseClientMonitor client, boolean success) {
|
||||
mBiometricState = STATE_IDLE;
|
||||
Slog.d(TAG, "Client finished, state updated to " + mBiometricState + ", client "
|
||||
+ client);
|
||||
|
||||
if (client instanceof EnrollmentModifier) {
|
||||
EnrollmentModifier enrollmentModifier = (EnrollmentModifier) client;
|
||||
final boolean enrollmentStateChanged = enrollmentModifier.hasEnrollmentStateChanged();
|
||||
Slog.d(TAG, "Enrollment state changed: " + enrollmentStateChanged);
|
||||
if (enrollmentStateChanged) {
|
||||
notifyAllEnrollmentStateChanged(client.getTargetUserId(),
|
||||
client.getSensorId(),
|
||||
enrollmentModifier.hasEnrollments());
|
||||
}
|
||||
}
|
||||
|
||||
notifyBiometricStateListeners(mBiometricState);
|
||||
}
|
||||
|
||||
private void notifyBiometricStateListeners(@BiometricStateListener.State int newState) {
|
||||
for (IBiometricStateListener listener : mBiometricStateListeners) {
|
||||
try {
|
||||
listener.onStateChanged(newState);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception in biometric state change", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be invoked when:
|
||||
* 1) Enrolled --> None-enrolled
|
||||
* 2) None-enrolled --> enrolled
|
||||
* 3) HAL becomes ready
|
||||
* 4) Listener is registered
|
||||
*/
|
||||
public void notifyAllEnrollmentStateChanged(int userId, int sensorId,
|
||||
boolean hasEnrollments) {
|
||||
for (IBiometricStateListener listener : mBiometricStateListeners) {
|
||||
notifyEnrollmentStateChanged(listener, userId, sensorId, hasEnrollments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the listener of enrollment state changes.
|
||||
*/
|
||||
public void notifyEnrollmentStateChanged(@NonNull IBiometricStateListener listener,
|
||||
int userId, int sensorId, boolean hasEnrollments) {
|
||||
try {
|
||||
listener.onEnrollmentsChanged(userId, sensorId, hasEnrollments);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables clients to register a BiometricStateListener. For example, this is used to forward
|
||||
* fingerprint sensor state changes to SideFpsEventHandler.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void registerBiometricStateListener(@NonNull IBiometricStateListener listener) {
|
||||
mBiometricStateListeners.add(listener);
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||
import android.hardware.biometrics.IBiometricService;
|
||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||
import android.hardware.biometrics.IBiometricStateListener;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
@@ -55,7 +56,6 @@ import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback
|
||||
import android.hardware.fingerprint.IFingerprintClientActiveCallback;
|
||||
import android.hardware.fingerprint.IFingerprintService;
|
||||
import android.hardware.fingerprint.IFingerprintServiceReceiver;
|
||||
import android.hardware.fingerprint.IFingerprintStateListener;
|
||||
import android.hardware.fingerprint.ISidefpsController;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
import android.os.Binder;
|
||||
@@ -84,6 +84,7 @@ import com.android.server.ServiceThread;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.log.BiometricContext;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
@@ -114,7 +115,7 @@ public class FingerprintService extends SystemService {
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final FingerprintServiceWrapper mServiceWrapper;
|
||||
@NonNull private final List<ServiceProvider> mServiceProviders;
|
||||
@NonNull private final FingerprintStateCallback mFingerprintStateCallback;
|
||||
@NonNull private final BiometricStateCallback mBiometricStateCallback;
|
||||
@NonNull private final Handler mHandler;
|
||||
|
||||
@GuardedBy("mLock")
|
||||
@@ -125,20 +126,20 @@ public class FingerprintService extends SystemService {
|
||||
@NonNull private final List<FingerprintSensorPropertiesInternal> mSensorProps;
|
||||
|
||||
/**
|
||||
* Registers FingerprintStateListener in list stored by FingerprintService
|
||||
* @param listener new FingerprintStateListener being added
|
||||
* Registers BiometricStateListener in list stored by FingerprintService
|
||||
* @param listener new BiometricStateListener being added
|
||||
*/
|
||||
public void registerFingerprintStateListener(@NonNull IFingerprintStateListener listener) {
|
||||
mFingerprintStateCallback.registerFingerprintStateListener(listener);
|
||||
public void registerBiometricStateListener(@NonNull IBiometricStateListener listener) {
|
||||
mBiometricStateCallback.registerBiometricStateListener(listener);
|
||||
broadcastCurrentEnrollmentState(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param listener if non-null, notifies only this listener. if null, notifies all listeners
|
||||
* in {@link FingerprintStateCallback}. This is slightly ugly, but reduces
|
||||
* in {@link BiometricStateCallback}. This is slightly ugly, but reduces
|
||||
* redundant code.
|
||||
*/
|
||||
private void broadcastCurrentEnrollmentState(@Nullable IFingerprintStateListener listener) {
|
||||
private void broadcastCurrentEnrollmentState(@Nullable IBiometricStateListener listener) {
|
||||
final UserManager um = UserManager.get(getContext());
|
||||
synchronized (mLock) {
|
||||
// Update the new listener with current state of all sensors
|
||||
@@ -151,10 +152,10 @@ public class FingerprintService extends SystemService {
|
||||
// Defer this work and allow the loop to release the lock sooner
|
||||
mHandler.post(() -> {
|
||||
if (listener != null) {
|
||||
mFingerprintStateCallback.notifyFingerprintEnrollmentStateChanged(
|
||||
mBiometricStateCallback.notifyEnrollmentStateChanged(
|
||||
listener, userInfo.id, prop.sensorId, enrolled);
|
||||
} else {
|
||||
mFingerprintStateCallback.notifyAllFingerprintEnrollmentStateChanged(
|
||||
mBiometricStateCallback.notifyAllEnrollmentStateChanged(
|
||||
userInfo.id, prop.sensorId, enrolled);
|
||||
}
|
||||
});
|
||||
@@ -651,7 +652,7 @@ public class FingerprintService extends SystemService {
|
||||
pw.println("Dumping for sensorId: " + props.sensorId
|
||||
+ ", provider: " + provider.getClass().getSimpleName());
|
||||
pw.println("Fps state: "
|
||||
+ mFingerprintStateCallback.getFingerprintState());
|
||||
+ mBiometricStateCallback.getBiometricState());
|
||||
provider.dumpInternal(props.sensorId, pw);
|
||||
pw.println();
|
||||
}
|
||||
@@ -847,12 +848,12 @@ public class FingerprintService extends SystemService {
|
||||
Fingerprint21UdfpsMock.CONFIG_ENABLE_TEST_UDFPS, 0 /* default */,
|
||||
UserHandle.USER_CURRENT) != 0) {
|
||||
fingerprint21 = Fingerprint21UdfpsMock.newInstance(getContext(),
|
||||
mFingerprintStateCallback, hidlSensor,
|
||||
mBiometricStateCallback, hidlSensor,
|
||||
mLockoutResetDispatcher, mGestureAvailabilityDispatcher,
|
||||
BiometricContext.getInstance(getContext()));
|
||||
} else {
|
||||
fingerprint21 = Fingerprint21.newInstance(getContext(),
|
||||
mFingerprintStateCallback, hidlSensor, mHandler,
|
||||
mBiometricStateCallback, hidlSensor, mHandler,
|
||||
mLockoutResetDispatcher, mGestureAvailabilityDispatcher);
|
||||
}
|
||||
mServiceProviders.add(fingerprint21);
|
||||
@@ -875,7 +876,7 @@ public class FingerprintService extends SystemService {
|
||||
try {
|
||||
final SensorProps[] props = fp.getSensorProps();
|
||||
final FingerprintProvider provider =
|
||||
new FingerprintProvider(getContext(), mFingerprintStateCallback, props,
|
||||
new FingerprintProvider(getContext(), mBiometricStateCallback, props,
|
||||
instance, mLockoutResetDispatcher,
|
||||
mGestureAvailabilityDispatcher,
|
||||
BiometricContext.getInstance(getContext()));
|
||||
@@ -1015,8 +1016,8 @@ public class FingerprintService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerFingerprintStateListener(@NonNull IFingerprintStateListener listener) {
|
||||
FingerprintService.this.registerFingerprintStateListener(listener);
|
||||
public void registerBiometricStateListener(@NonNull IBiometricStateListener listener) {
|
||||
FingerprintService.this.registerBiometricStateListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1028,7 +1029,7 @@ public class FingerprintService extends SystemService {
|
||||
mLockoutResetDispatcher = new LockoutResetDispatcher(context);
|
||||
mLockPatternUtils = new LockPatternUtils(context);
|
||||
mServiceProviders = new ArrayList<>();
|
||||
mFingerprintStateCallback = new FingerprintStateCallback();
|
||||
mBiometricStateCallback = new BiometricStateCallback();
|
||||
mAuthenticatorsRegisteredCallbacks = new RemoteCallbackList<>();
|
||||
mSensorProps = new ArrayList<>();
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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;
|
||||
|
||||
import static android.hardware.fingerprint.FingerprintStateListener.STATE_AUTH_OTHER;
|
||||
import static android.hardware.fingerprint.FingerprintStateListener.STATE_BP_AUTH;
|
||||
import static android.hardware.fingerprint.FingerprintStateListener.STATE_ENROLLING;
|
||||
import static android.hardware.fingerprint.FingerprintStateListener.STATE_IDLE;
|
||||
import static android.hardware.fingerprint.FingerprintStateListener.STATE_KEYGUARD_AUTH;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.hardware.fingerprint.FingerprintStateListener;
|
||||
import android.hardware.fingerprint.IFingerprintStateListener;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.sensors.AuthenticationClient;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.EnrollClient;
|
||||
import com.android.server.biometrics.sensors.EnrollmentModifier;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* A callback for receiving notifications about changes in fingerprint state.
|
||||
*/
|
||||
public class FingerprintStateCallback implements ClientMonitorCallback {
|
||||
|
||||
@NonNull private final CopyOnWriteArrayList<IFingerprintStateListener>
|
||||
mFingerprintStateListeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private @FingerprintStateListener.State int mFingerprintState;
|
||||
|
||||
public FingerprintStateCallback() {
|
||||
mFingerprintState = STATE_IDLE;
|
||||
}
|
||||
|
||||
public int getFingerprintState() {
|
||||
return mFingerprintState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientStarted(@NonNull BaseClientMonitor client) {
|
||||
final int previousFingerprintState = mFingerprintState;
|
||||
|
||||
if (client instanceof AuthenticationClient) {
|
||||
final AuthenticationClient<?> authClient = (AuthenticationClient<?>) client;
|
||||
if (authClient.isKeyguard()) {
|
||||
mFingerprintState = STATE_KEYGUARD_AUTH;
|
||||
} else if (authClient.isBiometricPrompt()) {
|
||||
mFingerprintState = STATE_BP_AUTH;
|
||||
} else {
|
||||
mFingerprintState = STATE_AUTH_OTHER;
|
||||
}
|
||||
} else if (client instanceof EnrollClient) {
|
||||
mFingerprintState = STATE_ENROLLING;
|
||||
} else {
|
||||
Slog.w(FingerprintService.TAG,
|
||||
"Other authentication client: " + Utils.getClientName(client));
|
||||
mFingerprintState = STATE_IDLE;
|
||||
}
|
||||
|
||||
Slog.d(FingerprintService.TAG, "Fps state updated from " + previousFingerprintState
|
||||
+ " to " + mFingerprintState + ", client " + client);
|
||||
notifyFingerprintStateListeners(mFingerprintState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientFinished(@NonNull BaseClientMonitor client, boolean success) {
|
||||
mFingerprintState = STATE_IDLE;
|
||||
Slog.d(FingerprintService.TAG,
|
||||
"Client finished, fps state updated to " + mFingerprintState + ", client "
|
||||
+ client);
|
||||
|
||||
if (client instanceof EnrollmentModifier) {
|
||||
EnrollmentModifier enrollmentModifier = (EnrollmentModifier) client;
|
||||
final boolean enrollmentStateChanged = enrollmentModifier.hasEnrollmentStateChanged();
|
||||
Slog.d(FingerprintService.TAG, "Enrollment state changed: " + enrollmentStateChanged);
|
||||
if (enrollmentStateChanged) {
|
||||
notifyAllFingerprintEnrollmentStateChanged(client.getTargetUserId(),
|
||||
client.getSensorId(),
|
||||
enrollmentModifier.hasEnrollments());
|
||||
}
|
||||
}
|
||||
|
||||
notifyFingerprintStateListeners(mFingerprintState);
|
||||
}
|
||||
|
||||
private void notifyFingerprintStateListeners(@FingerprintStateListener.State int newState) {
|
||||
for (IFingerprintStateListener listener : mFingerprintStateListeners) {
|
||||
try {
|
||||
listener.onStateChanged(newState);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(FingerprintService.TAG, "Remote exception in fingerprint state change", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be invoked when:
|
||||
* 1) Enrolled --> None-enrolled
|
||||
* 2) None-enrolled --> enrolled
|
||||
* 3) HAL becomes ready
|
||||
* 4) Listener is registered
|
||||
*/
|
||||
void notifyAllFingerprintEnrollmentStateChanged(int userId, int sensorId,
|
||||
boolean hasEnrollments) {
|
||||
for (IFingerprintStateListener listener : mFingerprintStateListeners) {
|
||||
notifyFingerprintEnrollmentStateChanged(listener, userId, sensorId, hasEnrollments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the listener of enrollment state changes.
|
||||
*/
|
||||
void notifyFingerprintEnrollmentStateChanged(@NonNull IFingerprintStateListener listener,
|
||||
int userId, int sensorId, boolean hasEnrollments) {
|
||||
try {
|
||||
listener.onEnrollmentsChanged(userId, sensorId, hasEnrollments);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(FingerprintService.TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables clients to register a FingerprintStateListener. Used by FingerprintService to forward
|
||||
* updates in fingerprint sensor state to the SideFpNsEventHandler
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void registerFingerprintStateListener(@NonNull IFingerprintStateListener listener) {
|
||||
mFingerprintStateListeners.add(listener);
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.HardwareAuthTokenUtils;
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintStateCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -52,7 +52,7 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
@NonNull private final Context mContext;
|
||||
private final int mSensorId;
|
||||
@NonNull private final ITestSessionCallback mCallback;
|
||||
@NonNull private final FingerprintStateCallback mFingerprintStateCallback;
|
||||
@NonNull private final BiometricStateCallback mBiometricStateCallback;
|
||||
@NonNull private final FingerprintProvider mProvider;
|
||||
@NonNull private final Sensor mSensor;
|
||||
@NonNull private final Set<Integer> mEnrollmentIds;
|
||||
@@ -118,13 +118,13 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId,
|
||||
@NonNull ITestSessionCallback callback,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull FingerprintProvider provider,
|
||||
@NonNull Sensor sensor) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
mCallback = callback;
|
||||
mFingerprintStateCallback = fingerprintStateCallback;
|
||||
mBiometricStateCallback = biometricStateCallback;
|
||||
mProvider = provider;
|
||||
mSensor = sensor;
|
||||
mEnrollmentIds = new HashSet<>();
|
||||
|
||||
@@ -58,13 +58,13 @@ import com.android.server.biometrics.log.BiometricContext;
|
||||
import com.android.server.biometrics.log.BiometricLogger;
|
||||
import com.android.server.biometrics.sensors.AuthenticationClient;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCompositeCallback;
|
||||
import com.android.server.biometrics.sensors.InvalidationRequesterClient;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.PerformanceTracker;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintStateCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDispatcher;
|
||||
import com.android.server.biometrics.sensors.fingerprint.ServiceProvider;
|
||||
@@ -91,7 +91,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
private boolean mTestHalEnabled;
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
@NonNull private final FingerprintStateCallback mFingerprintStateCallback;
|
||||
@NonNull private final BiometricStateCallback mBiometricStateCallback;
|
||||
@NonNull private final String mHalInstanceName;
|
||||
@NonNull @VisibleForTesting
|
||||
final SparseArray<Sensor> mSensors; // Map of sensors that this HAL supports
|
||||
@@ -141,13 +141,13 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
}
|
||||
|
||||
public FingerprintProvider(@NonNull Context context,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull SensorProps[] props, @NonNull String halInstanceName,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher,
|
||||
@NonNull GestureAvailabilityDispatcher gestureAvailabilityDispatcher,
|
||||
@NonNull BiometricContext biometricContext) {
|
||||
mContext = context;
|
||||
mFingerprintStateCallback = fingerprintStateCallback;
|
||||
mBiometricStateCallback = biometricStateCallback;
|
||||
mHalInstanceName = halInstanceName;
|
||||
mSensors = new SparseArray<>();
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
@@ -389,13 +389,13 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
|
||||
@Override
|
||||
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
|
||||
mFingerprintStateCallback.onClientStarted(clientMonitor);
|
||||
mBiometricStateCallback.onClientStarted(clientMonitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
|
||||
boolean success) {
|
||||
mFingerprintStateCallback.onClientFinished(clientMonitor, success);
|
||||
mBiometricStateCallback.onClientFinished(clientMonitor, success);
|
||||
if (success) {
|
||||
scheduleLoadAuthenticatorIdsForUser(sensorId, userId);
|
||||
scheduleInvalidationRequest(sensorId, userId);
|
||||
@@ -425,7 +425,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
createLogger(BiometricsProtoEnums.ACTION_AUTHENTICATE, statsClient),
|
||||
mBiometricContext,
|
||||
mUdfpsOverlayController, isStrongBiometric);
|
||||
scheduleForSensor(sensorId, client, mFingerprintStateCallback);
|
||||
scheduleForSensor(sensorId, client, mBiometricStateCallback);
|
||||
});
|
||||
|
||||
return id;
|
||||
@@ -447,7 +447,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
mTaskStackListener, mSensors.get(sensorId).getLockoutCache(),
|
||||
mUdfpsOverlayController, mSidefpsController, allowBackgroundAuthentication,
|
||||
mSensors.get(sensorId).getSensorProperties());
|
||||
scheduleForSensor(sensorId, client, mFingerprintStateCallback);
|
||||
scheduleForSensor(sensorId, client, mBiometricStateCallback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
BiometricsProtoEnums.CLIENT_UNKNOWN),
|
||||
mBiometricContext,
|
||||
mSensors.get(sensorId).getAuthenticatorIds());
|
||||
scheduleForSensor(sensorId, client, mFingerprintStateCallback);
|
||||
scheduleForSensor(sensorId, client, mBiometricStateCallback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
enrolledList, FingerprintUtils.getInstance(sensorId),
|
||||
mSensors.get(sensorId).getAuthenticatorIds());
|
||||
scheduleForSensor(sensorId, client, new ClientMonitorCompositeCallback(callback,
|
||||
mFingerprintStateCallback));
|
||||
mBiometricStateCallback));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
@Override
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) {
|
||||
return mSensors.get(sensorId).createTestSession(callback, mFingerprintStateCallback);
|
||||
return mSensors.get(sensorId).createTestSession(callback, mBiometricStateCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,6 +55,7 @@ import com.android.server.biometrics.sensors.AcquisitionClient;
|
||||
import com.android.server.biometrics.sensors.AuthenticationConsumer;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.EnumerateConsumer;
|
||||
import com.android.server.biometrics.sensors.ErrorConsumer;
|
||||
import com.android.server.biometrics.sensors.LockoutCache;
|
||||
@@ -64,7 +65,6 @@ import com.android.server.biometrics.sensors.RemovalConsumer;
|
||||
import com.android.server.biometrics.sensors.StartUserClient;
|
||||
import com.android.server.biometrics.sensors.StopUserClient;
|
||||
import com.android.server.biometrics.sensors.UserAwareBiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintStateCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDispatcher;
|
||||
|
||||
@@ -527,9 +527,9 @@ public class Sensor {
|
||||
}
|
||||
|
||||
@NonNull ITestSession createTestSession(@NonNull ITestSessionCallback callback,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback) {
|
||||
@NonNull BiometricStateCallback biometricStateCallback) {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorProperties.sensorId, callback,
|
||||
fingerprintStateCallback, mProvider, this);
|
||||
biometricStateCallback, mProvider, this);
|
||||
}
|
||||
|
||||
@NonNull BiometricScheduler getScheduler() {
|
||||
|
||||
@@ -31,8 +31,8 @@ import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintStateCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -53,7 +53,7 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
@NonNull private final Context mContext;
|
||||
private final int mSensorId;
|
||||
@NonNull private final ITestSessionCallback mCallback;
|
||||
@NonNull private final FingerprintStateCallback mFingerprintStateCallback;
|
||||
@NonNull private final BiometricStateCallback mBiometricStateCallback;
|
||||
@NonNull private final Fingerprint21 mFingerprint21;
|
||||
@NonNull private final Fingerprint21.HalResultController mHalResultController;
|
||||
@NonNull private final Set<Integer> mEnrollmentIds;
|
||||
@@ -119,14 +119,14 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId,
|
||||
@NonNull ITestSessionCallback callback,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull Fingerprint21 fingerprint21,
|
||||
@NonNull Fingerprint21.HalResultController halResultController) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
mCallback = callback;
|
||||
mFingerprint21 = fingerprint21;
|
||||
mFingerprintStateCallback = fingerprintStateCallback;
|
||||
mBiometricStateCallback = biometricStateCallback;
|
||||
mHalResultController = halResultController;
|
||||
mEnrollmentIds = new HashSet<>();
|
||||
mRandom = new Random();
|
||||
|
||||
@@ -64,6 +64,7 @@ import com.android.server.biometrics.sensors.AuthenticationClient;
|
||||
import com.android.server.biometrics.sensors.AuthenticationConsumer;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCompositeCallback;
|
||||
@@ -73,7 +74,6 @@ import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
import com.android.server.biometrics.sensors.PerformanceTracker;
|
||||
import com.android.server.biometrics.sensors.RemovalConsumer;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintStateCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDispatcher;
|
||||
import com.android.server.biometrics.sensors.fingerprint.ServiceProvider;
|
||||
@@ -105,7 +105,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
private boolean mTestHalEnabled;
|
||||
|
||||
final Context mContext;
|
||||
@NonNull private final FingerprintStateCallback mFingerprintStateCallback;
|
||||
@NonNull private final BiometricStateCallback mBiometricStateCallback;
|
||||
private final ActivityTaskManager mActivityTaskManager;
|
||||
@NonNull private final FingerprintSensorPropertiesInternal mSensorProperties;
|
||||
private final BiometricScheduler mScheduler;
|
||||
@@ -323,7 +323,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
|
||||
@VisibleForTesting
|
||||
Fingerprint21(@NonNull Context context,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull FingerprintSensorPropertiesInternal sensorProps,
|
||||
@NonNull BiometricScheduler scheduler,
|
||||
@NonNull Handler handler,
|
||||
@@ -331,7 +331,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
@NonNull HalResultController controller,
|
||||
@NonNull BiometricContext biometricContext) {
|
||||
mContext = context;
|
||||
mFingerprintStateCallback = fingerprintStateCallback;
|
||||
mBiometricStateCallback = biometricStateCallback;
|
||||
mBiometricContext = biometricContext;
|
||||
|
||||
mSensorProperties = sensorProps;
|
||||
@@ -362,7 +362,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
}
|
||||
|
||||
public static Fingerprint21 newInstance(@NonNull Context context,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull FingerprintSensorPropertiesInternal sensorProps,
|
||||
@NonNull Handler handler,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher,
|
||||
@@ -373,7 +373,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
gestureAvailabilityDispatcher);
|
||||
final HalResultController controller = new HalResultController(sensorProps.sensorId,
|
||||
context, handler, scheduler);
|
||||
return new Fingerprint21(context, fingerprintStateCallback, sensorProps, scheduler, handler,
|
||||
return new Fingerprint21(context, biometricStateCallback, sensorProps, scheduler, handler,
|
||||
lockoutResetDispatcher, controller, BiometricContext.getInstance(context));
|
||||
}
|
||||
|
||||
@@ -604,13 +604,13 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
mScheduler.scheduleClientMonitor(client, new ClientMonitorCallback() {
|
||||
@Override
|
||||
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
|
||||
mFingerprintStateCallback.onClientStarted(clientMonitor);
|
||||
mBiometricStateCallback.onClientStarted(clientMonitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
|
||||
boolean success) {
|
||||
mFingerprintStateCallback.onClientFinished(clientMonitor, success);
|
||||
mBiometricStateCallback.onClientFinished(clientMonitor, success);
|
||||
if (success) {
|
||||
// Update authenticatorIds
|
||||
scheduleUpdateActiveUserWithoutHandler(clientMonitor.getTargetUserId(),
|
||||
@@ -642,7 +642,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
createLogger(BiometricsProtoEnums.ACTION_AUTHENTICATE, statsClient),
|
||||
mBiometricContext, mUdfpsOverlayController,
|
||||
isStrongBiometric);
|
||||
mScheduler.scheduleClientMonitor(client, mFingerprintStateCallback);
|
||||
mScheduler.scheduleClientMonitor(client, mBiometricStateCallback);
|
||||
});
|
||||
|
||||
return id;
|
||||
@@ -666,7 +666,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
mTaskStackListener, mLockoutTracker,
|
||||
mUdfpsOverlayController, mSidefpsController,
|
||||
allowBackgroundAuthentication, mSensorProperties);
|
||||
mScheduler.scheduleClientMonitor(client, mFingerprintStateCallback);
|
||||
mScheduler.scheduleClientMonitor(client, mBiometricStateCallback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -708,7 +708,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
createLogger(BiometricsProtoEnums.ACTION_REMOVE,
|
||||
BiometricsProtoEnums.CLIENT_UNKNOWN),
|
||||
mBiometricContext, mAuthenticatorIds);
|
||||
mScheduler.scheduleClientMonitor(client, mFingerprintStateCallback);
|
||||
mScheduler.scheduleClientMonitor(client, mBiometricStateCallback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -728,7 +728,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
createLogger(BiometricsProtoEnums.ACTION_REMOVE,
|
||||
BiometricsProtoEnums.CLIENT_UNKNOWN),
|
||||
mBiometricContext, mAuthenticatorIds);
|
||||
mScheduler.scheduleClientMonitor(client, mFingerprintStateCallback);
|
||||
mScheduler.scheduleClientMonitor(client, mBiometricStateCallback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -754,7 +754,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
public void scheduleInternalCleanup(int sensorId, int userId,
|
||||
@Nullable ClientMonitorCallback callback) {
|
||||
scheduleInternalCleanup(userId, new ClientMonitorCompositeCallback(callback,
|
||||
mFingerprintStateCallback));
|
||||
mBiometricStateCallback));
|
||||
}
|
||||
|
||||
private BiometricLogger createLogger(int statsAction, int statsClient) {
|
||||
@@ -967,6 +967,6 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorProperties.sensorId, callback,
|
||||
mFingerprintStateCallback, this, mHalResultController);
|
||||
mBiometricStateCallback, this, mHalResultController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ import com.android.server.biometrics.log.BiometricContext;
|
||||
import com.android.server.biometrics.sensors.AuthenticationConsumer;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintStateCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDispatcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -245,7 +245,7 @@ public class Fingerprint21UdfpsMock extends Fingerprint21 implements TrustManage
|
||||
}
|
||||
|
||||
public static Fingerprint21UdfpsMock newInstance(@NonNull Context context,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull FingerprintSensorPropertiesInternal sensorProps,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher,
|
||||
@NonNull GestureAvailabilityDispatcher gestureAvailabilityDispatcher,
|
||||
@@ -257,7 +257,7 @@ public class Fingerprint21UdfpsMock extends Fingerprint21 implements TrustManage
|
||||
new TestableBiometricScheduler(TAG, handler, gestureAvailabilityDispatcher);
|
||||
final MockHalResultController controller =
|
||||
new MockHalResultController(sensorProps.sensorId, context, handler, scheduler);
|
||||
return new Fingerprint21UdfpsMock(context, fingerprintStateCallback, sensorProps, scheduler,
|
||||
return new Fingerprint21UdfpsMock(context, biometricStateCallback, sensorProps, scheduler,
|
||||
handler, lockoutResetDispatcher, controller, biometricContext);
|
||||
}
|
||||
|
||||
@@ -382,14 +382,14 @@ public class Fingerprint21UdfpsMock extends Fingerprint21 implements TrustManage
|
||||
}
|
||||
|
||||
private Fingerprint21UdfpsMock(@NonNull Context context,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull FingerprintSensorPropertiesInternal sensorProps,
|
||||
@NonNull TestableBiometricScheduler scheduler,
|
||||
@NonNull Handler handler,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher,
|
||||
@NonNull MockHalResultController controller,
|
||||
@NonNull BiometricContext biometricContext) {
|
||||
super(context, fingerprintStateCallback, sensorProps, scheduler, handler,
|
||||
super(context, biometricStateCallback, sensorProps, scheduler, handler,
|
||||
lockoutResetDispatcher, controller, biometricContext);
|
||||
mScheduler = scheduler;
|
||||
mScheduler.init(this);
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.android.server.policy;
|
||||
|
||||
import static android.hardware.fingerprint.FingerprintStateListener.STATE_BP_AUTH;
|
||||
import static android.hardware.fingerprint.FingerprintStateListener.STATE_ENROLLING;
|
||||
import static android.hardware.fingerprint.FingerprintStateListener.STATE_IDLE;
|
||||
import static android.hardware.biometrics.BiometricStateListener.STATE_BP_AUTH;
|
||||
import static android.hardware.biometrics.BiometricStateListener.STATE_ENROLLING;
|
||||
import static android.hardware.biometrics.BiometricStateListener.STATE_IDLE;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
@@ -30,9 +30,9 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.biometrics.BiometricStateListener;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintStateListener;
|
||||
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
@@ -67,7 +67,7 @@ public class SideFpsEventHandler {
|
||||
}
|
||||
};
|
||||
|
||||
private @FingerprintStateListener.State int mFingerprintState;
|
||||
private @BiometricStateListener.State int mBiometricState;
|
||||
|
||||
SideFpsEventHandler(Context context, Handler handler, PowerManager powerManager) {
|
||||
this(context, handler, powerManager, () -> new AlertDialog.Builder(context));
|
||||
@@ -80,7 +80,7 @@ public class SideFpsEventHandler {
|
||||
mHandler = handler;
|
||||
mPowerManager = powerManager;
|
||||
mDialogSupplier = dialogSupplier;
|
||||
mFingerprintState = STATE_IDLE;
|
||||
mBiometricState = STATE_IDLE;
|
||||
mSideFpsEventHandlerReady = new AtomicBoolean(false);
|
||||
|
||||
// ensure dialog is dismissed if screen goes off for unrelated reasons
|
||||
@@ -108,7 +108,7 @@ public class SideFpsEventHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mFingerprintState) {
|
||||
switch (mBiometricState) {
|
||||
case STATE_ENROLLING:
|
||||
case STATE_BP_AUTH:
|
||||
mHandler.post(() -> {
|
||||
@@ -116,7 +116,7 @@ public class SideFpsEventHandler {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
mDialog = showConfirmDialog(mDialogSupplier.get(),
|
||||
mPowerManager, eventTime, mFingerprintState, mDialogDismissListener);
|
||||
mPowerManager, eventTime, mBiometricState, mDialogDismissListener);
|
||||
});
|
||||
return true;
|
||||
default:
|
||||
@@ -127,9 +127,9 @@ public class SideFpsEventHandler {
|
||||
@NonNull
|
||||
private static Dialog showConfirmDialog(@NonNull AlertDialog.Builder dialogBuilder,
|
||||
@NonNull PowerManager powerManager, long eventTime,
|
||||
@FingerprintStateListener.State int fingerprintState,
|
||||
@BiometricStateListener.State int biometricState,
|
||||
@NonNull DialogInterface.OnDismissListener dismissListener) {
|
||||
final boolean enrolling = fingerprintState == STATE_ENROLLING;
|
||||
final boolean enrolling = biometricState == STATE_ENROLLING;
|
||||
final int title = enrolling ? R.string.fp_power_button_enrollment_title
|
||||
: R.string.fp_power_button_bp_title;
|
||||
final int message = enrolling ? R.string.fp_power_button_enrollment_message
|
||||
@@ -165,8 +165,8 @@ public class SideFpsEventHandler {
|
||||
/**
|
||||
* Awaits notification from PhoneWindowManager that fingerprint service is ready
|
||||
* to send updates about power button fps sensor state. Then configures a
|
||||
* FingerprintStateListener to receive and record updates to fps state, and
|
||||
* registers the FingerprintStateListener in FingerprintManager.
|
||||
* BiometricStateListener to receive and record updates to fps state, and
|
||||
* registers the BiometricStateListener in FingerprintManager.
|
||||
*/
|
||||
public void onFingerprintSensorReady() {
|
||||
final PackageManager pm = mContext.getPackageManager();
|
||||
@@ -182,13 +182,14 @@ public class SideFpsEventHandler {
|
||||
public void onAllAuthenticatorsRegistered(
|
||||
List<FingerprintSensorPropertiesInternal> sensors) {
|
||||
if (fingerprintManager.isPowerbuttonFps()) {
|
||||
fingerprintManager.registerFingerprintStateListener(
|
||||
new FingerprintStateListener() {
|
||||
@Nullable private Runnable mStateRunnable = null;
|
||||
fingerprintManager.registerBiometricStateListener(
|
||||
new BiometricStateListener() {
|
||||
@Nullable
|
||||
private Runnable mStateRunnable = null;
|
||||
|
||||
@Override
|
||||
public void onStateChanged(
|
||||
@FingerprintStateListener.State int newState) {
|
||||
@BiometricStateListener.State int newState) {
|
||||
if (mStateRunnable != null) {
|
||||
mHandler.removeCallbacks(mStateRunnable);
|
||||
mStateRunnable = null;
|
||||
@@ -198,11 +199,11 @@ public class SideFpsEventHandler {
|
||||
// arrive in any order (success auth & power). Add a
|
||||
// damper when moving to idle in case auth is first
|
||||
if (newState == STATE_IDLE) {
|
||||
mStateRunnable = () -> mFingerprintState = newState;
|
||||
mStateRunnable = () -> mBiometricState = newState;
|
||||
mHandler.postDelayed(mStateRunnable,
|
||||
DEBOUNCE_DELAY_MILLIS);
|
||||
} else {
|
||||
mFingerprintState = newState;
|
||||
mBiometricState = newState;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,12 +24,13 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.hardware.fingerprint.FingerprintStateListener;
|
||||
import android.hardware.biometrics.BiometricStateListener;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.server.biometrics.sensors.AuthenticationClient;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.EnrollClient;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -39,19 +40,19 @@ import org.mockito.MockitoAnnotations;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
public class FingerprintStateCallbackTest {
|
||||
public class BiometricStateCallbackTest {
|
||||
|
||||
private FingerprintStateCallback mCallback;
|
||||
private BiometricStateCallback mCallback;
|
||||
|
||||
@Mock
|
||||
FingerprintStateListener mFingerprintStateListener;
|
||||
BiometricStateListener mBiometricStateListener;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mCallback = new FingerprintStateCallback();
|
||||
mCallback.registerFingerprintStateListener(mFingerprintStateListener);
|
||||
mCallback = new BiometricStateCallback();
|
||||
mCallback.registerBiometricStateListener(mBiometricStateListener);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,10 +87,10 @@ public class FingerprintStateCallbackTest {
|
||||
|
||||
mCallback.onClientFinished(client, true /* success */);
|
||||
if (expectCallback) {
|
||||
verify(mFingerprintStateListener).onEnrollmentsChanged(eq(userId), eq(sensorId),
|
||||
verify(mBiometricStateListener).onEnrollmentsChanged(eq(userId), eq(sensorId),
|
||||
eq(expectedCallbackValue));
|
||||
} else {
|
||||
verify(mFingerprintStateListener, never()).onEnrollmentsChanged(anyInt(), anyInt(),
|
||||
verify(mBiometricStateListener, never()).onEnrollmentsChanged(anyInt(), anyInt(),
|
||||
anyBoolean());
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@ public class FingerprintStateCallbackTest {
|
||||
public void testAuthentication_enrollmentCallbackNeverNotified() {
|
||||
AuthenticationClient<?> client = mock(AuthenticationClient.class);
|
||||
mCallback.onClientFinished(client, true /* success */);
|
||||
verify(mFingerprintStateListener, never()).onEnrollmentsChanged(anyInt(), anyInt(),
|
||||
verify(mBiometricStateListener, never()).onEnrollmentsChanged(anyInt(), anyInt(),
|
||||
anyBoolean());
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,9 @@ import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.server.biometrics.log.BiometricContext;
|
||||
import com.android.server.biometrics.sensors.BiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintStateCallback;
|
||||
import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDispatcher;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -71,7 +71,7 @@ public class FingerprintProviderTest {
|
||||
@Mock
|
||||
private GestureAvailabilityDispatcher mGestureAvailabilityDispatcher;
|
||||
@Mock
|
||||
private FingerprintStateCallback mFingerprintStateCallback;
|
||||
private BiometricStateCallback mBiometricStateCallback;
|
||||
@Mock
|
||||
private BiometricContext mBiometricContext;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class FingerprintProviderTest {
|
||||
mLockoutResetDispatcher = new LockoutResetDispatcher(mContext);
|
||||
|
||||
mFingerprintProvider = new TestableFingerprintProvider(mDaemon, mContext,
|
||||
mFingerprintStateCallback, mSensorProps, TAG, mLockoutResetDispatcher,
|
||||
mBiometricStateCallback, mSensorProps, TAG, mLockoutResetDispatcher,
|
||||
mGestureAvailabilityDispatcher, mBiometricContext);
|
||||
}
|
||||
|
||||
@@ -156,13 +156,13 @@ public class FingerprintProviderTest {
|
||||
|
||||
TestableFingerprintProvider(@NonNull IFingerprint daemon,
|
||||
@NonNull Context context,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull SensorProps[] props,
|
||||
@NonNull String halInstanceName,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher,
|
||||
@NonNull GestureAvailabilityDispatcher gestureAvailabilityDispatcher,
|
||||
@NonNull BiometricContext biometricContext) {
|
||||
super(context, fingerprintStateCallback, props, halInstanceName, lockoutResetDispatcher,
|
||||
super(context, biometricStateCallback, props, halInstanceName, lockoutResetDispatcher,
|
||||
gestureAvailabilityDispatcher, biometricContext);
|
||||
mDaemon = daemon;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ import androidx.test.filters.SmallTest;
|
||||
import com.android.internal.R;
|
||||
import com.android.server.biometrics.log.BiometricContext;
|
||||
import com.android.server.biometrics.sensors.BiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintStateCallback;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -70,7 +70,7 @@ public class Fingerprint21Test {
|
||||
@Mock
|
||||
private BiometricScheduler mScheduler;
|
||||
@Mock
|
||||
private FingerprintStateCallback mFingerprintStateCallback;
|
||||
private BiometricStateCallback mBiometricStateCallback;
|
||||
@Mock
|
||||
private BiometricContext mBiometricContext;
|
||||
|
||||
@@ -102,7 +102,7 @@ public class Fingerprint21Test {
|
||||
componentInfo, FingerprintSensorProperties.TYPE_UNKNOWN,
|
||||
resetLockoutRequiresHardwareAuthToken);
|
||||
|
||||
mFingerprint21 = new TestableFingerprint21(mContext, mFingerprintStateCallback, sensorProps,
|
||||
mFingerprint21 = new TestableFingerprint21(mContext, mBiometricStateCallback, sensorProps,
|
||||
mScheduler, new Handler(Looper.getMainLooper()), mLockoutResetDispatcher,
|
||||
mHalResultController, mBiometricContext);
|
||||
}
|
||||
@@ -125,13 +125,13 @@ public class Fingerprint21Test {
|
||||
private static class TestableFingerprint21 extends Fingerprint21 {
|
||||
|
||||
TestableFingerprint21(@NonNull Context context,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull BiometricStateCallback biometricStateCallback,
|
||||
@NonNull FingerprintSensorPropertiesInternal sensorProps,
|
||||
@NonNull BiometricScheduler scheduler, @NonNull Handler handler,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher,
|
||||
@NonNull HalResultController controller,
|
||||
@NonNull BiometricContext biometricContext) {
|
||||
super(context, fingerprintStateCallback, sensorProps, scheduler, handler,
|
||||
super(context, biometricStateCallback, sensorProps, scheduler, handler,
|
||||
lockoutResetDispatcher, controller, biometricContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.biometrics.BiometricStateListener;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintStateListener;
|
||||
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
@@ -61,11 +61,11 @@ import java.util.List;
|
||||
public class SideFpsEventHandlerTest {
|
||||
|
||||
private static final List<Integer> sAllStates = List.of(
|
||||
FingerprintStateListener.STATE_IDLE,
|
||||
FingerprintStateListener.STATE_ENROLLING,
|
||||
FingerprintStateListener.STATE_KEYGUARD_AUTH,
|
||||
FingerprintStateListener.STATE_BP_AUTH,
|
||||
FingerprintStateListener.STATE_AUTH_OTHER);
|
||||
BiometricStateListener.STATE_IDLE,
|
||||
BiometricStateListener.STATE_ENROLLING,
|
||||
BiometricStateListener.STATE_KEYGUARD_AUTH,
|
||||
BiometricStateListener.STATE_BP_AUTH,
|
||||
BiometricStateListener.STATE_AUTH_OTHER);
|
||||
|
||||
@Rule
|
||||
public TestableContext mContext =
|
||||
@@ -83,7 +83,7 @@ public class SideFpsEventHandlerTest {
|
||||
|
||||
private TestLooper mLooper = new TestLooper();
|
||||
private SideFpsEventHandler mEventHandler;
|
||||
private FingerprintStateListener mFingerprintStateListener;
|
||||
private BiometricStateListener mBiometricStateListener;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -116,7 +116,7 @@ public class SideFpsEventHandlerTest {
|
||||
setupWithSensor(false /* hasSfps */, true /* initialized */);
|
||||
|
||||
for (int state : sAllStates) {
|
||||
setFingerprintState(state);
|
||||
setBiometricState(state);
|
||||
assertThat(mEventHandler.onSinglePressDetected(200L)).isFalse();
|
||||
|
||||
mLooper.dispatchAll();
|
||||
@@ -129,7 +129,7 @@ public class SideFpsEventHandlerTest {
|
||||
setupWithSensor(true /* hasSfps */, false /* initialized */);
|
||||
|
||||
for (int state : sAllStates) {
|
||||
setFingerprintState(state);
|
||||
setBiometricState(state);
|
||||
assertThat(mEventHandler.onSinglePressDetected(400L)).isFalse();
|
||||
|
||||
mLooper.dispatchAll();
|
||||
@@ -141,10 +141,10 @@ public class SideFpsEventHandlerTest {
|
||||
public void ignoresWhenIdleOrUnknown() throws Exception {
|
||||
setupWithSensor(true /* hasSfps */, true /* initialized */);
|
||||
|
||||
setFingerprintState(FingerprintStateListener.STATE_IDLE);
|
||||
setBiometricState(BiometricStateListener.STATE_IDLE);
|
||||
assertThat(mEventHandler.onSinglePressDetected(80000L)).isFalse();
|
||||
|
||||
setFingerprintState(FingerprintStateListener.STATE_AUTH_OTHER);
|
||||
setBiometricState(BiometricStateListener.STATE_AUTH_OTHER);
|
||||
assertThat(mEventHandler.onSinglePressDetected(90000L)).isFalse();
|
||||
|
||||
mLooper.dispatchAll();
|
||||
@@ -155,7 +155,7 @@ public class SideFpsEventHandlerTest {
|
||||
public void ignoresOnKeyguard() throws Exception {
|
||||
setupWithSensor(true /* hasSfps */, true /* initialized */);
|
||||
|
||||
setFingerprintState(FingerprintStateListener.STATE_KEYGUARD_AUTH);
|
||||
setBiometricState(BiometricStateListener.STATE_KEYGUARD_AUTH);
|
||||
assertThat(mEventHandler.onSinglePressDetected(80000L)).isFalse();
|
||||
|
||||
mLooper.dispatchAll();
|
||||
@@ -166,7 +166,7 @@ public class SideFpsEventHandlerTest {
|
||||
public void promptsWhenBPisActive() throws Exception {
|
||||
setupWithSensor(true /* hasSfps */, true /* initialized */);
|
||||
|
||||
setFingerprintState(FingerprintStateListener.STATE_BP_AUTH);
|
||||
setBiometricState(BiometricStateListener.STATE_BP_AUTH);
|
||||
assertThat(mEventHandler.onSinglePressDetected(80000L)).isTrue();
|
||||
|
||||
mLooper.dispatchAll();
|
||||
@@ -177,16 +177,16 @@ public class SideFpsEventHandlerTest {
|
||||
public void promptsWhenEnrolling() throws Exception {
|
||||
setupWithSensor(true /* hasSfps */, true /* initialized */);
|
||||
|
||||
setFingerprintState(FingerprintStateListener.STATE_ENROLLING);
|
||||
setBiometricState(BiometricStateListener.STATE_ENROLLING);
|
||||
assertThat(mEventHandler.onSinglePressDetected(80000L)).isTrue();
|
||||
|
||||
mLooper.dispatchAll();
|
||||
verify(mAlertDialog).show();
|
||||
}
|
||||
|
||||
private void setFingerprintState(@FingerprintStateListener.State int newState) {
|
||||
if (mFingerprintStateListener != null) {
|
||||
mFingerprintStateListener.onStateChanged(newState);
|
||||
private void setBiometricState(@BiometricStateListener.State int newState) {
|
||||
if (mBiometricStateListener != null) {
|
||||
mBiometricStateListener.onStateChanged(newState);
|
||||
mLooper.dispatchAll();
|
||||
}
|
||||
}
|
||||
@@ -204,10 +204,10 @@ public class SideFpsEventHandlerTest {
|
||||
fpCallbackCaptor.getValue().onAllAuthenticatorsRegistered(
|
||||
List.of(mock(FingerprintSensorPropertiesInternal.class)));
|
||||
if (hasSfps) {
|
||||
ArgumentCaptor<FingerprintStateListener> captor = ArgumentCaptor.forClass(
|
||||
FingerprintStateListener.class);
|
||||
verify(mFingerprintManager).registerFingerprintStateListener(captor.capture());
|
||||
mFingerprintStateListener = captor.getValue();
|
||||
ArgumentCaptor<BiometricStateListener> captor = ArgumentCaptor.forClass(
|
||||
BiometricStateListener.class);
|
||||
verify(mFingerprintManager).registerBiometricStateListener(captor.capture());
|
||||
mBiometricStateListener = captor.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user