Merge "Add onUdfpsUiEvent() and callbacks on overlay shown in FingerprintManager." into udc-qpr-dev
This commit is contained in:
@@ -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_UP = 109;
|
||||
private static final int MSG_POWER_BUTTON_PRESSED = 110;
|
||||
private static final int MSG_UDFPS_OVERLAY_SHOWN = 111;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
@@ -120,6 +121,24 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
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.
|
||||
* @hide
|
||||
@@ -475,12 +494,17 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
|
||||
public void onUiReady(long requestId, int sensorId) {
|
||||
public void onUdfpsUiEvent(@UdfpsUiEvent int event, long requestId, int sensorId) {
|
||||
if (mService == null) {
|
||||
Slog.w(TAG, "onUiReady: no fingerprint service");
|
||||
Slog.w(TAG, "onUdfpsUiEvent: no fingerprint service");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
mService.onUiReady(requestId, sensorId);
|
||||
mService.onUdfpsUiEvent(event, requestId, sensorId);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1365,6 +1389,8 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
case MSG_POWER_BUTTON_PRESSED:
|
||||
sendPowerPressed();
|
||||
break;
|
||||
case MSG_UDFPS_OVERLAY_SHOWN:
|
||||
sendUdfpsOverlayShown();
|
||||
default:
|
||||
Slog.w(TAG, "Unknown message: " + msg.what);
|
||||
|
||||
@@ -1489,7 +1515,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
}
|
||||
|
||||
if (mEnrollmentCallback != null) {
|
||||
mEnrollmentCallback.onPointerDown(sensorId);
|
||||
mEnrollmentCallback.onUdfpsPointerDown(sensorId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1500,7 +1526,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
mAuthenticationCallback.onUdfpsPointerUp(sensorId);
|
||||
}
|
||||
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
|
||||
*/
|
||||
@@ -1787,6 +1819,11 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
public void onUdfpsPointerUp(int sensorId) {
|
||||
mHandler.obtainMessage(MSG_UDFPS_POINTER_UP, sensorId, 0).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUdfpsOverlayShown() {
|
||||
mHandler.obtainMessage(MSG_UDFPS_OVERLAY_SHOWN).sendToTarget();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -75,4 +75,9 @@ public class FingerprintServiceReceiver extends IFingerprintServiceReceiver.Stub
|
||||
public void onUdfpsPointerUp(int sensorId) throws RemoteException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUdfpsOverlayShown() throws RemoteException {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ interface IFingerprintService {
|
||||
|
||||
// Notifies about the fingerprint UI being ready (e.g. HBM illumination is enabled).
|
||||
@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.
|
||||
@EnforcePermission("USE_BIOMETRIC_INTERNAL")
|
||||
|
||||
@@ -32,4 +32,5 @@ oneway interface IFingerprintServiceReceiver {
|
||||
void onChallengeGenerated(int sensorId, int userId, long challenge);
|
||||
void onUdfpsPointerDown(int sensorId);
|
||||
void onUdfpsPointerUp(int sensorId);
|
||||
void onUdfpsOverlayShown();
|
||||
}
|
||||
|
||||
@@ -356,7 +356,8 @@ public class UdfpsController implements DozeReceiver, Dumpable {
|
||||
UdfpsController.this.mAlternateTouchProvider.onUiReady();
|
||||
} else {
|
||||
final long requestId = (mOverlay != null) ? mOverlay.getRequestId() : 0L;
|
||||
UdfpsController.this.mFingerprintManager.onUiReady(requestId, sensorId);
|
||||
UdfpsController.this.mFingerprintManager.onUdfpsUiEvent(
|
||||
FingerprintManager.UDFPS_UI_READY, requestId, sensorId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -956,6 +957,10 @@ public class UdfpsController implements DozeReceiver, Dumpable {
|
||||
mOnFingerDown = false;
|
||||
mAttemptedToDismissKeyguard = false;
|
||||
mOrientationListener.enable();
|
||||
if (mFingerprintManager != null) {
|
||||
mFingerprintManager.onUdfpsUiEvent(FingerprintManager.UDFPS_UI_OVERLAY_SHOWN,
|
||||
overlay.getRequestId(), mSensorProps.sensorId);
|
||||
}
|
||||
} else {
|
||||
Log.v(TAG, "showUdfpsOverlay | the overlay is already showing");
|
||||
}
|
||||
@@ -1097,7 +1102,8 @@ public class UdfpsController implements DozeReceiver, Dumpable {
|
||||
mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
|
||||
});
|
||||
} else {
|
||||
mFingerprintManager.onUiReady(requestId, mSensorProps.sensorId);
|
||||
mFingerprintManager.onUdfpsUiEvent(FingerprintManager.UDFPS_UI_READY, requestId,
|
||||
mSensorProps.sensorId);
|
||||
mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,6 +442,16 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
||||
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
|
||||
public void testSubscribesToOrientationChangesWhenShowingOverlay() throws Exception {
|
||||
mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
|
||||
@@ -762,17 +772,20 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
||||
inOrder.verify(mAlternateTouchProvider).onUiReady();
|
||||
inOrder.verify(mLatencyTracker).onActionEnd(
|
||||
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
|
||||
verify(mFingerprintManager, never()).onUiReady(anyLong(), anyInt());
|
||||
verify(mFingerprintManager, never()).onUdfpsUiEvent(
|
||||
eq(FingerprintManager.UDFPS_UI_READY), anyLong(), anyInt());
|
||||
} else {
|
||||
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));
|
||||
inOrder.verify(mLatencyTracker).onActionEnd(
|
||||
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
|
||||
verify(mAlternateTouchProvider, never()).onUiReady();
|
||||
}
|
||||
} else {
|
||||
verify(mFingerprintManager, never()).onUiReady(anyLong(), anyInt());
|
||||
verify(mFingerprintManager, never()).onUdfpsUiEvent(
|
||||
eq(FingerprintManager.UDFPS_UI_READY), anyLong(), anyInt());
|
||||
verify(mAlternateTouchProvider, never()).onUiReady();
|
||||
verify(mLatencyTracker, never()).onActionEnd(
|
||||
eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE));
|
||||
|
||||
@@ -170,6 +170,12 @@ public class ClientMonitorCallbackConverter {
|
||||
}
|
||||
}
|
||||
|
||||
public void onUdfpsOverlayShown() throws RemoteException {
|
||||
if (mFingerprintServiceReceiver != null) {
|
||||
mFingerprintServiceReceiver.onUdfpsOverlayShown();
|
||||
}
|
||||
}
|
||||
|
||||
// Face-specific callbacks for FaceManager only
|
||||
|
||||
/**
|
||||
|
||||
@@ -929,17 +929,19 @@ public class FingerprintService extends SystemService {
|
||||
|
||||
@android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL)
|
||||
@Override
|
||||
public void onUiReady(long requestId, int sensorId) {
|
||||
super.onUiReady_enforcePermission();
|
||||
public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event, long requestId,
|
||||
int sensorId) {
|
||||
super.onUdfpsUiEvent_enforcePermission();
|
||||
|
||||
final ServiceProvider provider = mRegistry.getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "No matching provider for onUiReady, sensorId: " + sensorId);
|
||||
Slog.w(TAG, "No matching provider for onUdfpsUiEvent, sensorId: " + sensorId);
|
||||
return;
|
||||
}
|
||||
provider.onUiReady(requestId, sensorId);
|
||||
provider.onUdfpsUiEvent(event, requestId, sensorId);
|
||||
}
|
||||
|
||||
|
||||
@android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL)
|
||||
@Override
|
||||
public void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller) {
|
||||
|
||||
@@ -130,7 +130,7 @@ public interface ServiceProvider extends
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.server.biometrics.sensors.fingerprint;
|
||||
|
||||
import android.hardware.biometrics.fingerprint.PointerContext;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
|
||||
@@ -28,6 +29,6 @@ import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
public interface Udfps {
|
||||
void onPointerDown(PointerContext pc);
|
||||
void onPointerUp(PointerContext pc);
|
||||
void onUiReady();
|
||||
void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event);
|
||||
boolean isPointerDown();
|
||||
}
|
||||
|
||||
@@ -114,6 +114,11 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void onUdfpsPointerUp(int sensorId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUdfpsOverlayShown() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId,
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.hardware.biometrics.BiometricManager.Authenticators;
|
||||
import android.hardware.biometrics.common.ICancellationSignal;
|
||||
import android.hardware.biometrics.fingerprint.PointerContext;
|
||||
import android.hardware.fingerprint.FingerprintAuthenticateOptions;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.ISidefpsController;
|
||||
import android.hardware.fingerprint.IUdfpsOverlay;
|
||||
@@ -363,9 +364,11 @@ class FingerprintAuthenticationClient
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiReady() {
|
||||
public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
|
||||
try {
|
||||
getFreshDaemon().getSession().onUiReady();
|
||||
if (event == FingerprintManager.UDFPS_UI_READY) {
|
||||
getFreshDaemon().getSession().onUiReady();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
|
||||
@@ -265,11 +265,20 @@ class FingerprintEnrollClient extends EnrollClient<AidlSession> implements Udfps
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiReady() {
|
||||
public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
|
||||
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) {
|
||||
Slog.e(TAG, "Unable to send UI ready", e);
|
||||
Slog.e(TAG, "Unable to send onUdfpsUiEvent", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -681,14 +681,15 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiReady(long requestId, int sensorId) {
|
||||
public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event, long requestId,
|
||||
int sensorId) {
|
||||
mFingerprintSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(
|
||||
requestId, (client) -> {
|
||||
if (!(client instanceof Udfps)) {
|
||||
Slog.e(getTag(), "onUiReady received during client: " + client);
|
||||
Slog.e(getTag(), "onUdfpsUiEvent received during client: " + client);
|
||||
return;
|
||||
}
|
||||
((Udfps) client).onUiReady();
|
||||
((Udfps) client).onUdfpsUiEvent(event);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,11 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void onUdfpsPointerUp(int sensorId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUdfpsOverlayShown() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId,
|
||||
|
||||
@@ -829,13 +829,14 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiReady(long requestId, int sensorId) {
|
||||
public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event, long requestId,
|
||||
int sensorId) {
|
||||
mScheduler.getCurrentClientIfMatches(requestId, (client) -> {
|
||||
if (!(client instanceof Udfps)) {
|
||||
Slog.w(TAG, "onUiReady received during client: " + client);
|
||||
Slog.w(TAG, "onUdfpsUiEvent received during client: " + client);
|
||||
return;
|
||||
}
|
||||
((Udfps) client).onUiReady();
|
||||
((Udfps) client).onUdfpsUiEvent(event);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.hardware.biometrics.BiometricManager.Authenticators;
|
||||
import android.hardware.biometrics.fingerprint.PointerContext;
|
||||
import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprint;
|
||||
import android.hardware.fingerprint.FingerprintAuthenticateOptions;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.ISidefpsController;
|
||||
import android.hardware.fingerprint.IUdfpsOverlay;
|
||||
@@ -273,7 +274,7 @@ class FingerprintAuthenticationClient
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiReady() {
|
||||
public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
|
||||
// Unsupported in HIDL.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.hardware.biometrics.BiometricOverlayConstants;
|
||||
import android.hardware.biometrics.fingerprint.PointerContext;
|
||||
import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprint;
|
||||
import android.hardware.fingerprint.FingerprintAuthenticateOptions;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.IUdfpsOverlay;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
import android.os.IBinder;
|
||||
@@ -130,7 +131,7 @@ class FingerprintDetectClient extends AcquisitionClient<IBiometricsFingerprint>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiReady() {
|
||||
public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
|
||||
// Unsupported in HIDL.
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public class FingerprintEnrollClient extends EnrollClient<IBiometricsFingerprint
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiReady() {
|
||||
public void onUdfpsUiEvent(@FingerprintManager.UdfpsUiEvent int event) {
|
||||
// Unsupported in HIDL.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user