Add onUdfpsUiEvent() and callbacks on overlay shown in FingerprintManager.

This CL renames onUiReady() to onUdfpsUiEvent() for the event of overlay
shown in FingerprintManager and notifies the mService for calling
corresponding callbacks.

Bug: 280718879
Test: atest UdfpsControllerTest
Change-Id: Ifcd11becb75d81259215d24172636f8f7bb7b6ee
This commit is contained in:
Hao Dong
2023-06-07 00:15:57 +00:00
parent be4612cacf
commit fc3434959a
19 changed files with 130 additions and 33 deletions

View File

@@ -103,6 +103,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
private static final int MSG_UDFPS_POINTER_DOWN = 108; private static final int MSG_UDFPS_POINTER_DOWN = 108;
private static final int MSG_UDFPS_POINTER_UP = 109; private static final int MSG_UDFPS_POINTER_UP = 109;
private static final int MSG_POWER_BUTTON_PRESSED = 110; private static final int MSG_POWER_BUTTON_PRESSED = 110;
private static final int MSG_UDFPS_OVERLAY_SHOWN = 111;
/** /**
* @hide * @hide
@@ -120,6 +121,24 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface EnrollReason {} public @interface EnrollReason {}
/**
* Udfps ui event of overlay is shown on the screen.
* @hide
*/
public static final int UDFPS_UI_OVERLAY_SHOWN = 1;
/**
* Udfps ui event of the udfps UI being ready (e.g. HBM illumination is enabled).
* @hide
*/
public static final int UDFPS_UI_READY = 2;
/**
* @hide
*/
@IntDef({UDFPS_UI_OVERLAY_SHOWN, UDFPS_UI_READY})
@Retention(RetentionPolicy.SOURCE)
public @interface UdfpsUiEvent{}
/** /**
* Request authentication with any single sensor. * Request authentication with any single sensor.
* @hide * @hide
@@ -475,12 +494,17 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
/** /**
* Called when a pointer down event has occurred. * Called when a pointer down event has occurred.
*/ */
public void onPointerDown(int sensorId){ } public void onUdfpsPointerDown(int sensorId){ }
/** /**
* Called when a pointer up event has occurred. * Called when a pointer up event has occurred.
*/ */
public void onPointerUp(int sensorId){ } public void onUdfpsPointerUp(int sensorId){ }
/**
* Called when udfps overlay is shown.
*/
public void onUdfpsOverlayShown() { }
} }
/** /**
@@ -1112,14 +1136,14 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
* @hide * @hide
*/ */
@RequiresPermission(USE_BIOMETRIC_INTERNAL) @RequiresPermission(USE_BIOMETRIC_INTERNAL)
public void onUiReady(long requestId, int sensorId) { public void onUdfpsUiEvent(@UdfpsUiEvent int event, long requestId, int sensorId) {
if (mService == null) { if (mService == null) {
Slog.w(TAG, "onUiReady: no fingerprint service"); Slog.w(TAG, "onUdfpsUiEvent: no fingerprint service");
return; return;
} }
try { try {
mService.onUiReady(requestId, sensorId); mService.onUdfpsUiEvent(event, requestId, sensorId);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1365,6 +1389,8 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
case MSG_POWER_BUTTON_PRESSED: case MSG_POWER_BUTTON_PRESSED:
sendPowerPressed(); sendPowerPressed();
break; break;
case MSG_UDFPS_OVERLAY_SHOWN:
sendUdfpsOverlayShown();
default: default:
Slog.w(TAG, "Unknown message: " + msg.what); Slog.w(TAG, "Unknown message: " + msg.what);
@@ -1489,7 +1515,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
} }
if (mEnrollmentCallback != null) { if (mEnrollmentCallback != null) {
mEnrollmentCallback.onPointerDown(sensorId); mEnrollmentCallback.onUdfpsPointerDown(sensorId);
} }
} }
@@ -1500,7 +1526,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
mAuthenticationCallback.onUdfpsPointerUp(sensorId); mAuthenticationCallback.onUdfpsPointerUp(sensorId);
} }
if (mEnrollmentCallback != null) { if (mEnrollmentCallback != null) {
mEnrollmentCallback.onPointerUp(sensorId); mEnrollmentCallback.onUdfpsPointerUp(sensorId);
} }
} }
@@ -1512,6 +1538,12 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
} }
} }
private void sendUdfpsOverlayShown() {
if (mEnrollmentCallback != null) {
mEnrollmentCallback.onUdfpsOverlayShown();
}
}
/** /**
* @hide * @hide
*/ */
@@ -1787,6 +1819,11 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
public void onUdfpsPointerUp(int sensorId) { public void onUdfpsPointerUp(int sensorId) {
mHandler.obtainMessage(MSG_UDFPS_POINTER_UP, sensorId, 0).sendToTarget(); mHandler.obtainMessage(MSG_UDFPS_POINTER_UP, sensorId, 0).sendToTarget();
} }
@Override
public void onUdfpsOverlayShown() {
mHandler.obtainMessage(MSG_UDFPS_OVERLAY_SHOWN).sendToTarget();
}
}; };
} }

