Merge "Split onPointerDown to onPointerDown and onUiReady" into sc-dev

This commit is contained in:
Ilya Matyukhin
2021-05-10 07:36:14 +00:00
committed by Android (Google) Code Review
15 changed files with 108 additions and 15 deletions

View File

@@ -925,6 +925,23 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
}
}
/**
* @hide
*/
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
public void onUiReady(int sensorId) {
if (mService == null) {
Slog.w(TAG, "onUiReady: no fingerprint service");
return;
}
try {
mService.onUiReady(sensorId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Determine if there is at least one fingerprint enrolled.
*
@@ -1450,7 +1467,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
@Override // binder call
public void onUdfpsPointerUp(int sensorId) {
mHandler.obtainMessage(MSG_UDFPS_POINTER_UP, sensorId, 0).sendToTarget();
}
};

View File

@@ -160,6 +160,9 @@ interface IFingerprintService {
// Notifies about a finger leaving the sensor area.
void onPointerUp(int sensorId);
// Notifies about the fingerprint UI being ready (e.g. HBM illumination is enabled).
void onUiReady(int sensorId);
// Sets the controller for managing the UDFPS overlay.
void setUdfpsOverlayController(in IUdfpsOverlayController controller);

View File

@@ -345,7 +345,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
}
if (isWithinSensorArea(udfpsView, event.getX(), event.getY(), fromUdfpsView)) {
Trace.beginAsyncSection(
"UdfpsController.mOnTouchListener#isWithinSensorArea", 1);
"UdfpsController#ACTION_DOWN", 1);
// The pointer that causes ACTION_DOWN is always at index 0.
// We need to persist its ID to track it during ACTION_MOVE that could include
// data for many other pointers because of multi-touch support.
@@ -382,8 +382,6 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
minor, major, v, exceedsVelocityThreshold);
final long sinceLastLog = SystemClock.elapsedRealtime() - mTouchLogTime;
if (!isFingerDown && !exceedsVelocityThreshold) {
Trace.endAsyncSection(
"UdfpsController.mOnTouchListener#isWithinSensorArea", 1);
onFingerDown((int) x, (int) y, minor, major);
Log.v(TAG, "onTouch | finger down: " + touchInfo);
mTouchLogTime = SystemClock.elapsedRealtime();
@@ -761,10 +759,13 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
Log.w(TAG, "Null view in onFingerDown");
return;
}
mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major);
Trace.endAsyncSection(
"UdfpsController#ACTION_DOWN", 1);
Trace.beginAsyncSection("UdfpsController#startIllumination", 1);
mView.startIllumination(() -> {
mFingerprintManager.onUiReady(mSensorProps.sensorId);
Trace.endAsyncSection("UdfpsController#startIllumination", 1);
mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major);
});
}

View File

@@ -232,12 +232,14 @@ public class UdfpsControllerTest extends SysuiTestCase {
MotionEvent moveEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, 0, 0);
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent);
moveEvent.recycle();
// THEN illumination begins
// AND onIlluminatedRunnable that notifies FingerprintManager is set
verify(mUdfpsView).startIllumination(mOnIlluminatedRunnableCaptor.capture());
mOnIlluminatedRunnableCaptor.getValue().run();
// THEN FingerprintManager is notified about onPointerDown
verify(mFingerprintManager).onPointerDown(eq(mUdfpsController.mSensorProps.sensorId), eq(0),
eq(0), eq(0f), eq(0f));
// AND illumination begins
verify(mUdfpsView).startIllumination(mOnIlluminatedRunnableCaptor.capture());
// AND onIlluminatedRunnable notifies FingerprintManager about onUiReady
mOnIlluminatedRunnableCaptor.getValue().run();
verify(mFingerprintManager).onUiReady(eq(mUdfpsController.mSensorProps.sensorId));
}
@Test

View File