View File

@@ -75,4 +75,9 @@ public class FingerprintServiceReceiver extends IFingerprintServiceReceiver.Stub
public void onUdfpsPointerUp(int sensorId) throws RemoteException { public void onUdfpsPointerUp(int sensorId) throws RemoteException {
} }
@Override
public void onUdfpsOverlayShown() throws RemoteException {
}
} }

View File

@@ -193,7 +193,7 @@ interface IFingerprintService {
// Notifies about the fingerprint UI being ready (e.g. HBM illumination is enabled). // Notifies about the fingerprint UI being ready (e.g. HBM illumination is enabled).
@EnforcePermission("USE_BIOMETRIC_INTERNAL") @EnforcePermission("USE_BIOMETRIC_INTERNAL")
void onUiReady(long requestId, int sensorId); void onUdfpsUiEvent(int event, long requestId, int sensorId);
// Sets the controller for managing the UDFPS overlay. // Sets the controller for managing the UDFPS overlay.
@EnforcePermission("USE_BIOMETRIC_INTERNAL") @EnforcePermission("USE_BIOMETRIC_INTERNAL")

View File

@@ -32,4 +32,5 @@ oneway interface IFingerprintServiceReceiver {
void onChallengeGenerated(int sensorId, int userId, long challenge); void onChallengeGenerated(int sensorId, int userId, long challenge);
void onUdfpsPointerDown(int sensorId); void onUdfpsPointerDown(int sensorId);
void onUdfpsPointerUp(int sensorId); void onUdfpsPointerUp(int sensorId);
void onUdfpsOverlayShown();
} }

View File

@@ -356,7 +356,8 @@ public class UdfpsController implements DozeReceiver, Dumpable {
UdfpsController.this.mAlternateTouchProvider.onUiReady(); UdfpsController.this.mAlternateTouchProvider.onUiReady();
} else { } else {
final long requestId = (mOverlay != null) ? mOverlay.getRequestId() : 0L; final long requestId = (mOverlay != null) ? mOverlay.getRequestId() : 0L;
UdfpsController.this.mFingerprintManager.onUiReady(requestId, sensorId); UdfpsController.this.mFingerprintManager.onUdfpsUiEvent(
FingerprintManager.UDFPS_UI_READY, requestId, sensorId);
} }
} }
} }
@@ -960,6 +961,10 @@ public class UdfpsController implements DozeReceiver, Dumpable {
mOnFingerDown = false; mOnFingerDown = false;
mAttemptedToDismissKeyguard = false; mAttemptedToDismissKeyguard = false;
mOrientationListener.enable(); mOrientationListener.enable();
if (mFingerprintManager != null) {
mFingerprintManager.onUdfpsUiEvent(FingerprintManager.UDFPS_UI_OVERLAY_SHOWN,
overlay.getRequestId(), mSensorProps.sensorId);
}
} else { } else {
Log.v(TAG, "showUdfpsOverlay | the overlay is already showing"); Log.v(TAG, "showUdfpsOverlay | the overlay is already showing");
} }
@@ -1101,7 +1106,8 @@ public class UdfpsController implements DozeReceiver, Dumpable {
mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE); mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
}); });
} else { } else {
mFingerprintManager.onUiReady(requestId, mSensorProps.sensorId); mFingerprintManager.onUdfpsUiEvent(FingerprintManager.UDFPS_UI_READY, requestId,
mSensorProps.sensorId);
mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE); mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
} }
} }

View File

@@ -439,6 +439,16 @@ public class UdfpsControllerTest extends SysuiTestCase {
verify(mStatusBarKeyguardViewManager).hideAlternateBouncer(eq(true)); verify(mStatusBarKeyguardViewManager).hideAlternateBouncer(eq(true));
} }
@Test
public void showUdfpsOverlay_callsListener() throws RemoteException {
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
mFgExecutor.runAllReady();
verify(mFingerprintManager).onUdfpsUiEvent(FingerprintManager.UDFPS_UI_OVERLAY_SHOWN,
TEST_REQUEST_ID, mOpticalProps.sensorId);
}
@Test @Test
public void testSubscribesToOrientationChangesWhenShowingOverlay() throws Exception { public void testSubscribesToOrientationChangesWhenShowingOverlay() throws Exception {
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId, mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
@@ -759,17 +769,20 @@ public class UdfpsControllerTest extends SysuiTestCase {
inOrder.verify(mAlternateTouchProvider).onUiReady(); inOrder.verify(mAlternateTouchProvider).onUiReady();
inOrder.verify(mLatencyTracker).onActionEnd( inOrder.verify(mLatencyTracker).onActionEnd(
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE)); eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
verify(mFingerprintManager, never()).onUiReady(anyLong(), anyInt()); verify(mFingerprintManager, never()).onUdfpsUiEvent(
eq(FingerprintManager.UDFPS_UI_READY), anyLong(), anyInt());
} else { } else {
InOrder inOrder = inOrder(mFingerprintManager, mLatencyTracker); InOrder inOrder = inOrder(mFingerprintManager, mLatencyTracker);
inOrder.verify(mFingerprintManager).onUiReady(eq(TEST_REQUEST_ID), inOrder.verify(mFingerprintManager).onUdfpsUiEvent(
eq(FingerprintManager.UDFPS_UI_READY), eq(TEST_REQUEST_ID),
eq(testParams.sensorProps.sensorId)); eq(testParams.sensorProps.sensorId));
inOrder.verify(mLatencyTracker).onActionEnd( inOrder.verify(mLatencyTracker).onActionEnd(
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE)); eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
verify(mAlternateTouchProvider, never()).onUiReady(); verify(mAlternateTouchProvider, never()).onUiReady();
} }
} else { } else {
verify(mFingerprintManager, never()).onUiReady(anyLong(), anyInt()); verify(mFingerprintManager, never()).onUdfpsUiEvent(
eq(FingerprintManager.UDFPS_UI_READY), anyLong(), anyInt());
verify(mAlternateTouchProvider, never()).onUiReady(); verify(mAlternateTouchProvider, never()).onUiReady();
verify(mLatencyTracker, never()).onActionEnd( verify(mLatencyTracker, never()).onActionEnd(
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE)); eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));

View File