@@ -167,13 +167,13 @@ public class ClientMonitorCallbackConverter {
// Fingerprint-specific callbacks for FingerprintManager only
public void onUdfpsPointerDown(int sensorId, int cookie) throws RemoteException {
public void onUdfpsPointerDown(int sensorId) throws RemoteException {
if (mFingerprintServiceReceiver != null) {
mFingerprintServiceReceiver.onUdfpsPointerDown(sensorId);
}
}
public void onUdfpsPointerUp(int sensorId, int cookie) throws RemoteException {
public void onUdfpsPointerUp(int sensorId) throws RemoteException {
if (mFingerprintServiceReceiver != null) {
mFingerprintServiceReceiver.onUdfpsPointerUp(sensorId);
}

View File

@@ -924,6 +924,18 @@ public class FingerprintService extends SystemService {
provider.onPointerUp(sensorId);
}
@Override
public void onUiReady(int sensorId) {
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
final ServiceProvider provider = getProviderForSensor(sensorId);
if (provider == null) {
Slog.w(TAG, "No matching provider for onUiReady, sensorId: " + sensorId);
return;
}
provider.onUiReady(sensorId);
}
@Override
public void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller) {
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);

View File

@@ -140,6 +140,8 @@ public interface ServiceProvider {
void onPointerUp(int sensorId);
void onUiReady(int sensorId);
void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller);
void dumpProtoState(int sensorId, @NonNull ProtoOutputStream proto,

View File

@@ -26,4 +26,5 @@ import com.android.server.biometrics.sensors.BaseClientMonitor;
public interface Udfps {
void onPointerDown(int x, int y, float minor, float major);
void onPointerUp();
void onUiReady();
}

View File

@@ -120,7 +120,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
try {
getFreshDaemon().onPointerDown(0 /* pointerId */, x, y, minor, major);
if (getListener() != null) {
getListener().onUdfpsPointerDown(getSensorId(), getCookie());
getListener().onUdfpsPointerDown(getSensorId());
}
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
@@ -132,13 +132,22 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
try {
getFreshDaemon().onPointerUp(0 /* pointerId */);
if (getListener() != null) {
getListener().onUdfpsPointerUp(getSensorId(), getCookie());
getListener().onUdfpsPointerUp(getSensorId());
}
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
}
}
@Override
public void onUiReady() {
try {
getFreshDaemon().onUiReady();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
}
}
@Override
public void onLockoutTimed(long durationMillis) {
mLockoutCache.setLockoutModeForUser(getTargetUserId(), LockoutTracker.LOCKOUT_TIMED);

View File

@@ -150,4 +150,13 @@ class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
Slog.e(TAG, "Unable to send pointer up", e);
}
}
@Override
public void onUiReady() {
try {
getFreshDaemon().onUiReady();
} catch (RemoteException e) {
Slog.e(TAG, "Unable to send UI ready", e);
}
}
}

View File

@@ -513,6 +513,18 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
udfps.onPointerUp();
}
@Override
public void onUiReady(int sensorId) {
final BaseClientMonitor client =
mSensors.get(sensorId).getScheduler().getCurrentClient();
if (!(client instanceof Udfps)) {
Slog.e(getTag(), "onUiReady received during client: " + client);
return;
}
final Udfps udfps = (Udfps) client;
udfps.onUiReady();
}
@Override
public void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller) {
mUdfpsOverlayController = controller;

View File

@@ -737,6 +737,17 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
udfps.onPointerUp();
}
@Override
public void onUiReady(int sensorId) {
final BaseClientMonitor client = mScheduler.getCurrentClient();
if (!(client instanceof Udfps)) {
Slog.w(TAG, "onUiReady received during client: " + client);
return;
}
final Udfps udfps = (Udfps) client;
udfps.onUiReady();
}
@Override
public void setUdfpsOverlayController(@NonNull IUdfpsOverlayController controller) {
mUdfpsOverlayController = controller;

View File

@@ -152,7 +152,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<IBiometricsFi
UdfpsHelper.onFingerDown(getFreshDaemon(), x, y, minor, major);
if (getListener() != null) {
try {
getListener().onUdfpsPointerDown(getSensorId(), getCookie());
getListener().onUdfpsPointerDown(getSensorId());
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
}
@@ -164,10 +164,15 @@ class FingerprintAuthenticationClient extends AuthenticationClient<IBiometricsFi
UdfpsHelper.onFingerUp(getFreshDaemon());
if (getListener() != null) {
try {
getListener().onUdfpsPointerUp(getSensorId(), getCookie());
getListener().onUdfpsPointerUp(getSensorId());
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
}
}
}
@Override
public void onUiReady() {
// Unsupported in HIDL.
}
}

View File

@@ -107,6 +107,11 @@ class FingerprintDetectClient extends AcquisitionClient<IBiometricsFingerprint>
UdfpsHelper.onFingerUp(getFreshDaemon());
}
@Override
public void onUiReady() {
// Unsupported in HIDL.
}
@Override
public void onAuthenticated(BiometricAuthenticator.Identifier identifier, boolean authenticated,
ArrayList<Byte> hardwareAuthToken) {

View File

@@ -146,4 +146,9 @@ public class FingerprintEnrollClient extends EnrollClient<IBiometricsFingerprint
public void onPointerUp() {
UdfpsHelper.onFingerUp(getFreshDaemon());
}
@Override
public void onUiReady() {
// Unsupported in HIDL.
}
}