@@ -170,6 +170,12 @@ public class ClientMonitorCallbackConverter {
} }
} }
public void onUdfpsOverlayShown() throws RemoteException {
if (mFingerprintServiceReceiver != null) {
mFingerprintServiceReceiver.onUdfpsOverlayShown();
}
}
// Face-specific callbacks for FaceManager only // Face-specific callbacks for FaceManager only
/** /**

View File

@@ -929,17 +929,19 @@ public class FingerprintService extends SystemService {
@android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL) @android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL)
@Override @Override
public void onUiReady(long requestId, int sensorId) { public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event, long requestId,
super.onUiReady_enforcePermission(); int sensorId) {
super.onUdfpsUiEvent_enforcePermission();
final ServiceProvider provider = mRegistry.getProviderForSensor(sensorId); final ServiceProvider provider = mRegistry.getProviderForSensor(sensorId);
if (provider == null) { if (provider == null) {
Slog.w(TAG, "No matching provider for onUiReady, sensorId: " + sensorId); Slog.w(TAG, "No matching provider for onUdfpsUiEvent, sensorId: " + sensorId);
return; return;
} }
provider.onUiReady(requestId, sensorId); provider.onUdfpsUiEvent(event, requestId, sensorId);
} }
@android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL) @android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL)
@Override @Override
public void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller) { public void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller) {

View File

@@ -130,7 +130,7 @@ public interface ServiceProvider extends
void onPointerUp(long requestId, int sensorId, PointerContext pc); void onPointerUp(long requestId, int sensorId, PointerContext pc);
void onUiReady(long requestId, int sensorId); void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event, long requestId, int sensorId);
void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller); void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller);

View File

@@ -17,6 +17,7 @@
package com.android.server.biometrics.sensors.fingerprint; package com.android.server.biometrics.sensors.fingerprint;
import android.hardware.biometrics.fingerprint.PointerContext; import android.hardware.biometrics.fingerprint.PointerContext;
import android.hardware.fingerprint.FingerprintManager;
import com.android.server.biometrics.sensors.BaseClientMonitor; import com.android.server.biometrics.sensors.BaseClientMonitor;
@@ -28,6 +29,6 @@ import com.android.server.biometrics.sensors.BaseClientMonitor;
public interface Udfps { public interface Udfps {
void onPointerDown(PointerContext pc); void onPointerDown(PointerContext pc);
void onPointerUp(PointerContext pc); void onPointerUp(PointerContext pc);
void onUiReady(); void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event);
boolean isPointerDown(); boolean isPointerDown();
} }

View File

@@ -114,6 +114,11 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
public void onUdfpsPointerUp(int sensorId) { public void onUdfpsPointerUp(int sensorId) {
} }
@Override
public void onUdfpsOverlayShown() {
}
}; };
BiometricTestSessionImpl(@NonNull Context context, int sensorId, BiometricTestSessionImpl(@NonNull Context context, int sensorId,

View File

@@ -27,6 +27,7 @@ import android.hardware.biometrics.BiometricManager.Authenticators;
import android.hardware.biometrics.common.ICancellationSignal; import android.hardware.biometrics.common.ICancellationSignal;
import android.hardware.biometrics.fingerprint.PointerContext; import android.hardware.biometrics.fingerprint.PointerContext;
import android.hardware.fingerprint.FingerprintAuthenticateOptions; import android.hardware.fingerprint.FingerprintAuthenticateOptions;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.ISidefpsController; import android.hardware.fingerprint.ISidefpsController;
import android.hardware.fingerprint.IUdfpsOverlay; import android.hardware.fingerprint.IUdfpsOverlay;
@@ -363,9 +364,11 @@ class FingerprintAuthenticationClient
} }
@Override @Override
public void onUiReady() { public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
try { try {
getFreshDaemon().getSession().onUiReady(); if (event == FingerprintManager.UDFPS_UI_READY) {
getFreshDaemon().getSession().onUiReady();
}
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e); Slog.e(TAG, "Remote exception", e);
} }

View File

@@ -265,11 +265,20 @@ class FingerprintEnrollClient extends EnrollClient<AidlSession> implements Udfps
} }
@Override @Override
public void onUiReady() { public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
try { try {
getFreshDaemon().getSession().onUiReady(); switch (event) {
case FingerprintManager.UDFPS_UI_OVERLAY_SHOWN:
getListener().onUdfpsOverlayShown();
break;
case FingerprintManager.UDFPS_UI_READY:
getFreshDaemon().getSession().onUiReady();
break;
default:
Slog.w(TAG, "No matching event for onUdfpsUiEvent");
}
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Unable to send UI ready", e); Slog.e(TAG, "Unable to send onUdfpsUiEvent", e);
} }
} }

View File

@@ -669,14 +669,15 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
} }
@Override @Override
public void onUiReady(long requestId, int sensorId) { public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event, long requestId,
int sensorId) {
mFingerprintSensors.get(sensorId).getScheduler().getCurrentClientIfMatches( mFingerprintSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(
requestId, (client) -> { requestId, (client) -> {
if (!(client instanceof Udfps)) { if (!(client instanceof Udfps)) {
Slog.e(getTag(), "onUiReady received during client: " + client); Slog.e(getTag(), "onUdfpsUiEvent received during client: " + client);
return; return;
} }
((Udfps) client).onUiReady(); ((Udfps) client).onUdfpsUiEvent(event);
}); });
} }

View File

@@ -115,6 +115,11 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
public void onUdfpsPointerUp(int sensorId) { public void onUdfpsPointerUp(int sensorId) {
} }
@Override
public void onUdfpsOverlayShown() {
}
}; };
BiometricTestSessionImpl(@NonNull Context context, int sensorId, BiometricTestSessionImpl(@NonNull Context context, int sensorId,

View File

@@ -829,13 +829,14 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
} }
@Override @Override
public void onUiReady(long requestId, int sensorId) { public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event, long requestId,
int sensorId) {
mScheduler.getCurrentClientIfMatches(requestId, (client) -> { mScheduler.getCurrentClientIfMatches(requestId, (client) -> {
if (!(client instanceof Udfps)) { if (!(client instanceof Udfps)) {
Slog.w(TAG, "onUiReady received during client: " + client); Slog.w(TAG, "onUdfpsUiEvent received during client: " + client);
return; return;
} }
((Udfps) client).onUiReady(); ((Udfps) client).onUdfpsUiEvent(event);
}); });
} }

View File

@@ -27,6 +27,7 @@ import android.hardware.biometrics.BiometricManager.Authenticators;
import android.hardware.biometrics.fingerprint.PointerContext; import android.hardware.biometrics.fingerprint.PointerContext;
import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprint; import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprint;
import android.hardware.fingerprint.FingerprintAuthenticateOptions; import android.hardware.fingerprint.FingerprintAuthenticateOptions;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.ISidefpsController; import android.hardware.fingerprint.ISidefpsController;
import android.hardware.fingerprint.IUdfpsOverlay; import android.hardware.fingerprint.IUdfpsOverlay;
@@ -273,7 +274,7 @@ class FingerprintAuthenticationClient
} }
@Override @Override
public void onUiReady() { public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
// Unsupported in HIDL. // Unsupported in HIDL.
} }
} }

View File

@@ -25,6 +25,7 @@ import android.hardware.biometrics.BiometricOverlayConstants;
import android.hardware.biometrics.fingerprint.PointerContext; import android.hardware.biometrics.fingerprint.PointerContext;
import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprint; import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprint;
import android.hardware.fingerprint.FingerprintAuthenticateOptions; import android.hardware.fingerprint.FingerprintAuthenticateOptions;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.IUdfpsOverlay; import android.hardware.fingerprint.IUdfpsOverlay;
import android.hardware.fingerprint.IUdfpsOverlayController; import android.hardware.fingerprint.IUdfpsOverlayController;
import android.os.IBinder; import android.os.IBinder;
@@ -130,7 +131,7 @@ class FingerprintDetectClient extends AcquisitionClient<IBiometricsFingerprint>
} }
@Override @Override
public void onUiReady() { public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
// Unsupported in HIDL. // Unsupported in HIDL.
} }

View File

@@ -186,7 +186,7 @@ public class FingerprintEnrollClient extends EnrollClient<IBiometricsFingerprint
} }
@Override @Override
public void onUiReady() { public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
// Unsupported in HIDL. // Unsupported in HIDL.
} }
} }